babylon.d.ts 1.5 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871
  1. declare module 'babylonjs' {
  2. export = BABYLON;
  3. }
  4. declare module BABYLON {
  5. /**
  6. * Set of assets to keep when moving a scene into an asset container.
  7. */
  8. class KeepAssets {
  9. /**
  10. * Cameras to keep.
  11. */
  12. cameras: Camera[];
  13. /**
  14. * Lights to keep.
  15. */
  16. lights: Light[];
  17. /**
  18. * Meshes to keep.
  19. */
  20. meshes: AbstractMesh[];
  21. /**
  22. * Skeletons to keep.
  23. */
  24. skeletons: Skeleton[];
  25. /**
  26. * ParticleSystems to keep.
  27. */
  28. particleSystems: IParticleSystem[];
  29. /**
  30. * Animations to keep.
  31. */
  32. animations: Animation[];
  33. /**
  34. * AnimationGroups to keep.
  35. */
  36. animationGroups: AnimationGroup[];
  37. /**
  38. * MultiMaterials to keep.
  39. */
  40. multiMaterials: MultiMaterial[];
  41. /**
  42. * Materials to keep.
  43. */
  44. materials: Material[];
  45. /**
  46. * MorphTargetManagers to keep.
  47. */
  48. morphTargetManagers: MorphTargetManager[];
  49. /**
  50. * Geometries to keep.
  51. */
  52. geometries: Geometry[];
  53. /**
  54. * TransformNodes to keep.
  55. */
  56. transformNodes: TransformNode[];
  57. /**
  58. * LensFlareSystems to keep.
  59. */
  60. lensFlareSystems: LensFlareSystem[];
  61. /**
  62. * ShadowGenerators to keep.
  63. */
  64. shadowGenerators: ShadowGenerator[];
  65. /**
  66. * ActionManagers to keep.
  67. */
  68. actionManagers: ActionManager[];
  69. /**
  70. * Sounds to keep.
  71. */
  72. sounds: Sound[];
  73. /**
  74. * Textures to keep.
  75. */
  76. textures: Texture[];
  77. /**
  78. * Effect layers to keep.
  79. */
  80. effectLayers: EffectLayer[];
  81. }
  82. /**
  83. * Container with a set of assets that can be added or removed from a scene.
  84. */
  85. class AssetContainer {
  86. /**
  87. * The scene the AssetContainer belongs to.
  88. */
  89. scene: Scene;
  90. /**
  91. * Cameras populated in the container.
  92. */
  93. cameras: Camera[];
  94. /**
  95. * Lights populated in the container.
  96. */
  97. lights: Light[];
  98. /**
  99. * Meshes populated in the container.
  100. */
  101. meshes: AbstractMesh[];
  102. /**
  103. * Skeletons populated in the container.
  104. */
  105. skeletons: Skeleton[];
  106. /**
  107. * ParticleSystems populated in the container.
  108. */
  109. particleSystems: IParticleSystem[];
  110. /**
  111. * Animations populated in the container.
  112. */
  113. animations: Animation[];
  114. /**
  115. * AnimationGroups populated in the container.
  116. */
  117. animationGroups: AnimationGroup[];
  118. /**
  119. * MultiMaterials populated in the container.
  120. */
  121. multiMaterials: MultiMaterial[];
  122. /**
  123. * Materials populated in the container.
  124. */
  125. materials: Material[];
  126. /**
  127. * MorphTargetManagers populated in the container.
  128. */
  129. morphTargetManagers: MorphTargetManager[];
  130. /**
  131. * Geometries populated in the container.
  132. */
  133. geometries: Geometry[];
  134. /**
  135. * TransformNodes populated in the container.
  136. */
  137. transformNodes: TransformNode[];
  138. /**
  139. * LensFlareSystems populated in the container.
  140. */
  141. lensFlareSystems: LensFlareSystem[];
  142. /**
  143. * ShadowGenerators populated in the container.
  144. */
  145. shadowGenerators: ShadowGenerator[];
  146. /**
  147. * ActionManagers populated in the container.
  148. */
  149. actionManagers: ActionManager[];
  150. /**
  151. * Sounds populated in the container.
  152. */
  153. sounds: Sound[];
  154. /**
  155. * Textures populated in the container.
  156. */
  157. textures: Texture[];
  158. /**
  159. * Effect layers populated in the container.
  160. */
  161. effectLayers: EffectLayer[];
  162. /**
  163. * Instantiates an AssetContainer.
  164. * @param scene The scene the AssetContainer belongs to.
  165. */
  166. constructor(scene: Scene);
  167. /**
  168. * Adds all the assets from the container to the scene.
  169. */
  170. addAllToScene(): void;
  171. /**
  172. * Removes all the assets in the container from the scene
  173. */
  174. removeAllFromScene(): void;
  175. private _moveAssets<T>(sourceAssets, targetAssets, keepAssets);
  176. /**
  177. * Removes all the assets contained in the scene and adds them to the container.
  178. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  179. */
  180. moveAllFromScene(keepAssets?: KeepAssets): void;
  181. /**
  182. * Adds all meshes in the asset container to a root mesh that can be used to position all the contained meshes. The root mesh is then added to the front of the meshes in the assetContainer.
  183. * @returns the root mesh
  184. */
  185. createRootMesh(): Mesh;
  186. }
  187. }
  188. interface Window {
  189. mozIndexedDB: IDBFactory;
  190. webkitIndexedDB: IDBFactory;
  191. msIndexedDB: IDBFactory;
  192. webkitURL: typeof URL;
  193. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  194. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  195. WebGLRenderingContext: WebGLRenderingContext;
  196. MSGesture: MSGesture;
  197. CANNON: any;
  198. AudioContext: AudioContext;
  199. webkitAudioContext: AudioContext;
  200. PointerEvent: any;
  201. Math: Math;
  202. Uint8Array: Uint8ArrayConstructor;
  203. Float32Array: Float32ArrayConstructor;
  204. mozURL: typeof URL;
  205. msURL: typeof URL;
  206. VRFrameData: any;
  207. DracoDecoderModule: any;
  208. }
  209. interface WebGLRenderingContext {
  210. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  211. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  212. vertexAttribDivisor(index: number, divisor: number): void;
  213. createVertexArray(): any;
  214. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  215. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  216. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  217. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  218. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  219. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  220. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  221. createQuery(): WebGLQuery;
  222. deleteQuery(query: WebGLQuery): void;
  223. beginQuery(target: number, query: WebGLQuery): void;
  224. endQuery(target: number): void;
  225. getQueryParameter(query: WebGLQuery, pname: number): any;
  226. getQuery(target: number, pname: number): any;
  227. MAX_SAMPLES: number;
  228. RGBA8: number;
  229. READ_FRAMEBUFFER: number;
  230. DRAW_FRAMEBUFFER: number;
  231. UNIFORM_BUFFER: number;
  232. HALF_FLOAT_OES: number;
  233. RGBA16F: number;
  234. RGBA32F: number;
  235. R32F: number;
  236. RG32F: number;
  237. RGB32F: number;
  238. RED: number;
  239. RG: number;
  240. UNSIGNED_INT_24_8: number;
  241. DEPTH24_STENCIL8: number;
  242. drawBuffers(buffers: number[]): void;
  243. readBuffer(src: number): void;
  244. readonly COLOR_ATTACHMENT0: number;
  245. readonly COLOR_ATTACHMENT1: number;
  246. readonly COLOR_ATTACHMENT2: number;
  247. readonly COLOR_ATTACHMENT3: number;
  248. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  249. ANY_SAMPLES_PASSED: number;
  250. QUERY_RESULT_AVAILABLE: number;
  251. QUERY_RESULT: number;
  252. }
  253. interface Document {
  254. mozCancelFullScreen(): void;
  255. msCancelFullScreen(): void;
  256. mozFullScreen: boolean;
  257. msIsFullScreen: boolean;
  258. fullscreen: boolean;
  259. mozPointerLockElement: HTMLElement;
  260. msPointerLockElement: HTMLElement;
  261. webkitPointerLockElement: HTMLElement;
  262. }
  263. interface HTMLCanvasElement {
  264. msRequestPointerLock?(): void;
  265. mozRequestPointerLock?(): void;
  266. webkitRequestPointerLock?(): void;
  267. }
  268. interface CanvasRenderingContext2D {
  269. msImageSmoothingEnabled: boolean;
  270. }
  271. interface WebGLBuffer {
  272. references: number;
  273. capacity: number;
  274. is32Bits: boolean;
  275. }
  276. interface WebGLProgram {
  277. transformFeedback?: WebGLTransformFeedback | null;
  278. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  279. }
  280. interface MouseEvent {
  281. mozMovementX: number;
  282. mozMovementY: number;
  283. webkitMovementX: number;
  284. webkitMovementY: number;
  285. msMovementX: number;
  286. msMovementY: number;
  287. }
  288. interface Navigator {
  289. mozGetVRDevices: (any: any) => any;
  290. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  291. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  292. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  293. webkitGetGamepads(): Gamepad[];
  294. msGetGamepads(): Gamepad[];
  295. webkitGamepads(): Gamepad[];
  296. }
  297. interface HTMLVideoElement {
  298. mozSrcObject: any;
  299. }
  300. interface Screen {
  301. orientation: string;
  302. mozOrientation: string;
  303. }
  304. interface Math {
  305. fround(x: number): number;
  306. imul(a: number, b: number): number;
  307. }
  308. interface EXT_disjoint_timer_query {
  309. QUERY_COUNTER_BITS_EXT: number;
  310. TIME_ELAPSED_EXT: number;
  311. TIMESTAMP_EXT: number;
  312. GPU_DISJOINT_EXT: number;
  313. QUERY_RESULT_EXT: number;
  314. QUERY_RESULT_AVAILABLE_EXT: number;
  315. queryCounterEXT(query: WebGLQuery, target: number): void;
  316. createQueryEXT(): WebGLQuery;
  317. beginQueryEXT(target: number, query: WebGLQuery): void;
  318. endQueryEXT(target: number): void;
  319. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  320. deleteQueryEXT(query: WebGLQuery): void;
  321. }
  322. interface WebGLUniformLocation {
  323. _currentState: any;
  324. }
  325. declare module BABYLON {
  326. /**
  327. * Node is the basic class for all scene objects (Mesh, Light Camera).
  328. */
  329. class Node implements IBehaviorAware<Node> {
  330. /**
  331. * Gets or sets the name of the node
  332. */
  333. name: string;
  334. /**
  335. * Gets or sets the id of the node
  336. */
  337. id: string;
  338. /**
  339. * Gets or sets the unique id of the node
  340. */
  341. uniqueId: number;
  342. /**
  343. * Gets or sets a string used to store user defined state for the node
  344. */
  345. state: string;
  346. /**
  347. * Gets or sets an object used to store user defined information for the node
  348. */
  349. metadata: any;
  350. /**
  351. * Gets or sets a boolean used to define if the node must be serialized
  352. */
  353. doNotSerialize: boolean;
  354. /** @hidden */
  355. _isDisposed: boolean;
  356. /**
  357. * Gets a list of Animations associated with the node
  358. */
  359. animations: Animation[];
  360. private _ranges;
  361. /**
  362. * Callback raised when the node is ready to be used
  363. */
  364. onReady: (node: Node) => void;
  365. private _isEnabled;
  366. private _isReady;
  367. /** @hidden */
  368. _currentRenderId: number;
  369. private _parentRenderId;
  370. protected _childRenderId: number;
  371. /** @hidden */
  372. _waitingParentId: Nullable<string>;
  373. private _scene;
  374. /** @hidden */
  375. _cache: any;
  376. private _parentNode;
  377. private _children;
  378. /**
  379. * Gets a boolean indicating if the node has been disposed
  380. * @returns true if the node was disposed
  381. */
  382. isDisposed(): boolean;
  383. /**
  384. * Gets or sets the parent of the node
  385. */
  386. parent: Nullable<Node>;
  387. private _animationPropertiesOverride;
  388. /**
  389. * Gets or sets the animation properties override
  390. */
  391. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  392. /**
  393. * Gets a string idenfifying the name of the class
  394. * @returns "Node" string
  395. */
  396. getClassName(): string;
  397. /**
  398. * An event triggered when the mesh is disposed
  399. */
  400. onDisposeObservable: Observable<Node>;
  401. private _onDisposeObserver;
  402. /**
  403. * Sets a callback that will be raised when the node will be disposed
  404. */
  405. onDispose: () => void;
  406. /**
  407. * Creates a new Node
  408. * @param {string} name - the name and id to be given to this node
  409. * @param {BABYLON.Scene} the scene this node will be added to
  410. */
  411. constructor(name: string, scene?: Nullable<Scene>);
  412. /**
  413. * Gets the scene of the node
  414. * @returns a {BABYLON.Scene}
  415. */
  416. getScene(): Scene;
  417. /**
  418. * Gets the engine of the node
  419. * @returns a {BABYLON.Engine}
  420. */
  421. getEngine(): Engine;
  422. private _behaviors;
  423. /**
  424. * Attach a behavior to the node
  425. * @see http://doc.babylonjs.com/features/behaviour
  426. * @param behavior defines the behavior to attach
  427. * @returns the current Node
  428. */
  429. addBehavior(behavior: Behavior<Node>): Node;
  430. /**
  431. * Remove an attached behavior
  432. * @see http://doc.babylonjs.com/features/behaviour
  433. * @param behavior defines the behavior to attach
  434. * @returns the current Node
  435. */
  436. removeBehavior(behavior: Behavior<Node>): Node;
  437. /**
  438. * Gets the list of attached behaviors
  439. * @see http://doc.babylonjs.com/features/behaviour
  440. */
  441. readonly behaviors: Behavior<Node>[];
  442. /**
  443. * Gets an attached behavior by name
  444. * @param name defines the name of the behavior to look for
  445. * @see http://doc.babylonjs.com/features/behaviour
  446. * @returns null if behavior was not found else the requested behavior
  447. */
  448. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  449. /**
  450. * Returns the world matrix of the node
  451. * @returns a matrix containing the node's world matrix
  452. */
  453. getWorldMatrix(): Matrix;
  454. /** @hidden */
  455. _getWorldMatrixDeterminant(): number;
  456. /** @hidden */
  457. _initCache(): void;
  458. /** @hidden */
  459. updateCache(force?: boolean): void;
  460. /** @hidden */
  461. _updateCache(ignoreParentClass?: boolean): void;
  462. /** @hidden */
  463. _isSynchronized(): boolean;
  464. /** @hidden */
  465. _markSyncedWithParent(): void;
  466. /** @hidden */
  467. isSynchronizedWithParent(): boolean;
  468. /** @hidden */
  469. isSynchronized(updateCache?: boolean): boolean;
  470. /** @hidden */
  471. hasNewParent(update?: boolean): boolean;
  472. /**
  473. * Is this node ready to be used/rendered
  474. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  475. * @return true if the node is ready
  476. */
  477. isReady(completeCheck?: boolean): boolean;
  478. /**
  479. * Is this node enabled?
  480. * If the node has a parent, all ancestors will be checked and false will be returned if any are false (not enabled), otherwise will return true
  481. * @param checkAncestors indicates if this method should check the ancestors. The default is to check the ancestors. If set to false, the method will return the value of this node without checking ancestors
  482. * @return whether this node (and its parent) is enabled
  483. */
  484. isEnabled(checkAncestors?: boolean): boolean;
  485. /**
  486. * Set the enabled state of this node
  487. * @param value defines the new enabled state
  488. */
  489. setEnabled(value: boolean): void;
  490. /**
  491. * Is this node a descendant of the given node?
  492. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  493. * @param ancestor defines the parent node to inspect
  494. * @returns a boolean indicating if this node is a descendant of the given node
  495. */
  496. isDescendantOf(ancestor: Node): boolean;
  497. /** @hidden */
  498. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  499. /**
  500. * Will return all nodes that have this node as ascendant
  501. * @param directDescendantsOnly defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered
  502. * @param predicate defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored
  503. * @return all children nodes of all types
  504. */
  505. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  506. /**
  507. * Get all child-meshes of this node
  508. * @param directDescendantsOnly defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered
  509. * @param predicate defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored
  510. * @returns an array of {BABYLON.AbstractMesh}
  511. */
  512. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  513. /**
  514. * Get all child-transformNodes of this node
  515. * @param directDescendantsOnly defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered
  516. * @param predicate defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored
  517. * @returns an array of {BABYLON.TransformNode}
  518. */
  519. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  520. /**
  521. * Get all direct children of this node
  522. * @param predicate defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored
  523. * @returns an array of {BABYLON.Node}
  524. */
  525. getChildren(predicate?: (node: Node) => boolean): Node[];
  526. /** @hidden */
  527. _setReady(state: boolean): void;
  528. /**
  529. * Get an animation by name
  530. * @param name defines the name of the animation to look for
  531. * @returns null if not found else the requested animation
  532. */
  533. getAnimationByName(name: string): Nullable<Animation>;
  534. /**
  535. * Creates an animation range for this node
  536. * @param name defines the name of the range
  537. * @param from defines the starting key
  538. * @param to defines the end key
  539. */
  540. createAnimationRange(name: string, from: number, to: number): void;
  541. /**
  542. * Delete a specific animation range
  543. * @param name defines the name of the range to delete
  544. * @param deleteFrames defines if animation frames from the range must be deleted as well
  545. */
  546. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  547. /**
  548. * Get an animation range by name
  549. * @param name defines the name of the animation range to look for
  550. * @returns null if not found else the requested animation range
  551. */
  552. getAnimationRange(name: string): Nullable<AnimationRange>;
  553. /**
  554. * Will start the animation sequence
  555. * @param name defines the range frames for animation sequence
  556. * @param loop defines if the animation should loop (false by default)
  557. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  558. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  559. * @returns the object created for this animation. If range does not exist, it will return null
  560. */
  561. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  562. /**
  563. * Serialize animation ranges into a JSON compatible object
  564. * @returns serialization object
  565. */
  566. serializeAnimationRanges(): any;
  567. /**
  568. * Computes the world matrix of the node
  569. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  570. * @returns the world matrix
  571. */
  572. computeWorldMatrix(force?: boolean): Matrix;
  573. /**
  574. * Releases resources associated with this node.
  575. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  576. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  577. */
  578. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  579. /**
  580. * Parse animation range data from a serialization object and store them into a given node
  581. * @param node defines where to store the animation ranges
  582. * @param parsedNode defines the serialization object to read data from
  583. * @param scene defines the hosting scene
  584. */
  585. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  586. }
  587. }
  588. declare module BABYLON {
  589. /**
  590. * Define an interface for all classes that will hold resources
  591. */
  592. interface IDisposable {
  593. /**
  594. * Releases all held resources
  595. */
  596. dispose(): void;
  597. }
  598. /**
  599. * Interface used to let developers provide their own mesh selection mechanism
  600. */
  601. interface IActiveMeshCandidateProvider {
  602. /**
  603. * Return the list of active meshes
  604. * @param scene defines the current scene
  605. * @returns the list of active meshes
  606. */
  607. getMeshes(scene: Scene): AbstractMesh[];
  608. /**
  609. * Indicates if the meshes have been checked to make sure they are isEnabled()
  610. */
  611. readonly checksIsEnabled: boolean;
  612. }
  613. /**
  614. * This class is used by the onRenderingGroupObservable
  615. */
  616. class RenderingGroupInfo {
  617. /**
  618. * The Scene that being rendered
  619. */
  620. scene: Scene;
  621. /**
  622. * The camera currently used for the rendering pass
  623. */
  624. camera: Nullable<Camera>;
  625. /**
  626. * The ID of the renderingGroup being processed
  627. */
  628. renderingGroupId: number;
  629. /**
  630. * The rendering stage, can be either STAGE_PRECLEAR, STAGE_PREOPAQUE, STAGE_PRETRANSPARENT, STAGE_POSTTRANSPARENT
  631. */
  632. renderStage: number;
  633. /**
  634. * Stage corresponding to the very first hook in the renderingGroup phase: before the render buffer may be cleared
  635. * This stage will be fired no matter what
  636. */
  637. static STAGE_PRECLEAR: number;
  638. /**
  639. * Called before opaque object are rendered.
  640. * This stage will be fired only if there's 3D Opaque content to render
  641. */
  642. static STAGE_PREOPAQUE: number;
  643. /**
  644. * Called after the opaque objects are rendered and before the transparent ones
  645. * This stage will be fired only if there's 3D transparent content to render
  646. */
  647. static STAGE_PRETRANSPARENT: number;
  648. /**
  649. * Called after the transparent object are rendered, last hook of the renderingGroup phase
  650. * This stage will be fired no matter what
  651. */
  652. static STAGE_POSTTRANSPARENT: number;
  653. }
  654. /**
  655. * Represents a scene to be rendered by the engine.
  656. * @see http://doc.babylonjs.com/features/scene
  657. */
  658. class Scene implements IAnimatable {
  659. private static _FOGMODE_NONE;
  660. private static _FOGMODE_EXP;
  661. private static _FOGMODE_EXP2;
  662. private static _FOGMODE_LINEAR;
  663. private static _uniqueIdCounter;
  664. /**
  665. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  666. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  667. */
  668. static MinDeltaTime: number;
  669. /**
  670. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  671. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  672. */
  673. static MaxDeltaTime: number;
  674. /** The fog is deactivated */
  675. static readonly FOGMODE_NONE: number;
  676. /** The fog density is following an exponential function */
  677. static readonly FOGMODE_EXP: number;
  678. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  679. static readonly FOGMODE_EXP2: number;
  680. /** The fog density is following a linear function. */
  681. static readonly FOGMODE_LINEAR: number;
  682. /**
  683. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  684. */
  685. autoClear: boolean;
  686. /**
  687. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  688. */
  689. autoClearDepthAndStencil: boolean;
  690. /**
  691. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  692. */
  693. clearColor: Color4;
  694. /**
  695. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  696. */
  697. ambientColor: Color3;
  698. /** @hidden */
  699. _environmentBRDFTexture: BaseTexture;
  700. /** @hidden */
  701. protected _environmentTexture: BaseTexture;
  702. /**
  703. * Texture used in all pbr material as the reflection texture.
  704. * As in the majority of the scene they are the same (exception for multi room and so on),
  705. * this is easier to reference from here than from all the materials.
  706. */
  707. /**
  708. * Texture used in all pbr material as the reflection texture.
  709. * As in the majority of the scene they are the same (exception for multi room and so on),
  710. * this is easier to set here than in all the materials.
  711. */
  712. environmentTexture: BaseTexture;
  713. /** @hidden */
  714. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  715. /**
  716. * Default image processing configuration used either in the rendering
  717. * Forward main pass or through the imageProcessingPostProcess if present.
  718. * As in the majority of the scene they are the same (exception for multi camera),
  719. * this is easier to reference from here than from all the materials and post process.
  720. *
  721. * No setter as we it is a shared configuration, you can set the values instead.
  722. */
  723. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  724. private _forceWireframe;
  725. /**
  726. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  727. */
  728. forceWireframe: boolean;
  729. private _forcePointsCloud;
  730. /**
  731. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  732. */
  733. forcePointsCloud: boolean;
  734. /**
  735. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  736. */
  737. forceShowBoundingBoxes: boolean;
  738. /**
  739. * Gets or sets the active clipplane
  740. */
  741. clipPlane: Nullable<Plane>;
  742. /**
  743. * Gets or sets a boolean indicating if animations are enabled
  744. */
  745. animationsEnabled: boolean;
  746. private _animationPropertiesOverride;
  747. /**
  748. * Gets or sets the animation properties override
  749. */
  750. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  751. /**
  752. * Gets or sets a boolean indicating if a constant deltatime has to be used
  753. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  754. */
  755. useConstantAnimationDeltaTime: boolean;
  756. /**
  757. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  758. * Please note that it requires to run a ray cast through the scene on every frame
  759. */
  760. constantlyUpdateMeshUnderPointer: boolean;
  761. /**
  762. * Defines the HTML cursor to use when hovering over interactive elements
  763. */
  764. hoverCursor: string;
  765. /**
  766. * Defines the HTML default cursor to use (empty by default)
  767. */
  768. defaultCursor: string;
  769. /**
  770. * This is used to call preventDefault() on pointer down
  771. * in order to block unwanted artifacts like system double clicks
  772. */
  773. preventDefaultOnPointerDown: boolean;
  774. /**
  775. * Gets or sets user defined metadata
  776. */
  777. metadata: any;
  778. /**
  779. * Gets the name of the plugin used to load this scene (null by default)
  780. */
  781. loadingPluginName: string;
  782. /**
  783. * Use this array to add regular expressions used to disable offline support for specific urls
  784. */
  785. disableOfflineSupportExceptionRules: RegExp[];
  786. private _spritePredicate;
  787. /**
  788. * An event triggered when the scene is disposed.
  789. */
  790. onDisposeObservable: Observable<Scene>;
  791. private _onDisposeObserver;
  792. /** Sets a function to be executed when this scene is disposed. */
  793. onDispose: () => void;
  794. /**
  795. * An event triggered before rendering the scene (right after animations and physics)
  796. */
  797. onBeforeRenderObservable: Observable<Scene>;
  798. private _onBeforeRenderObserver;
  799. /** Sets a function to be executed before rendering this scene */
  800. beforeRender: Nullable<() => void>;
  801. /**
  802. * An event triggered after rendering the scene
  803. */
  804. onAfterRenderObservable: Observable<Scene>;
  805. private _onAfterRenderObserver;
  806. /** Sets a function to be executed after rendering this scene */
  807. afterRender: Nullable<() => void>;
  808. /**
  809. * An event triggered before animating the scene
  810. */
  811. onBeforeAnimationsObservable: Observable<Scene>;
  812. /**
  813. * An event triggered after animations processing
  814. */
  815. onAfterAnimationsObservable: Observable<Scene>;
  816. /**
  817. * An event triggered before draw calls are ready to be sent
  818. */
  819. onBeforeDrawPhaseObservable: Observable<Scene>;
  820. /**
  821. * An event triggered after draw calls have been sent
  822. */
  823. onAfterDrawPhaseObservable: Observable<Scene>;
  824. /**
  825. * An event triggered when physic simulation is about to be run
  826. */
  827. onBeforePhysicsObservable: Observable<Scene>;
  828. /**
  829. * An event triggered when physic simulation has been done
  830. */
  831. onAfterPhysicsObservable: Observable<Scene>;
  832. /**
  833. * An event triggered when the scene is ready
  834. */
  835. onReadyObservable: Observable<Scene>;
  836. /**
  837. * An event triggered before rendering a camera
  838. */
  839. onBeforeCameraRenderObservable: Observable<Camera>;
  840. private _onBeforeCameraRenderObserver;
  841. /** Sets a function to be executed before rendering a camera*/
  842. beforeCameraRender: () => void;
  843. /**
  844. * An event triggered after rendering a camera
  845. */
  846. onAfterCameraRenderObservable: Observable<Camera>;
  847. private _onAfterCameraRenderObserver;
  848. /** Sets a function to be executed after rendering a camera*/
  849. afterCameraRender: () => void;
  850. /**
  851. * An event triggered when active meshes evaluation is about to start
  852. */
  853. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  854. /**
  855. * An event triggered when active meshes evaluation is done
  856. */
  857. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  858. /**
  859. * An event triggered when particles rendering is about to start
  860. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  861. */
  862. onBeforeParticlesRenderingObservable: Observable<Scene>;
  863. /**
  864. * An event triggered when particles rendering is done
  865. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  866. */
  867. onAfterParticlesRenderingObservable: Observable<Scene>;
  868. /**
  869. * An event triggered when sprites rendering is about to start
  870. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  871. */
  872. onBeforeSpritesRenderingObservable: Observable<Scene>;
  873. /**
  874. * An event triggered when sprites rendering is done
  875. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  876. */
  877. onAfterSpritesRenderingObservable: Observable<Scene>;
  878. /**
  879. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  880. */
  881. onDataLoadedObservable: Observable<Scene>;
  882. /**
  883. * An event triggered when a camera is created
  884. */
  885. onNewCameraAddedObservable: Observable<Camera>;
  886. /**
  887. * An event triggered when a camera is removed
  888. */
  889. onCameraRemovedObservable: Observable<Camera>;
  890. /**
  891. * An event triggered when a light is created
  892. */
  893. onNewLightAddedObservable: Observable<Light>;
  894. /**
  895. * An event triggered when a light is removed
  896. */
  897. onLightRemovedObservable: Observable<Light>;
  898. /**
  899. * An event triggered when a geometry is created
  900. */
  901. onNewGeometryAddedObservable: Observable<Geometry>;
  902. /**
  903. * An event triggered when a geometry is removed
  904. */
  905. onGeometryRemovedObservable: Observable<Geometry>;
  906. /**
  907. * An event triggered when a transform node is created
  908. */
  909. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  910. /**
  911. * An event triggered when a transform node is removed
  912. */
  913. onTransformNodeRemovedObservable: Observable<TransformNode>;
  914. /**
  915. * An event triggered when a mesh is created
  916. */
  917. onNewMeshAddedObservable: Observable<AbstractMesh>;
  918. /**
  919. * An event triggered when a mesh is removed
  920. */
  921. onMeshRemovedObservable: Observable<AbstractMesh>;
  922. /**
  923. * An event triggered when render targets are about to be rendered
  924. * Can happen multiple times per frame.
  925. */
  926. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  927. /**
  928. * An event triggered when render targets were rendered.
  929. * Can happen multiple times per frame.
  930. */
  931. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  932. /**
  933. * An event triggered before calculating deterministic simulation step
  934. */
  935. onBeforeStepObservable: Observable<Scene>;
  936. /**
  937. * An event triggered after calculating deterministic simulation step
  938. */
  939. onAfterStepObservable: Observable<Scene>;
  940. /**
  941. * This Observable will be triggered for each stage of each renderingGroup of each rendered camera.
  942. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  943. * If you wish to register an Observer only for a given set of renderingGroup, use the mask with a combination of the renderingGroup index elevated to the power of two (1 for renderingGroup 0, 2 for renderingrOup1, 4 for 2 and 8 for 3)
  944. */
  945. onRenderingGroupObservable: Observable<RenderingGroupInfo>;
  946. /**
  947. * Gets a list of Animations associated with the scene
  948. */
  949. animations: Animation[];
  950. private _registeredForLateAnimationBindings;
  951. /**
  952. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  953. */
  954. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  955. /**
  956. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  957. */
  958. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  959. /**
  960. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  961. */
  962. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  963. private _onPointerMove;
  964. private _onPointerDown;
  965. private _onPointerUp;
  966. /** Deprecated. Use onPointerObservable instead */
  967. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  968. /** Deprecated. Use onPointerObservable instead */
  969. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  970. /** Deprecated. Use onPointerObservable instead */
  971. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  972. /** Deprecated. Use onPointerObservable instead */
  973. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  974. private _gamepadManager;
  975. /**
  976. * Gets the gamepad manager associated with the scene
  977. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  978. */
  979. readonly gamepadManager: GamepadManager;
  980. /**
  981. * This observable event is triggered when any ponter event is triggered. It is registered during Scene.attachControl() and it is called BEFORE the 3D engine process anything (mesh/sprite picking for instance).
  982. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  983. */
  984. onPrePointerObservable: Observable<PointerInfoPre>;
  985. /**
  986. * Observable event triggered each time an input event is received from the rendering canvas
  987. */
  988. onPointerObservable: Observable<PointerInfo>;
  989. /**
  990. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  991. */
  992. readonly unTranslatedPointer: Vector2;
  993. /** The distance in pixel that you have to move to prevent some events */
  994. static DragMovementThreshold: number;
  995. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  996. static LongPressDelay: number;
  997. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  998. static DoubleClickDelay: number;
  999. /** If you need to check double click without raising a single click at first click, enable this flag */
  1000. static ExclusiveDoubleClickMode: boolean;
  1001. private _initClickEvent;
  1002. private _initActionManager;
  1003. private _delayedSimpleClick;
  1004. private _delayedSimpleClickTimeout;
  1005. private _previousDelayedSimpleClickTimeout;
  1006. private _meshPickProceed;
  1007. private _previousButtonPressed;
  1008. private _currentPickResult;
  1009. private _previousPickResult;
  1010. private _totalPointersPressed;
  1011. private _doubleClickOccured;
  1012. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  1013. cameraToUseForPointers: Nullable<Camera>;
  1014. private _pointerX;
  1015. private _pointerY;
  1016. private _unTranslatedPointerX;
  1017. private _unTranslatedPointerY;
  1018. private _startingPointerPosition;
  1019. private _previousStartingPointerPosition;
  1020. private _startingPointerTime;
  1021. private _previousStartingPointerTime;
  1022. private _pointerCaptures;
  1023. private _timeAccumulator;
  1024. private _currentStepId;
  1025. private _currentInternalStep;
  1026. /** @hidden */
  1027. _mirroredCameraPosition: Nullable<Vector3>;
  1028. /**
  1029. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  1030. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  1031. */
  1032. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  1033. /**
  1034. * Observable event triggered each time an keyboard event is received from the hosting window
  1035. */
  1036. onKeyboardObservable: Observable<KeyboardInfo>;
  1037. private _onKeyDown;
  1038. private _onKeyUp;
  1039. private _onCanvasFocusObserver;
  1040. private _onCanvasBlurObserver;
  1041. private _useRightHandedSystem;
  1042. /**
  1043. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  1044. */
  1045. useRightHandedSystem: boolean;
  1046. /**
  1047. * Sets the step Id used by deterministic lock step
  1048. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  1049. * @param newStepId defines the step Id
  1050. */
  1051. setStepId(newStepId: number): void;
  1052. /**
  1053. * Gets the step Id used by deterministic lock step
  1054. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  1055. * @returns the step Id
  1056. */
  1057. getStepId(): number;
  1058. /**
  1059. * Gets the internal step used by deterministic lock step
  1060. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  1061. * @returns the internal step
  1062. */
  1063. getInternalStep(): number;
  1064. private _fogEnabled;
  1065. /**
  1066. * Gets or sets a boolean indicating if fog is enabled on this scene
  1067. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1068. */
  1069. fogEnabled: boolean;
  1070. private _fogMode;
  1071. /**
  1072. * Gets or sets the fog mode to use
  1073. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1074. */
  1075. fogMode: number;
  1076. /**
  1077. * Gets or sets the fog color to use
  1078. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1079. */
  1080. fogColor: Color3;
  1081. /**
  1082. * Gets or sets the fog density to use
  1083. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1084. */
  1085. fogDensity: number;
  1086. /**
  1087. * Gets or sets the fog start distance to use
  1088. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1089. */
  1090. fogStart: number;
  1091. /**
  1092. * Gets or sets the fog end distance to use
  1093. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1094. */
  1095. fogEnd: number;
  1096. private _shadowsEnabled;
  1097. /**
  1098. * Gets or sets a boolean indicating if shadows are enabled on this scene
  1099. */
  1100. shadowsEnabled: boolean;
  1101. private _lightsEnabled;
  1102. /**
  1103. * Gets or sets a boolean indicating if lights are enabled on this scene
  1104. */
  1105. lightsEnabled: boolean;
  1106. /**
  1107. * All of the lights added to this scene
  1108. * @see http://doc.babylonjs.com/babylon101/lights
  1109. */
  1110. lights: Light[];
  1111. /** All of the cameras added to this scene.
  1112. * @see http://doc.babylonjs.com/babylon101/cameras
  1113. */
  1114. cameras: Camera[];
  1115. /** All of the active cameras added to this scene. */
  1116. activeCameras: Camera[];
  1117. /** The current active camera */
  1118. activeCamera: Nullable<Camera>;
  1119. /**
  1120. * All of the tranform nodes added to this scene
  1121. * @see http://doc.babylonjs.com/how_to/transformnode
  1122. */
  1123. transformNodes: TransformNode[];
  1124. /**
  1125. * All of the (abstract) meshes added to this scene
  1126. */
  1127. meshes: AbstractMesh[];
  1128. /**
  1129. * All of the animation groups added to this scene
  1130. * @see http://doc.babylonjs.com/how_to/group
  1131. */
  1132. animationGroups: AnimationGroup[];
  1133. private _geometries;
  1134. /**
  1135. * All of the materials added to this scene
  1136. * @see http://doc.babylonjs.com/babylon101/materials
  1137. */
  1138. materials: Material[];
  1139. /**
  1140. * All of the multi-materials added to this scene
  1141. * @see http://doc.babylonjs.com/how_to/multi_materials
  1142. */
  1143. multiMaterials: MultiMaterial[];
  1144. private _defaultMaterial;
  1145. /** The default material used on meshes when no material is affected */
  1146. /** The default material used on meshes when no material is affected */
  1147. defaultMaterial: Material;
  1148. private _texturesEnabled;
  1149. /**
  1150. * Gets or sets a boolean indicating if textures are enabled on this scene
  1151. */
  1152. texturesEnabled: boolean;
  1153. /**
  1154. * All of the textures added to this scene
  1155. */
  1156. textures: BaseTexture[];
  1157. /**
  1158. * Gets or sets a boolean indicating if particles are enabled on this scene
  1159. */
  1160. particlesEnabled: boolean;
  1161. /**
  1162. * All of the particle systems added to this scene
  1163. * @see http://doc.babylonjs.com/babylon101/particles
  1164. */
  1165. particleSystems: IParticleSystem[];
  1166. /**
  1167. * Gets or sets a boolean indicating if sprites are enabled on this scene
  1168. */
  1169. spritesEnabled: boolean;
  1170. /**
  1171. * All of the sprite managers added to this scene
  1172. * @see http://doc.babylonjs.com/babylon101/sprites
  1173. */
  1174. spriteManagers: SpriteManager[];
  1175. /**
  1176. * The list of layers (background and foreground) of the scene
  1177. */
  1178. layers: Layer[];
  1179. /**
  1180. * The list of effect layers (highlights/glow) added to the scene
  1181. * @see http://doc.babylonjs.com/how_to/highlight_layer
  1182. * @see http://doc.babylonjs.com/how_to/glow_layer
  1183. */
  1184. effectLayers: EffectLayer[];
  1185. private _skeletonsEnabled;
  1186. /**
  1187. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  1188. */
  1189. skeletonsEnabled: boolean;
  1190. /**
  1191. * The list of skeletons added to the scene
  1192. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  1193. */
  1194. skeletons: Skeleton[];
  1195. /**
  1196. * The list of morph target managers added to the scene
  1197. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  1198. */
  1199. morphTargetManagers: MorphTargetManager[];
  1200. /**
  1201. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  1202. */
  1203. lensFlaresEnabled: boolean;
  1204. /**
  1205. * The list of lens flare system added to the scene
  1206. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  1207. */
  1208. lensFlareSystems: LensFlareSystem[];
  1209. /**
  1210. * Gets or sets a boolean indicating if collisions are enabled on this scene
  1211. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  1212. */
  1213. collisionsEnabled: boolean;
  1214. private _workerCollisions;
  1215. /** @hidden */
  1216. collisionCoordinator: ICollisionCoordinator;
  1217. /**
  1218. * Defines the gravity applied to this scene (used only for collisions)
  1219. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  1220. */
  1221. gravity: Vector3;
  1222. /**
  1223. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  1224. */
  1225. postProcessesEnabled: boolean;
  1226. /**
  1227. * The list of postprocesses added to the scene
  1228. */
  1229. postProcesses: PostProcess[];
  1230. /**
  1231. * Gets the current postprocess manager
  1232. */
  1233. postProcessManager: PostProcessManager;
  1234. private _postProcessRenderPipelineManager;
  1235. /**
  1236. * Gets the postprocess render pipeline manager
  1237. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  1238. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  1239. */
  1240. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  1241. /**
  1242. * Gets or sets a boolean indicating if render targets are enabled on this scene
  1243. */
  1244. renderTargetsEnabled: boolean;
  1245. /**
  1246. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  1247. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  1248. */
  1249. dumpNextRenderTargets: boolean;
  1250. /**
  1251. * The list of user defined render targets added to the scene
  1252. */
  1253. customRenderTargets: RenderTargetTexture[];
  1254. /**
  1255. * Defines if texture loading must be delayed
  1256. * If true, textures will only be loaded when they need to be rendered
  1257. */
  1258. useDelayedTextureLoading: boolean;
  1259. /**
  1260. * Gets the list of meshes imported to the scene through SceneLoader
  1261. */
  1262. importedMeshesFiles: String[];
  1263. /**
  1264. * Gets or sets a boolean indicating if probes are enabled on this scene
  1265. */
  1266. probesEnabled: boolean;
  1267. /**
  1268. * The list of reflection probes added to the scene
  1269. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  1270. */
  1271. reflectionProbes: ReflectionProbe[];
  1272. /**
  1273. * @hidden
  1274. */
  1275. database: Database;
  1276. /**
  1277. * Gets or sets the action manager associated with the scene
  1278. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  1279. */
  1280. actionManager: ActionManager;
  1281. /** @hidden */
  1282. _actionManagers: ActionManager[];
  1283. private _meshesForIntersections;
  1284. /**
  1285. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  1286. */
  1287. proceduralTexturesEnabled: boolean;
  1288. /**
  1289. * The list of procedural textures added to the scene
  1290. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  1291. */
  1292. proceduralTextures: ProceduralTexture[];
  1293. private _mainSoundTrack;
  1294. /**
  1295. * The list of sound tracks added to the scene
  1296. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  1297. */
  1298. soundTracks: SoundTrack[];
  1299. private _audioEnabled;
  1300. private _headphone;
  1301. /**
  1302. * Gets the main soundtrack associated with the scene
  1303. */
  1304. readonly mainSoundTrack: SoundTrack;
  1305. /**
  1306. * Gets or sets the VRExperienceHelper attached to the scene
  1307. * @see http://doc.babylonjs.com/how_to/webvr_helper
  1308. * @ignorenaming
  1309. */
  1310. VRHelper: VRExperienceHelper;
  1311. /**
  1312. * Gets or sets the simplification queue attached to the scene
  1313. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  1314. */
  1315. simplificationQueue: SimplificationQueue;
  1316. private _engine;
  1317. private _totalVertices;
  1318. /** @hidden */
  1319. _activeIndices: PerfCounter;
  1320. /** @hidden */
  1321. _activeParticles: PerfCounter;
  1322. /** @hidden */
  1323. _activeBones: PerfCounter;
  1324. private _animationRatio;
  1325. private _animationTimeLast;
  1326. private _animationTime;
  1327. /**
  1328. * Gets or sets a general scale for animation speed
  1329. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  1330. */
  1331. animationTimeScale: number;
  1332. /** @hidden */
  1333. _cachedMaterial: Nullable<Material>;
  1334. /** @hidden */
  1335. _cachedEffect: Nullable<Effect>;
  1336. /** @hidden */
  1337. _cachedVisibility: Nullable<number>;
  1338. private _renderId;
  1339. private _executeWhenReadyTimeoutId;
  1340. private _intermediateRendering;
  1341. private _viewUpdateFlag;
  1342. private _projectionUpdateFlag;
  1343. private _alternateViewUpdateFlag;
  1344. private _alternateProjectionUpdateFlag;
  1345. /** @hidden */
  1346. _toBeDisposed: SmartArray<Nullable<IDisposable>>;
  1347. private _activeRequests;
  1348. private _pendingData;
  1349. private _isDisposed;
  1350. /**
  1351. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  1352. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  1353. */
  1354. dispatchAllSubMeshesOfActiveMeshes: boolean;
  1355. private _activeMeshes;
  1356. private _processedMaterials;
  1357. private _renderTargets;
  1358. /** @hidden */
  1359. _activeParticleSystems: SmartArray<IParticleSystem>;
  1360. private _activeSkeletons;
  1361. private _softwareSkinnedMeshes;
  1362. private _renderingManager;
  1363. private _physicsEngine;
  1364. /** @hidden */
  1365. _activeAnimatables: Animatable[];
  1366. private _transformMatrix;
  1367. private _sceneUbo;
  1368. private _alternateSceneUbo;
  1369. private _pickWithRayInverseMatrix;
  1370. private _boundingBoxRenderer;
  1371. private _outlineRenderer;
  1372. private _viewMatrix;
  1373. private _projectionMatrix;
  1374. private _alternateViewMatrix;
  1375. private _alternateProjectionMatrix;
  1376. private _alternateTransformMatrix;
  1377. private _useAlternateCameraConfiguration;
  1378. private _alternateRendering;
  1379. /** @hidden */
  1380. _forcedViewPosition: Nullable<Vector3>;
  1381. /** @hidden */
  1382. readonly _isAlternateRenderingEnabled: boolean;
  1383. private _frustumPlanes;
  1384. /**
  1385. * Gets the list of frustum planes (built from the active camera)
  1386. */
  1387. readonly frustumPlanes: Plane[];
  1388. /**
  1389. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  1390. * This is useful if there are more lights that the maximum simulteanous authorized
  1391. */
  1392. requireLightSorting: boolean;
  1393. private _selectionOctree;
  1394. private _pointerOverMesh;
  1395. private _pointerOverSprite;
  1396. private _debugLayer;
  1397. private _depthRenderer;
  1398. private _geometryBufferRenderer;
  1399. /**
  1400. * Gets the current geometry buffer associated to the scene.
  1401. */
  1402. /**
  1403. * Sets the current geometry buffer for the scene.
  1404. */
  1405. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  1406. private _pickedDownMesh;
  1407. private _pickedUpMesh;
  1408. private _pickedDownSprite;
  1409. private _externalData;
  1410. private _uid;
  1411. /**
  1412. * Creates a new Scene
  1413. * @param engine defines the engine to use to render this scene
  1414. */
  1415. constructor(engine: Engine);
  1416. /**
  1417. * Gets the debug layer associated with the scene
  1418. * @see http://doc.babylonjs.com/features/playground_debuglayer
  1419. */
  1420. readonly debugLayer: DebugLayer;
  1421. /**
  1422. * Gets a boolean indicating if collisions are processed on a web worker
  1423. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#web-worker-based-collision-system-since-21
  1424. */
  1425. workerCollisions: boolean;
  1426. /**
  1427. * Gets the octree used to boost mesh selection (picking)
  1428. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  1429. */
  1430. readonly selectionOctree: Octree<AbstractMesh>;
  1431. /**
  1432. * Gets the mesh that is currently under the pointer
  1433. */
  1434. readonly meshUnderPointer: Nullable<AbstractMesh>;
  1435. /**
  1436. * Gets the current on-screen X position of the pointer
  1437. */
  1438. readonly pointerX: number;
  1439. /**
  1440. * Gets the current on-screen Y position of the pointer
  1441. */
  1442. readonly pointerY: number;
  1443. /**
  1444. * Gets the cached material (ie. the latest rendered one)
  1445. * @returns the cached material
  1446. */
  1447. getCachedMaterial(): Nullable<Material>;
  1448. /**
  1449. * Gets the cached effect (ie. the latest rendered one)
  1450. * @returns the cached effect
  1451. */
  1452. getCachedEffect(): Nullable<Effect>;
  1453. /**
  1454. * Gets the cached visibility state (ie. the latest rendered one)
  1455. * @returns the cached visibility state
  1456. */
  1457. getCachedVisibility(): Nullable<number>;
  1458. /**
  1459. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  1460. * @param material defines the current material
  1461. * @param effect defines the current effect
  1462. * @param visibility defines the current visibility state
  1463. * @returns true if one parameter is not cached
  1464. */
  1465. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  1466. /**
  1467. * Gets the bounding box renderer associated with the scene
  1468. * @returns a BoundingBoxRenderer
  1469. */
  1470. getBoundingBoxRenderer(): BoundingBoxRenderer;
  1471. /**
  1472. * Gets the outline renderer associated with the scene
  1473. * @returns a OutlineRenderer
  1474. */
  1475. getOutlineRenderer(): OutlineRenderer;
  1476. /**
  1477. * Gets the engine associated with the scene
  1478. * @returns an Engine
  1479. */
  1480. getEngine(): Engine;
  1481. /**
  1482. * Gets the total number of vertices rendered per frame
  1483. * @returns the total number of vertices rendered per frame
  1484. */
  1485. getTotalVertices(): number;
  1486. /**
  1487. * Gets the performance counter for total vertices
  1488. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  1489. */
  1490. readonly totalVerticesPerfCounter: PerfCounter;
  1491. /**
  1492. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  1493. * @returns the total number of active indices rendered per frame
  1494. */
  1495. getActiveIndices(): number;
  1496. /**
  1497. * Gets the performance counter for active indices
  1498. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  1499. */
  1500. readonly totalActiveIndicesPerfCounter: PerfCounter;
  1501. /**
  1502. * Gets the total number of active particles rendered per frame
  1503. * @returns the total number of active particles rendered per frame
  1504. */
  1505. getActiveParticles(): number;
  1506. /**
  1507. * Gets the performance counter for active particles
  1508. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  1509. */
  1510. readonly activeParticlesPerfCounter: PerfCounter;
  1511. /**
  1512. * Gets the total number of active bones rendered per frame
  1513. * @returns the total number of active bones rendered per frame
  1514. */
  1515. getActiveBones(): number;
  1516. /**
  1517. * Gets the performance counter for active bones
  1518. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  1519. */
  1520. readonly activeBonesPerfCounter: PerfCounter;
  1521. /** @hidden */
  1522. getInterFramePerfCounter(): number;
  1523. /** @hidden */
  1524. readonly interFramePerfCounter: Nullable<PerfCounter>;
  1525. /** @hidden */
  1526. getLastFrameDuration(): number;
  1527. /** @hidden */
  1528. readonly lastFramePerfCounter: Nullable<PerfCounter>;
  1529. /** @hidden */
  1530. getEvaluateActiveMeshesDuration(): number;
  1531. /** @hidden */
  1532. readonly evaluateActiveMeshesDurationPerfCounter: Nullable<PerfCounter>;
  1533. /**
  1534. * Gets the array of active meshes
  1535. * @returns an array of AbstractMesh
  1536. */
  1537. getActiveMeshes(): SmartArray<AbstractMesh>;
  1538. /** @hidden */
  1539. getRenderTargetsDuration(): number;
  1540. /** @hidden */
  1541. getRenderDuration(): number;
  1542. /** @hidden */
  1543. readonly renderDurationPerfCounter: Nullable<PerfCounter>;
  1544. /** @hidden */
  1545. getParticlesDuration(): number;
  1546. /** @hidden */
  1547. readonly particlesDurationPerfCounter: Nullable<PerfCounter>;
  1548. /** @hidden */
  1549. getSpritesDuration(): number;
  1550. /** @hidden */
  1551. readonly spriteDuractionPerfCounter: Nullable<PerfCounter>;
  1552. /**
  1553. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  1554. * @returns a number
  1555. */
  1556. getAnimationRatio(): number;
  1557. /**
  1558. * Gets an unique Id for the current frame
  1559. * @returns a number
  1560. */
  1561. getRenderId(): number;
  1562. /** Call this function if you want to manually increment the render Id*/
  1563. incrementRenderId(): void;
  1564. private _updatePointerPosition(evt);
  1565. private _createUbo();
  1566. private _createAlternateUbo();
  1567. private _pickSpriteButKeepRay(originalPointerInfo, x, y, predicate?, fastCheck?, camera?);
  1568. private _setRayOnPointerInfo(pointerInfo);
  1569. /**
  1570. * Use this method to simulate a pointer move on a mesh
  1571. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  1572. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  1573. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  1574. * @returns the current scene
  1575. */
  1576. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  1577. private _processPointerMove(pickResult, evt);
  1578. private _checkPrePointerObservable(pickResult, evt, type);
  1579. /**
  1580. * Use this method to simulate a pointer down on a mesh
  1581. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  1582. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  1583. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  1584. * @returns the current scene
  1585. */
  1586. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  1587. private _processPointerDown(pickResult, evt);
  1588. /**
  1589. * Use this method to simulate a pointer up on a mesh
  1590. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  1591. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  1592. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  1593. * @returns the current scene
  1594. */
  1595. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  1596. private _processPointerUp(pickResult, evt, clickInfo);
  1597. /**
  1598. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  1599. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  1600. * @returns true if the pointer was captured
  1601. */
  1602. isPointerCaptured(pointerId?: number): boolean;
  1603. /**
  1604. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  1605. * @param attachUp defines if you want to attach events to pointerup
  1606. * @param attachDown defines if you want to attach events to pointerdown
  1607. * @param attachMove defines if you want to attach events to pointermove
  1608. */
  1609. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  1610. /** Detaches all event handlers*/
  1611. detachControl(): void;
  1612. /**
  1613. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  1614. * Delay loaded resources are not taking in account
  1615. * @return true if all required resources are ready
  1616. */
  1617. isReady(): boolean;
  1618. /** Resets all cached information relative to material (including effect and visibility) */
  1619. resetCachedMaterial(): void;
  1620. /**
  1621. * Registers a function to be called before every frame render
  1622. * @param func defines the function to register
  1623. */
  1624. registerBeforeRender(func: () => void): void;
  1625. /**
  1626. * Unregisters a function called before every frame render
  1627. * @param func defines the function to unregister
  1628. */
  1629. unregisterBeforeRender(func: () => void): void;
  1630. /**
  1631. * Registers a function to be called after every frame render
  1632. * @param func defines the function to register
  1633. */
  1634. registerAfterRender(func: () => void): void;
  1635. /**
  1636. * Unregisters a function called after every frame render
  1637. * @param func defines the function to unregister
  1638. */
  1639. unregisterAfterRender(func: () => void): void;
  1640. private _executeOnceBeforeRender(func);
  1641. /**
  1642. * The provided function will run before render once and will be disposed afterwards.
  1643. * A timeout delay can be provided so that the function will be executed in N ms.
  1644. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  1645. * @param func The function to be executed.
  1646. * @param timeout optional delay in ms
  1647. */
  1648. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  1649. /** @hidden */
  1650. _addPendingData(data: any): void;
  1651. /** @hidden */
  1652. _removePendingData(data: any): void;
  1653. /**
  1654. * Returns the number of items waiting to be loaded
  1655. * @returns the number of items waiting to be loaded
  1656. */
  1657. getWaitingItemsCount(): number;
  1658. /**
  1659. * Returns a boolean indicating if the scene is still loading data
  1660. */
  1661. readonly isLoading: boolean;
  1662. /**
  1663. * Registers a function to be executed when the scene is ready
  1664. * @param {Function} func - the function to be executed
  1665. */
  1666. executeWhenReady(func: () => void): void;
  1667. /**
  1668. * Returns a promise that resolves when the scene is ready
  1669. * @returns A promise that resolves when the scene is ready
  1670. */
  1671. whenReadyAsync(): Promise<void>;
  1672. /** @hidden */
  1673. _checkIsReady(): void;
  1674. /**
  1675. * Will start the animation sequence of a given target
  1676. * @param target defines the target
  1677. * @param from defines from which frame should animation start
  1678. * @param to defines until which frame should animation run.
  1679. * @param weight defines the weight to apply to the animation (1.0 by default)
  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. * @returns the animatable object created for this animation
  1685. */
  1686. beginWeightedAnimation(target: any, from: number, to: number, weight?: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable): Animatable;
  1687. /**
  1688. * Will start the animation sequence of a given target
  1689. * @param target defines the target
  1690. * @param from defines from which frame should animation start
  1691. * @param to defines until which frame should animation run.
  1692. * @param loop defines if the animation loops
  1693. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  1694. * @param onAnimationEnd defines the function to be executed when the animation ends
  1695. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  1696. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  1697. * @returns the animatable object created for this animation
  1698. */
  1699. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean): Animatable;
  1700. /**
  1701. * Begin a new animation on a given node
  1702. * @param target defines the target where the animation will take place
  1703. * @param animations defines the list of animations to start
  1704. * @param from defines the initial value
  1705. * @param to defines the final value
  1706. * @param loop defines if you want animation to loop (off by default)
  1707. * @param speedRatio defines the speed ratio to apply to all animations
  1708. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  1709. * @returns the list of created animatables
  1710. */
  1711. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Animatable;
  1712. /**
  1713. * Begin a new animation on a given node and its hierarchy
  1714. * @param target defines the root node where the animation will take place
  1715. * @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.
  1716. * @param animations defines the list of animations to start
  1717. * @param from defines the initial value
  1718. * @param to defines the final value
  1719. * @param loop defines if you want animation to loop (off by default)
  1720. * @param speedRatio defines the speed ratio to apply to all animations
  1721. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  1722. * @returns the list of animatables created for all nodes
  1723. */
  1724. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Animatable[];
  1725. /**
  1726. * Gets the animatable associated with a specific target
  1727. * @param target defines the target of the animatable
  1728. * @returns the required animatable if found
  1729. */
  1730. getAnimatableByTarget(target: any): Nullable<Animatable>;
  1731. /**
  1732. * Gets all animatables associated with a given target
  1733. * @param target defines the target to look animatables for
  1734. * @returns an array of Animatables
  1735. */
  1736. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  1737. /**
  1738. * Gets all animatable attached to the scene
  1739. */
  1740. readonly animatables: Animatable[];
  1741. /**
  1742. * Will stop the animation of the given target
  1743. * @param target - the target
  1744. * @param animationName - the name of the animation to stop (all animations will be stopped if empty)
  1745. */
  1746. stopAnimation(target: any, animationName?: string): void;
  1747. /**
  1748. * Stops and removes all animations that have been applied to the scene
  1749. */
  1750. stopAllAnimations(): void;
  1751. private _animate();
  1752. /** @hidden */
  1753. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  1754. private _processLateAnimationBindingsForMatrices(holder);
  1755. private _processLateAnimationBindingsForQuaternions(holder);
  1756. private _processLateAnimationBindings();
  1757. /** @hidden */
  1758. _switchToAlternateCameraConfiguration(active: boolean): void;
  1759. /**
  1760. * Gets the current view matrix
  1761. * @returns a Matrix
  1762. */
  1763. getViewMatrix(): Matrix;
  1764. /**
  1765. * Gets the current projection matrix
  1766. * @returns a Matrix
  1767. */
  1768. getProjectionMatrix(): Matrix;
  1769. /**
  1770. * Gets the current transform matrix
  1771. * @returns a Matrix made of View * Projection
  1772. */
  1773. getTransformMatrix(): Matrix;
  1774. /**
  1775. * Sets the current transform matrix
  1776. * @param view defines the View matrix to use
  1777. * @param projection defines the Projection matrix to use
  1778. */
  1779. setTransformMatrix(view: Matrix, projection: Matrix): void;
  1780. /** @hidden */
  1781. _setAlternateTransformMatrix(view: Matrix, projection: Matrix): void;
  1782. /**
  1783. * Gets the uniform buffer used to store scene data
  1784. * @returns a UniformBuffer
  1785. */
  1786. getSceneUniformBuffer(): UniformBuffer;
  1787. /**
  1788. * Gets an unique (relatively to the current scene) Id
  1789. * @returns an unique number for the scene
  1790. */
  1791. getUniqueId(): number;
  1792. /**
  1793. * Add a mesh to the list of scene's meshes
  1794. * @param newMesh defines the mesh to add
  1795. * @param recursive if all child meshes should also be added to the scene
  1796. */
  1797. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  1798. /**
  1799. * Remove a mesh for the list of scene's meshes
  1800. * @param toRemove defines the mesh to remove
  1801. * @param recursive if all child meshes should also be removed from the scene
  1802. * @returns the index where the mesh was in the mesh list
  1803. */
  1804. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  1805. /**
  1806. * Add a transform node to the list of scene's transform nodes
  1807. * @param newTransformNode defines the transform node to add
  1808. */
  1809. addTransformNode(newTransformNode: TransformNode): void;
  1810. /**
  1811. * Remove a transform node for the list of scene's transform nodes
  1812. * @param toRemove defines the transform node to remove
  1813. * @returns the index where the transform node was in the transform node list
  1814. */
  1815. removeTransformNode(toRemove: TransformNode): number;
  1816. /**
  1817. * Remove a skeleton for the list of scene's skeletons
  1818. * @param toRemove defines the skeleton to remove
  1819. * @returns the index where the skeleton was in the skeleton list
  1820. */
  1821. removeSkeleton(toRemove: Skeleton): number;
  1822. /**
  1823. * Remove a morph target for the list of scene's morph targets
  1824. * @param toRemove defines the morph target to remove
  1825. * @returns the index where the morph target was in the morph target list
  1826. */
  1827. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  1828. /**
  1829. * Remove a light for the list of scene's lights
  1830. * @param toRemove defines the light to remove
  1831. * @returns the index where the light was in the light list
  1832. */
  1833. removeLight(toRemove: Light): number;
  1834. /**
  1835. * Remove a camera for the list of scene's cameras
  1836. * @param toRemove defines the camera to remove
  1837. * @returns the index where the camera was in the camera list
  1838. */
  1839. removeCamera(toRemove: Camera): number;
  1840. /**
  1841. * Remove a particle system for the list of scene's particle systems
  1842. * @param toRemove defines the particle system to remove
  1843. * @returns the index where the particle system was in the particle system list
  1844. */
  1845. removeParticleSystem(toRemove: IParticleSystem): number;
  1846. /**
  1847. * Remove a animation for the list of scene's animations
  1848. * @param toRemove defines the animation to remove
  1849. * @returns the index where the animation was in the animation list
  1850. */
  1851. removeAnimation(toRemove: Animation): number;
  1852. /**
  1853. * Removes the given animation group from this scene.
  1854. * @param toRemove The animation group to remove
  1855. * @returns The index of the removed animation group
  1856. */
  1857. removeAnimationGroup(toRemove: AnimationGroup): number;
  1858. /**
  1859. * Removes the given multi-material from this scene.
  1860. * @param toRemove The multi-material to remove
  1861. * @returns The index of the removed multi-material
  1862. */
  1863. removeMultiMaterial(toRemove: MultiMaterial): number;
  1864. /**
  1865. * Removes the given material from this scene.
  1866. * @param toRemove The material to remove
  1867. * @returns The index of the removed material
  1868. */
  1869. removeMaterial(toRemove: Material): number;
  1870. /**
  1871. * Removes the given lens flare system from this scene.
  1872. * @param toRemove The lens flare system to remove
  1873. * @returns The index of the removed lens flare system
  1874. */
  1875. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  1876. /**
  1877. * Removes the given action manager from this scene.
  1878. * @param toRemove The action manager to remove
  1879. * @returns The index of the removed action manager
  1880. */
  1881. removeActionManager(toRemove: ActionManager): number;
  1882. /**
  1883. * Removes the given effect layer from this scene.
  1884. * @param toRemove defines the effect layer to remove
  1885. * @returns the index of the removed effect layer
  1886. */
  1887. removeEffectLayer(toRemove: EffectLayer): number;
  1888. /**
  1889. * Removes the given texture from this scene.
  1890. * @param toRemove The texture to remove
  1891. * @returns The index of the removed texture
  1892. */
  1893. removeTexture(toRemove: BaseTexture): number;
  1894. /**
  1895. * Adds the given light to this scene
  1896. * @param newLight The light to add
  1897. */
  1898. addLight(newLight: Light): void;
  1899. /**
  1900. * Sorts the list list based on light priorities
  1901. */
  1902. sortLightsByPriority(): void;
  1903. /**
  1904. * Adds the given camera to this scene
  1905. * @param newCamera The camera to add
  1906. */
  1907. addCamera(newCamera: Camera): void;
  1908. /**
  1909. * Adds the given skeleton to this scene
  1910. * @param newSkeleton The skeleton to add
  1911. */
  1912. addSkeleton(newSkeleton: Skeleton): void;
  1913. /**
  1914. * Adds the given particle system to this scene
  1915. * @param newParticleSystem The particle system to add
  1916. */
  1917. addParticleSystem(newParticleSystem: IParticleSystem): void;
  1918. /**
  1919. * Adds the given animation to this scene
  1920. * @param newAnimation The animation to add
  1921. */
  1922. addAnimation(newAnimation: Animation): void;
  1923. /**
  1924. * Adds the given animation group to this scene.
  1925. * @param newAnimationGroup The animation group to add
  1926. */
  1927. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  1928. /**
  1929. * Adds the given multi-material to this scene
  1930. * @param newMultiMaterial The multi-material to add
  1931. */
  1932. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  1933. /**
  1934. * Adds the given material to this scene
  1935. * @param newMaterial The material to add
  1936. */
  1937. addMaterial(newMaterial: Material): void;
  1938. /**
  1939. * Adds the given morph target to this scene
  1940. * @param newMorphTargetManager The morph target to add
  1941. */
  1942. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  1943. /**
  1944. * Adds the given geometry to this scene
  1945. * @param newGeometry The geometry to add
  1946. */
  1947. addGeometry(newGeometry: Geometry): void;
  1948. /**
  1949. * Adds the given lens flare system to this scene
  1950. * @param newLensFlareSystem The lens flare system to add
  1951. */
  1952. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  1953. /**
  1954. * Adds the given effect layer to this scene
  1955. * @param newEffectLayer defines the effect layer to add
  1956. */
  1957. addEffectLayer(newEffectLayer: EffectLayer): void;
  1958. /**
  1959. * Adds the given action manager to this scene
  1960. * @param newActionManager The action manager to add
  1961. */
  1962. addActionManager(newActionManager: ActionManager): void;
  1963. /**
  1964. * Adds the given texture to this scene.
  1965. * @param newTexture The texture to add
  1966. */
  1967. addTexture(newTexture: BaseTexture): void;
  1968. /**
  1969. * Switch active camera
  1970. * @param newCamera defines the new active camera
  1971. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  1972. */
  1973. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  1974. /**
  1975. * sets the active camera of the scene using its ID
  1976. * @param id defines the camera's ID
  1977. * @return the new active camera or null if none found.
  1978. */
  1979. setActiveCameraByID(id: string): Nullable<Camera>;
  1980. /**
  1981. * sets the active camera of the scene using its name
  1982. * @param name defines the camera's name
  1983. * @returns the new active camera or null if none found.
  1984. */
  1985. setActiveCameraByName(name: string): Nullable<Camera>;
  1986. /**
  1987. * get an animation group using its name
  1988. * @param name defines the material's name
  1989. * @return the animation group or null if none found.
  1990. */
  1991. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  1992. /**
  1993. * get a material using its id
  1994. * @param id defines the material's ID
  1995. * @return the material or null if none found.
  1996. */
  1997. getMaterialByID(id: string): Nullable<Material>;
  1998. /**
  1999. * Gets a material using its name
  2000. * @param name defines the material's name
  2001. * @return the material or null if none found.
  2002. */
  2003. getMaterialByName(name: string): Nullable<Material>;
  2004. /**
  2005. * Gets a lens flare system using its name
  2006. * @param name defines the name to look for
  2007. * @returns the lens flare system or null if not found
  2008. */
  2009. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  2010. /**
  2011. * Gets a lens flare system using its id
  2012. * @param id defines the id to look for
  2013. * @returns the lens flare system or null if not found
  2014. */
  2015. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  2016. /**
  2017. * Gets a camera using its id
  2018. * @param id defines the id to look for
  2019. * @returns the camera or null if not found
  2020. */
  2021. getCameraByID(id: string): Nullable<Camera>;
  2022. /**
  2023. * Gets a camera using its unique id
  2024. * @param uniqueId defines the unique id to look for
  2025. * @returns the camera or null if not found
  2026. */
  2027. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  2028. /**
  2029. * Gets a camera using its name
  2030. * @param name defines the camera's name
  2031. * @return the camera or null if none found.
  2032. */
  2033. getCameraByName(name: string): Nullable<Camera>;
  2034. /**
  2035. * Gets a bone using its id
  2036. * @param id defines the bone's id
  2037. * @return the bone or null if not found
  2038. */
  2039. getBoneByID(id: string): Nullable<Bone>;
  2040. /**
  2041. * Gets a bone using its id
  2042. * @param name defines the bone's name
  2043. * @return the bone or null if not found
  2044. */
  2045. getBoneByName(name: string): Nullable<Bone>;
  2046. /**
  2047. * Gets a light node using its name
  2048. * @param name defines the the light's name
  2049. * @return the light or null if none found.
  2050. */
  2051. getLightByName(name: string): Nullable<Light>;
  2052. /**
  2053. * Gets a light node using its id
  2054. * @param id defines the light's id
  2055. * @return the light or null if none found.
  2056. */
  2057. getLightByID(id: string): Nullable<Light>;
  2058. /**
  2059. * Gets a light node using its scene-generated unique ID
  2060. * @param uniqueId defines the light's unique id
  2061. * @return the light or null if none found.
  2062. */
  2063. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  2064. /**
  2065. * Gets a particle system by id
  2066. * @param id defines the particle system id
  2067. * @return the corresponding system or null if none found
  2068. */
  2069. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  2070. /**
  2071. * Gets a geometry using its ID
  2072. * @param id defines the geometry's id
  2073. * @return the geometry or null if none found.
  2074. */
  2075. getGeometryByID(id: string): Nullable<Geometry>;
  2076. /**
  2077. * Add a new geometry to this scene
  2078. * @param geometry defines the geometry to be added to the scene.
  2079. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  2080. * @return a boolean defining if the geometry was added or not
  2081. */
  2082. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  2083. /**
  2084. * Removes an existing geometry
  2085. * @param geometry defines the geometry to be removed from the scene
  2086. * @return a boolean defining if the geometry was removed or not
  2087. */
  2088. removeGeometry(geometry: Geometry): boolean;
  2089. /**
  2090. * Gets the list of geometries attached to the scene
  2091. * @returns an array of Geometry
  2092. */
  2093. getGeometries(): Geometry[];
  2094. /**
  2095. * Gets the first added mesh found of a given ID
  2096. * @param id defines the id to search for
  2097. * @return the mesh found or null if not found at all
  2098. */
  2099. getMeshByID(id: string): Nullable<AbstractMesh>;
  2100. /**
  2101. * Gets a list of meshes using their id
  2102. * @param id defines the id to search for
  2103. * @returns a list of meshes
  2104. */
  2105. getMeshesByID(id: string): Array<AbstractMesh>;
  2106. /**
  2107. * Gets the first added transform node found of a given ID
  2108. * @param id defines the id to search for
  2109. * @return the found transform node or null if not found at all.
  2110. */
  2111. getTransformNodeByID(id: string): Nullable<TransformNode>;
  2112. /**
  2113. * Gets a list of transform nodes using their id
  2114. * @param id defines the id to search for
  2115. * @returns a list of transform nodes
  2116. */
  2117. getTransformNodesByID(id: string): Array<TransformNode>;
  2118. /**
  2119. * Gets a mesh with its auto-generated unique id
  2120. * @param uniqueId defines the unique id to search for
  2121. * @return the found mesh or null if not found at all.
  2122. */
  2123. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  2124. /**
  2125. * Gets a the last added mesh using a given id
  2126. * @param id defines the id to search for
  2127. * @return the found mesh or null if not found at all.
  2128. */
  2129. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  2130. /**
  2131. * Gets a the last added node (Mesh, Camera, Light) using a given id
  2132. * @param id defines the id to search for
  2133. * @return the found node or null if not found at all
  2134. */
  2135. getLastEntryByID(id: string): Nullable<Node>;
  2136. /**
  2137. * Gets a node (Mesh, Camera, Light) using a given id
  2138. * @param id defines the id to search for
  2139. * @return the found node or null if not found at all
  2140. */
  2141. getNodeByID(id: string): Nullable<Node>;
  2142. /**
  2143. * Gets a node (Mesh, Camera, Light) using a given name
  2144. * @param name defines the name to search for
  2145. * @return the found node or null if not found at all.
  2146. */
  2147. getNodeByName(name: string): Nullable<Node>;
  2148. /**
  2149. * Gets a mesh using a given name
  2150. * @param name defines the name to search for
  2151. * @return the found mesh or null if not found at all.
  2152. */
  2153. getMeshByName(name: string): Nullable<AbstractMesh>;
  2154. /**
  2155. * Gets a transform node using a given name
  2156. * @param name defines the name to search for
  2157. * @return the found transform node or null if not found at all.
  2158. */
  2159. getTransformNodeByName(name: string): Nullable<TransformNode>;
  2160. /**
  2161. * Gets a sound using a given name
  2162. * @param name defines the name to search for
  2163. * @return the found sound or null if not found at all.
  2164. */
  2165. getSoundByName(name: string): Nullable<Sound>;
  2166. /**
  2167. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  2168. * @param id defines the id to search for
  2169. * @return the found skeleton or null if not found at all.
  2170. */
  2171. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  2172. /**
  2173. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  2174. * @param id defines the id to search for
  2175. * @return the found skeleton or null if not found at all.
  2176. */
  2177. getSkeletonById(id: string): Nullable<Skeleton>;
  2178. /**
  2179. * Gets a skeleton using a given name
  2180. * @param name defines the name to search for
  2181. * @return the found skeleton or null if not found at all.
  2182. */
  2183. getSkeletonByName(name: string): Nullable<Skeleton>;
  2184. /**
  2185. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  2186. * @param id defines the id to search for
  2187. * @return the found morph target manager or null if not found at all.
  2188. */
  2189. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  2190. /**
  2191. * Gets a boolean indicating if the given mesh is active
  2192. * @param mesh defines the mesh to look for
  2193. * @returns true if the mesh is in the active list
  2194. */
  2195. isActiveMesh(mesh: AbstractMesh): boolean;
  2196. /**
  2197. * Return a the first highlight layer of the scene with a given name.
  2198. * @param name The name of the highlight layer to look for.
  2199. * @return The highlight layer if found otherwise null.
  2200. */
  2201. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  2202. /**
  2203. * Return a the first highlight layer of the scene with a given name.
  2204. * @param name The name of the highlight layer to look for.
  2205. * @return The highlight layer if found otherwise null.
  2206. */
  2207. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  2208. /**
  2209. * Return a unique id as a string which can serve as an identifier for the scene
  2210. */
  2211. readonly uid: string;
  2212. /**
  2213. * Add an externaly attached data from its key.
  2214. * This method call will fail and return false, if such key already exists.
  2215. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  2216. * @param key the unique key that identifies the data
  2217. * @param data the data object to associate to the key for this Engine instance
  2218. * @return true if no such key were already present and the data was added successfully, false otherwise
  2219. */
  2220. addExternalData<T>(key: string, data: T): boolean;
  2221. /**
  2222. * Get an externaly attached data from its key
  2223. * @param key the unique key that identifies the data
  2224. * @return the associated data, if present (can be null), or undefined if not present
  2225. */
  2226. getExternalData<T>(key: string): Nullable<T>;
  2227. /**
  2228. * Get an externaly attached data from its key, create it using a factory if it's not already present
  2229. * @param key the unique key that identifies the data
  2230. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  2231. * @return the associated data, can be null if the factory returned null.
  2232. */
  2233. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  2234. /**
  2235. * Remove an externaly attached data from the Engine instance
  2236. * @param key the unique key that identifies the data
  2237. * @return true if the data was successfully removed, false if it doesn't exist
  2238. */
  2239. removeExternalData(key: string): boolean;
  2240. private _evaluateSubMesh(subMesh, mesh);
  2241. /**
  2242. * Clear the processed materials smart array preventing retention point in material dispose.
  2243. */
  2244. freeProcessedMaterials(): void;
  2245. /**
  2246. * Clear the active meshes smart array preventing retention point in mesh dispose.
  2247. */
  2248. freeActiveMeshes(): void;
  2249. /**
  2250. * Clear the info related to rendering groups preventing retention points during dispose.
  2251. */
  2252. freeRenderingGroups(): void;
  2253. /** @hidden */
  2254. _isInIntermediateRendering(): boolean;
  2255. private _activeMeshCandidateProvider;
  2256. /**
  2257. * Defines the current active mesh candidate provider
  2258. * @param provider defines the provider to use
  2259. */
  2260. setActiveMeshCandidateProvider(provider: IActiveMeshCandidateProvider): void;
  2261. /**
  2262. * Gets the current active mesh candidate provider
  2263. * @returns the current active mesh candidate provider
  2264. */
  2265. getActiveMeshCandidateProvider(): IActiveMeshCandidateProvider;
  2266. private _activeMeshesFrozen;
  2267. /**
  2268. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  2269. * @returns the current scene
  2270. */
  2271. freezeActiveMeshes(): Scene;
  2272. /**
  2273. * Use this function to restart evaluating active meshes on every frame
  2274. * @returns the current scene
  2275. */
  2276. unfreezeActiveMeshes(): Scene;
  2277. private _evaluateActiveMeshes();
  2278. private _activeMesh(sourceMesh, mesh);
  2279. /**
  2280. * Update the transform matrix to update from the current active camera
  2281. * @param force defines a boolean used to force the update even if cache is up to date
  2282. */
  2283. updateTransformMatrix(force?: boolean): void;
  2284. /**
  2285. * 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)
  2286. * @param alternateCamera defines the camera to use
  2287. */
  2288. updateAlternateTransformMatrix(alternateCamera: Camera): void;
  2289. private _renderForCamera(camera, rigParent?);
  2290. private _processSubCameras(camera);
  2291. private _checkIntersections();
  2292. /**
  2293. * Render the scene
  2294. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  2295. */
  2296. render(updateCameras?: boolean): void;
  2297. private _updateAudioParameters();
  2298. /**
  2299. * Gets or sets if audio support is enabled
  2300. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  2301. */
  2302. audioEnabled: boolean;
  2303. private _disableAudio();
  2304. private _enableAudio();
  2305. /**
  2306. * Gets or sets if audio will be output to headphones
  2307. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  2308. */
  2309. headphone: boolean;
  2310. private _switchAudioModeForHeadphones();
  2311. private _switchAudioModeForNormalSpeakers();
  2312. /**
  2313. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  2314. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  2315. * @returns the created depth renderer
  2316. */
  2317. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  2318. /**
  2319. * Disables a depth renderer for a given camera
  2320. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  2321. */
  2322. disableDepthRenderer(camera?: Nullable<Camera>): void;
  2323. /**
  2324. * Enables a GeometryBufferRender and associates it with the scene
  2325. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  2326. * @returns the GeometryBufferRenderer
  2327. */
  2328. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  2329. /**
  2330. * Disables the GeometryBufferRender associated with the scene
  2331. */
  2332. disableGeometryBufferRenderer(): void;
  2333. /**
  2334. * Freeze all materials
  2335. * A frozen material will not be updatable but should be faster to render
  2336. */
  2337. freezeMaterials(): void;
  2338. /**
  2339. * Unfreeze all materials
  2340. * A frozen material will not be updatable but should be faster to render
  2341. */
  2342. unfreezeMaterials(): void;
  2343. /**
  2344. * Releases all held ressources
  2345. */
  2346. dispose(): void;
  2347. /**
  2348. * Gets if the scene is already disposed
  2349. */
  2350. readonly isDisposed: boolean;
  2351. /**
  2352. * Releases sounds & soundtracks
  2353. */
  2354. disposeSounds(): void;
  2355. /**
  2356. * Call this function to reduce memory footprint of the scene.
  2357. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  2358. */
  2359. clearCachedVertexData(): void;
  2360. /**
  2361. * This function will remove the local cached buffer data from texture.
  2362. * It will save memory but will prevent the texture from being rebuilt
  2363. */
  2364. cleanCachedTextureBuffer(): void;
  2365. /**
  2366. * Get the world extend vectors with an optional filter
  2367. *
  2368. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  2369. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  2370. */
  2371. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  2372. min: Vector3;
  2373. max: Vector3;
  2374. };
  2375. /**
  2376. * Creates or updates the octree used to boost selection (picking)
  2377. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  2378. * @param maxCapacity defines the maximum capacity per leaf
  2379. * @param maxDepth defines the maximum depth of the octree
  2380. * @returns an octree of AbstractMesh
  2381. */
  2382. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  2383. /**
  2384. * Creates a ray that can be used to pick in the scene
  2385. * @param x defines the x coordinate of the origin (on-screen)
  2386. * @param y defines the y coordinate of the origin (on-screen)
  2387. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  2388. * @param camera defines the camera to use for the picking
  2389. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  2390. * @returns a Ray
  2391. */
  2392. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  2393. /**
  2394. * Creates a ray that can be used to pick in the scene
  2395. * @param x defines the x coordinate of the origin (on-screen)
  2396. * @param y defines the y coordinate of the origin (on-screen)
  2397. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  2398. * @param result defines the ray where to store the picking ray
  2399. * @param camera defines the camera to use for the picking
  2400. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  2401. * @returns the current scene
  2402. */
  2403. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  2404. /**
  2405. * Creates a ray that can be used to pick in the scene
  2406. * @param x defines the x coordinate of the origin (on-screen)
  2407. * @param y defines the y coordinate of the origin (on-screen)
  2408. * @param camera defines the camera to use for the picking
  2409. * @returns a Ray
  2410. */
  2411. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  2412. /**
  2413. * Creates a ray that can be used to pick in the scene
  2414. * @param x defines the x coordinate of the origin (on-screen)
  2415. * @param y defines the y coordinate of the origin (on-screen)
  2416. * @param result defines the ray where to store the picking ray
  2417. * @param camera defines the camera to use for the picking
  2418. * @returns the current scene
  2419. */
  2420. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  2421. private _internalPick(rayFunction, predicate?, fastCheck?);
  2422. private _internalMultiPick(rayFunction, predicate?);
  2423. private _internalPickSprites(ray, predicate?, fastCheck?, camera?);
  2424. private _tempPickingRay;
  2425. /** Launch a ray to try to pick a mesh in the scene
  2426. * @param x position on screen
  2427. * @param y position on screen
  2428. * @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
  2429. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  2430. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  2431. * @returns a PickingInfo
  2432. */
  2433. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  2434. /** Launch a ray to try to pick a sprite in the scene
  2435. * @param x position on screen
  2436. * @param y position on screen
  2437. * @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
  2438. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  2439. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  2440. * @returns a PickingInfo
  2441. */
  2442. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  2443. private _cachedRayForTransform;
  2444. /** Use the given ray to pick a mesh in the scene
  2445. * @param ray The ray to use to pick meshes
  2446. * @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
  2447. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  2448. * @returns a PickingInfo
  2449. */
  2450. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  2451. /**
  2452. * Launch a ray to try to pick a mesh in the scene
  2453. * @param x X position on screen
  2454. * @param y Y position on screen
  2455. * @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
  2456. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  2457. * @returns an array of PickingInfo
  2458. */
  2459. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  2460. /**
  2461. * Launch a ray to try to pick a mesh in the scene
  2462. * @param ray Ray to use
  2463. * @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
  2464. * @returns an array of PickingInfo
  2465. */
  2466. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean): Nullable<PickingInfo[]>;
  2467. /**
  2468. * Force the value of meshUnderPointer
  2469. * @param mesh defines the mesh to use
  2470. */
  2471. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  2472. /**
  2473. * Gets the mesh under the pointer
  2474. * @returns a Mesh or null if no mesh is under the pointer
  2475. */
  2476. getPointerOverMesh(): Nullable<AbstractMesh>;
  2477. /**
  2478. * Force the sprite under the pointer
  2479. * @param sprite defines the sprite to use
  2480. */
  2481. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  2482. /**
  2483. * Gets the sprite under the pointer
  2484. * @returns a Sprite or null if no sprite is under the pointer
  2485. */
  2486. getPointerOverSprite(): Nullable<Sprite>;
  2487. /**
  2488. * Gets the current physics engine
  2489. * @returns a PhysicsEngine or null if none attached
  2490. */
  2491. getPhysicsEngine(): Nullable<PhysicsEngine>;
  2492. /**
  2493. * Enables physics to the current scene
  2494. * @param gravity defines the scene's gravity for the physics engine
  2495. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  2496. * @return a boolean indicating if the physics engine was initialized
  2497. */
  2498. enablePhysics(gravity?: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  2499. /**
  2500. * Disables and disposes the physics engine associated with the scene
  2501. */
  2502. disablePhysicsEngine(): void;
  2503. /**
  2504. * Gets a boolean indicating if there is an active physics engine
  2505. * @returns a boolean indicating if there is an active physics engine
  2506. */
  2507. isPhysicsEnabled(): boolean;
  2508. /**
  2509. * Deletes a physics compound impostor
  2510. * @param compound defines the compound to delete
  2511. */
  2512. deleteCompoundImpostor(compound: any): void;
  2513. /** @hidden */
  2514. _rebuildGeometries(): void;
  2515. /** @hidden */
  2516. _rebuildTextures(): void;
  2517. /**
  2518. * Creates a default light for the scene.
  2519. * @param replace Whether to replace the existing lights in the scene.
  2520. */
  2521. createDefaultLight(replace?: boolean): void;
  2522. /**
  2523. * Creates a default camera for the scene.
  2524. * @param createArcRotateCamera Whether to create an arc rotate or a free camera.
  2525. * @param replace Whether to replace the existing active camera in the scene.
  2526. * @param attachCameraControls Whether to attach camera controls to the canvas.
  2527. */
  2528. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  2529. /**
  2530. * Creates a default camera and a default light
  2531. * @param createArcRotateCamera defines that the camera will be an ArcRotateCamera
  2532. * @param replace defines if the camera and/or light will replace the existing ones
  2533. * @param attachCameraControls defines if attachControl will be called on the new camera
  2534. */
  2535. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  2536. /**
  2537. * Creates a new sky box
  2538. * @see http://doc.babylonjs.com/babylon101/environment#skybox
  2539. * @param environmentTexture defines the texture to use as environment texture
  2540. * @param pbr defines if PBRMaterial must be used instead of StandardMaterial
  2541. * @param scale defines the overall scale of the skybox
  2542. * @param blur defines if blurring must be applied to the environment texture (works only with pbr === true)
  2543. * @param setGlobalEnvTexture defines a boolean indicating that scene.environmentTexture must match the current skybox texture (true by default)
  2544. * @returns a new mesh holding the sky box
  2545. */
  2546. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  2547. /**
  2548. * Creates a new environment
  2549. * @see http://doc.babylonjs.com/babylon101/environment#skybox
  2550. * @param options defines the options you can use to configure the environment
  2551. * @returns the new EnvironmentHelper
  2552. */
  2553. createDefaultEnvironment(options: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  2554. /**
  2555. * Creates a new VREXperienceHelper
  2556. * @see http://doc.babylonjs.com/how_to/webvr_helper
  2557. * @param webVROptions defines the options used to create the new VREXperienceHelper
  2558. * @returns a new VREXperienceHelper
  2559. */
  2560. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  2561. private _getByTags(list, tagsQuery, forEach?);
  2562. /**
  2563. * Get a list of meshes by tags
  2564. * @param tagsQuery defines the tags query to use
  2565. * @param forEach defines a predicate used to filter results
  2566. * @returns an array of Mesh
  2567. */
  2568. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  2569. /**
  2570. * Get a list of cameras by tags
  2571. * @param tagsQuery defines the tags query to use
  2572. * @param forEach defines a predicate used to filter results
  2573. * @returns an array of Camera
  2574. */
  2575. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  2576. /**
  2577. * Get a list of lights by tags
  2578. * @param tagsQuery defines the tags query to use
  2579. * @param forEach defines a predicate used to filter results
  2580. * @returns an array of Light
  2581. */
  2582. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  2583. /**
  2584. * Get a list of materials by tags
  2585. * @param tagsQuery defines the tags query to use
  2586. * @param forEach defines a predicate used to filter results
  2587. * @returns an array of Material
  2588. */
  2589. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  2590. /**
  2591. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  2592. * This allowed control for front to back rendering or reversly depending of the special needs.
  2593. *
  2594. * @param renderingGroupId The rendering group id corresponding to its index
  2595. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  2596. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  2597. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  2598. */
  2599. 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;
  2600. /**
  2601. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  2602. *
  2603. * @param renderingGroupId The rendering group id corresponding to its index
  2604. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  2605. * @param depth Automatically clears depth between groups if true and autoClear is true.
  2606. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  2607. */
  2608. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  2609. /**
  2610. * Will flag all materials as dirty to trigger new shader compilation
  2611. * @param flag defines the flag used to specify which material part must be marked as dirty
  2612. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  2613. */
  2614. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  2615. /** @hidden */
  2616. _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;
  2617. /** @hidden */
  2618. _loadFileAsync(url: string, useDatabase?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  2619. }
  2620. }
  2621. declare module BABYLON {
  2622. type Nullable<T> = T | null;
  2623. type float = number;
  2624. type double = number;
  2625. type int = number;
  2626. type FloatArray = number[] | Float32Array;
  2627. type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  2628. /**
  2629. * Alias for types that can be used by a Buffer or VertexBuffer.
  2630. */
  2631. type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  2632. }
  2633. declare module BABYLON {
  2634. /**
  2635. * The action to be carried out following a trigger
  2636. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  2637. */
  2638. class Action {
  2639. /** the trigger, with or without parameters, for the action */
  2640. triggerOptions: any;
  2641. /**
  2642. * Trigger for the action
  2643. */
  2644. trigger: number;
  2645. /**
  2646. * Internal only - manager for action
  2647. * @hidden
  2648. */
  2649. _actionManager: ActionManager;
  2650. private _nextActiveAction;
  2651. private _child;
  2652. private _condition?;
  2653. private _triggerParameter;
  2654. /**
  2655. * An event triggered prior to action being executed.
  2656. */
  2657. onBeforeExecuteObservable: Observable<Action>;
  2658. /**
  2659. * Creates a new Action
  2660. * @param triggerOptions the trigger, with or without parameters, for the action
  2661. * @param condition an optional determinant of action
  2662. */
  2663. constructor(
  2664. /** the trigger, with or without parameters, for the action */
  2665. triggerOptions: any, condition?: Condition);
  2666. /**
  2667. * Internal only
  2668. * @hidden
  2669. */
  2670. _prepare(): void;
  2671. /**
  2672. * Gets the trigger parameters
  2673. * @returns the trigger parameters
  2674. */
  2675. getTriggerParameter(): any;
  2676. /**
  2677. * Internal only - executes current action event
  2678. * @hidden
  2679. */
  2680. _executeCurrent(evt?: ActionEvent): void;
  2681. /**
  2682. * Execute placeholder for child classes
  2683. * @param evt optional action event
  2684. */
  2685. execute(evt?: ActionEvent): void;
  2686. /**
  2687. * Skips to next active action
  2688. */
  2689. skipToNextActiveAction(): void;
  2690. /**
  2691. * Adds action to chain of actions, may be a DoNothingAction
  2692. * @param action defines the next action to execute
  2693. * @returns The action passed in
  2694. * @see https://www.babylonjs-playground.com/#1T30HR#0
  2695. */
  2696. then(action: Action): Action;
  2697. /**
  2698. * Internal only
  2699. * @hidden
  2700. */
  2701. _getProperty(propertyPath: string): string;
  2702. /**
  2703. * Internal only
  2704. * @hidden
  2705. */
  2706. _getEffectiveTarget(target: any, propertyPath: string): any;
  2707. /**
  2708. * Serialize placeholder for child classes
  2709. * @param parent of child
  2710. * @returns the serialized object
  2711. */
  2712. serialize(parent: any): any;
  2713. /**
  2714. * Internal only called by serialize
  2715. * @hidden
  2716. */
  2717. protected _serialize(serializedAction: any, parent?: any): any;
  2718. /**
  2719. * Internal only
  2720. * @hidden
  2721. */
  2722. static _SerializeValueAsString: (value: any) => string;
  2723. /**
  2724. * Internal only
  2725. * @hidden
  2726. */
  2727. static _GetTargetProperty: (target: Scene | Node) => {
  2728. name: string;
  2729. targetType: string;
  2730. value: string;
  2731. };
  2732. }
  2733. }
  2734. declare module BABYLON {
  2735. /**
  2736. * ActionEvent is the event being sent when an action is triggered.
  2737. */
  2738. class ActionEvent {
  2739. /** The mesh or sprite that triggered the action */
  2740. source: any;
  2741. /** The X mouse cursor position at the time of the event */
  2742. pointerX: number;
  2743. /** The Y mouse cursor position at the time of the event */
  2744. pointerY: number;
  2745. /** The mesh that is currently pointed at (can be null) */
  2746. meshUnderPointer: Nullable<AbstractMesh>;
  2747. /** the original (browser) event that triggered the ActionEvent */
  2748. sourceEvent: any;
  2749. /** additional data for the event */
  2750. additionalData: any;
  2751. /**
  2752. * Creates a new ActionEvent
  2753. * @param source The mesh or sprite that triggered the action
  2754. * @param pointerX The X mouse cursor position at the time of the event
  2755. * @param pointerY The Y mouse cursor position at the time of the event
  2756. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  2757. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  2758. * @param additionalData additional data for the event
  2759. */
  2760. constructor(
  2761. /** The mesh or sprite that triggered the action */
  2762. source: any,
  2763. /** The X mouse cursor position at the time of the event */
  2764. pointerX: number,
  2765. /** The Y mouse cursor position at the time of the event */
  2766. pointerY: number,
  2767. /** The mesh that is currently pointed at (can be null) */
  2768. meshUnderPointer: Nullable<AbstractMesh>,
  2769. /** the original (browser) event that triggered the ActionEvent */
  2770. sourceEvent?: any,
  2771. /** additional data for the event */
  2772. additionalData?: any);
  2773. /**
  2774. * Helper function to auto-create an ActionEvent from a source mesh.
  2775. * @param source The source mesh that triggered the event
  2776. * @param evt The original (browser) event
  2777. * @param additionalData additional data for the event
  2778. * @returns the new ActionEvent
  2779. */
  2780. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  2781. /**
  2782. * Helper function to auto-create an ActionEvent from a source sprite
  2783. * @param source The source sprite that triggered the event
  2784. * @param scene Scene associated with the sprite
  2785. * @param evt The original (browser) event
  2786. * @param additionalData additional data for the event
  2787. * @returns the new ActionEvent
  2788. */
  2789. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  2790. /**
  2791. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  2792. * @param scene the scene where the event occurred
  2793. * @param evt The original (browser) event
  2794. * @returns the new ActionEvent
  2795. */
  2796. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  2797. /**
  2798. * Helper function to auto-create an ActionEvent from a primitive
  2799. * @param prim defines the target primitive
  2800. * @param pointerPos defines the pointer position
  2801. * @param evt The original (browser) event
  2802. * @param additionalData additional data for the event
  2803. * @returns the new ActionEvent
  2804. */
  2805. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  2806. }
  2807. /**
  2808. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  2809. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  2810. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  2811. */
  2812. class ActionManager {
  2813. private static _NothingTrigger;
  2814. private static _OnPickTrigger;
  2815. private static _OnLeftPickTrigger;
  2816. private static _OnRightPickTrigger;
  2817. private static _OnCenterPickTrigger;
  2818. private static _OnPickDownTrigger;
  2819. private static _OnDoublePickTrigger;
  2820. private static _OnPickUpTrigger;
  2821. private static _OnLongPressTrigger;
  2822. private static _OnPointerOverTrigger;
  2823. private static _OnPointerOutTrigger;
  2824. private static _OnEveryFrameTrigger;
  2825. private static _OnIntersectionEnterTrigger;
  2826. private static _OnIntersectionExitTrigger;
  2827. private static _OnKeyDownTrigger;
  2828. private static _OnKeyUpTrigger;
  2829. private static _OnPickOutTrigger;
  2830. /**
  2831. * Nothing
  2832. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2833. */
  2834. static readonly NothingTrigger: number;
  2835. /**
  2836. * On pick
  2837. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2838. */
  2839. static readonly OnPickTrigger: number;
  2840. /**
  2841. * On left pick
  2842. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2843. */
  2844. static readonly OnLeftPickTrigger: number;
  2845. /**
  2846. * On right pick
  2847. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2848. */
  2849. static readonly OnRightPickTrigger: number;
  2850. /**
  2851. * On center pick
  2852. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2853. */
  2854. static readonly OnCenterPickTrigger: number;
  2855. /**
  2856. * On pick down
  2857. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2858. */
  2859. static readonly OnPickDownTrigger: number;
  2860. /**
  2861. * On double pick
  2862. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2863. */
  2864. static readonly OnDoublePickTrigger: number;
  2865. /**
  2866. * On pick up
  2867. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2868. */
  2869. static readonly OnPickUpTrigger: number;
  2870. /**
  2871. * On pick out.
  2872. * This trigger will only be raised if you also declared a OnPickDown
  2873. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2874. */
  2875. static readonly OnPickOutTrigger: number;
  2876. /**
  2877. * On long press
  2878. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2879. */
  2880. static readonly OnLongPressTrigger: number;
  2881. /**
  2882. * On pointer over
  2883. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2884. */
  2885. static readonly OnPointerOverTrigger: number;
  2886. /**
  2887. * On pointer out
  2888. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2889. */
  2890. static readonly OnPointerOutTrigger: number;
  2891. /**
  2892. * On every frame
  2893. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2894. */
  2895. static readonly OnEveryFrameTrigger: number;
  2896. /**
  2897. * On intersection enter
  2898. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2899. */
  2900. static readonly OnIntersectionEnterTrigger: number;
  2901. /**
  2902. * On intersection exit
  2903. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2904. */
  2905. static readonly OnIntersectionExitTrigger: number;
  2906. /**
  2907. * On key down
  2908. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2909. */
  2910. static readonly OnKeyDownTrigger: number;
  2911. /**
  2912. * On key up
  2913. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2914. */
  2915. static readonly OnKeyUpTrigger: number;
  2916. /** Gets the list of active triggers */
  2917. static Triggers: {
  2918. [key: string]: number;
  2919. };
  2920. /** Gets the list of actions */
  2921. actions: Action[];
  2922. /** Gets the cursor to use when hovering items */
  2923. hoverCursor: string;
  2924. private _scene;
  2925. /**
  2926. * Creates a new action manager
  2927. * @param scene defines the hosting scene
  2928. */
  2929. constructor(scene: Scene);
  2930. /**
  2931. * Releases all associated resources
  2932. */
  2933. dispose(): void;
  2934. /**
  2935. * Gets hosting scene
  2936. * @returns the hosting scene
  2937. */
  2938. getScene(): Scene;
  2939. /**
  2940. * Does this action manager handles actions of any of the given triggers
  2941. * @param triggers defines the triggers to be tested
  2942. * @return a boolean indicating whether one (or more) of the triggers is handled
  2943. */
  2944. hasSpecificTriggers(triggers: number[]): boolean;
  2945. /**
  2946. * Does this action manager handles actions of a given trigger
  2947. * @param trigger defines the trigger to be tested
  2948. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  2949. * @return whether the trigger is handled
  2950. */
  2951. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  2952. /**
  2953. * Does this action manager has pointer triggers
  2954. */
  2955. readonly hasPointerTriggers: boolean;
  2956. /**
  2957. * Does this action manager has pick triggers
  2958. */
  2959. readonly hasPickTriggers: boolean;
  2960. /**
  2961. * Does exist one action manager with at least one trigger
  2962. **/
  2963. static readonly HasTriggers: boolean;
  2964. /**
  2965. * Does exist one action manager with at least one pick trigger
  2966. **/
  2967. static readonly HasPickTriggers: boolean;
  2968. /**
  2969. * Does exist one action manager that handles actions of a given trigger
  2970. * @param trigger defines the trigger to be tested
  2971. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  2972. **/
  2973. static HasSpecificTrigger(trigger: number): boolean;
  2974. /**
  2975. * Registers an action to this action manager
  2976. * @param action defines the action to be registered
  2977. * @return the action amended (prepared) after registration
  2978. */
  2979. registerAction(action: Action): Nullable<Action>;
  2980. /**
  2981. * Unregisters an action to this action manager
  2982. * @param action defines the action to be unregistered
  2983. * @return a boolean indicating whether the action has been unregistered
  2984. */
  2985. unregisterAction(action: Action): Boolean;
  2986. /**
  2987. * Process a specific trigger
  2988. * @param trigger defines the trigger to process
  2989. * @param evt defines the event details to be processed
  2990. */
  2991. processTrigger(trigger: number, evt?: ActionEvent): void;
  2992. /** @hidden */
  2993. _getEffectiveTarget(target: any, propertyPath: string): any;
  2994. /** @hidden */
  2995. _getProperty(propertyPath: string): string;
  2996. /**
  2997. * Serialize this manager to a JSON object
  2998. * @param name defines the property name to store this manager
  2999. * @returns a JSON representation of this manager
  3000. */
  3001. serialize(name: string): any;
  3002. /**
  3003. * Creates a new ActionManager from a JSON data
  3004. * @param parsedActions defines the JSON data to read from
  3005. * @param object defines the hosting mesh
  3006. * @param scene defines the hosting scene
  3007. */
  3008. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  3009. /**
  3010. * Get a trigger name by index
  3011. * @param trigger defines the trigger index
  3012. * @returns a trigger name
  3013. */
  3014. static GetTriggerName(trigger: number): string;
  3015. }
  3016. }
  3017. declare module BABYLON {
  3018. /**
  3019. * A Condition applied to an Action
  3020. */
  3021. class Condition {
  3022. /**
  3023. * Internal only - manager for action
  3024. * @hidden
  3025. */
  3026. _actionManager: ActionManager;
  3027. /**
  3028. * Internal only
  3029. * @hidden
  3030. */
  3031. _evaluationId: number;
  3032. /**
  3033. * Internal only
  3034. * @hidden
  3035. */
  3036. _currentResult: boolean;
  3037. /**
  3038. * Creates a new Condition
  3039. * @param actionManager the manager of the action the condition is applied to
  3040. */
  3041. constructor(actionManager: ActionManager);
  3042. /**
  3043. * Check if the current condition is valid
  3044. * @returns a boolean
  3045. */
  3046. isValid(): boolean;
  3047. /**
  3048. * Internal only
  3049. * @hidden
  3050. */
  3051. _getProperty(propertyPath: string): string;
  3052. /**
  3053. * Internal only
  3054. * @hidden
  3055. */
  3056. _getEffectiveTarget(target: any, propertyPath: string): any;
  3057. /**
  3058. * Serialize placeholder for child classes
  3059. * @returns the serialized object
  3060. */
  3061. serialize(): any;
  3062. /**
  3063. * Internal only
  3064. * @hidden
  3065. */
  3066. protected _serialize(serializedCondition: any): any;
  3067. }
  3068. /**
  3069. * Defines specific conditional operators as extensions of Condition
  3070. */
  3071. class ValueCondition extends Condition {
  3072. /** path to specify the property of the target the conditional operator uses */
  3073. propertyPath: string;
  3074. /** the value compared by the conditional operator against the current value of the property */
  3075. value: any;
  3076. /** the conditional operator, default ValueCondition.IsEqual */
  3077. operator: number;
  3078. /**
  3079. * Internal only
  3080. * @hidden
  3081. */
  3082. private static _IsEqual;
  3083. /**
  3084. * Internal only
  3085. * @hidden
  3086. */
  3087. private static _IsDifferent;
  3088. /**
  3089. * Internal only
  3090. * @hidden
  3091. */
  3092. private static _IsGreater;
  3093. /**
  3094. * Internal only
  3095. * @hidden
  3096. */
  3097. private static _IsLesser;
  3098. /**
  3099. * returns the number for IsEqual
  3100. */
  3101. static readonly IsEqual: number;
  3102. /**
  3103. * Returns the number for IsDifferent
  3104. */
  3105. static readonly IsDifferent: number;
  3106. /**
  3107. * Returns the number for IsGreater
  3108. */
  3109. static readonly IsGreater: number;
  3110. /**
  3111. * Returns the number for IsLesser
  3112. */
  3113. static readonly IsLesser: number;
  3114. /**
  3115. * Internal only The action manager for the condition
  3116. * @hidden
  3117. */
  3118. _actionManager: ActionManager;
  3119. /**
  3120. * Internal only
  3121. * @hidden
  3122. */
  3123. private _target;
  3124. /**
  3125. * Internal only
  3126. * @hidden
  3127. */
  3128. private _effectiveTarget;
  3129. /**
  3130. * Internal only
  3131. * @hidden
  3132. */
  3133. private _property;
  3134. /**
  3135. * Creates a new ValueCondition
  3136. * @param actionManager manager for the action the condition applies to
  3137. * @param target for the action
  3138. * @param propertyPath path to specify the property of the target the conditional operator uses
  3139. * @param value the value compared by the conditional operator against the current value of the property
  3140. * @param operator the conditional operator, default ValueCondition.IsEqual
  3141. */
  3142. constructor(actionManager: ActionManager, target: any,
  3143. /** path to specify the property of the target the conditional operator uses */
  3144. propertyPath: string,
  3145. /** the value compared by the conditional operator against the current value of the property */
  3146. value: any,
  3147. /** the conditional operator, default ValueCondition.IsEqual */
  3148. operator?: number);
  3149. /**
  3150. * Compares the given value with the property value for the specified conditional operator
  3151. * @returns the result of the comparison
  3152. */
  3153. isValid(): boolean;
  3154. /**
  3155. * Serialize the ValueCondition into a JSON compatible object
  3156. * @returns serialization object
  3157. */
  3158. serialize(): any;
  3159. /**
  3160. * Gets the name of the conditional operator for the ValueCondition
  3161. * @param operator the conditional operator
  3162. * @returns the name
  3163. */
  3164. static GetOperatorName(operator: number): string;
  3165. }
  3166. /**
  3167. * Defines a predicate condition as an extension of Condition
  3168. */
  3169. class PredicateCondition extends Condition {
  3170. /** defines the predicate function used to validate the condition */
  3171. predicate: () => boolean;
  3172. /**
  3173. * Internal only - manager for action
  3174. * @hidden
  3175. */
  3176. _actionManager: ActionManager;
  3177. /**
  3178. * Creates a new PredicateCondition
  3179. * @param actionManager manager for the action the condition applies to
  3180. * @param predicate defines the predicate function used to validate the condition
  3181. */
  3182. constructor(actionManager: ActionManager,
  3183. /** defines the predicate function used to validate the condition */
  3184. predicate: () => boolean);
  3185. /**
  3186. * @returns the validity of the predicate condition
  3187. */
  3188. isValid(): boolean;
  3189. }
  3190. /**
  3191. * Defines a state condition as an extension of Condition
  3192. */
  3193. class StateCondition extends Condition {
  3194. value: string;
  3195. /**
  3196. * Internal only - manager for action
  3197. * @hidden
  3198. */
  3199. _actionManager: ActionManager;
  3200. /**
  3201. * Internal only
  3202. * @hidden
  3203. */
  3204. private _target;
  3205. /**
  3206. * Creates a new StateCondition
  3207. * @param actionManager manager for the action the condition applies to
  3208. * @param target of the condition
  3209. * @param value to compare with target state
  3210. */
  3211. constructor(actionManager: ActionManager, target: any, value: string);
  3212. /**
  3213. * @returns the validity of the state
  3214. */
  3215. isValid(): boolean;
  3216. /**
  3217. * Serialize the StateCondition into a JSON compatible object
  3218. * @returns serialization object
  3219. */
  3220. serialize(): any;
  3221. }
  3222. }
  3223. declare module BABYLON {
  3224. class SwitchBooleanAction extends Action {
  3225. propertyPath: string;
  3226. private _target;
  3227. private _effectiveTarget;
  3228. private _property;
  3229. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  3230. _prepare(): void;
  3231. execute(): void;
  3232. serialize(parent: any): any;
  3233. }
  3234. class SetStateAction extends Action {
  3235. value: string;
  3236. private _target;
  3237. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  3238. execute(): void;
  3239. serialize(parent: any): any;
  3240. }
  3241. class SetValueAction extends Action {
  3242. propertyPath: string;
  3243. value: any;
  3244. private _target;
  3245. private _effectiveTarget;
  3246. private _property;
  3247. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  3248. _prepare(): void;
  3249. execute(): void;
  3250. serialize(parent: any): any;
  3251. }
  3252. class IncrementValueAction extends Action {
  3253. propertyPath: string;
  3254. value: any;
  3255. private _target;
  3256. private _effectiveTarget;
  3257. private _property;
  3258. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  3259. _prepare(): void;
  3260. execute(): void;
  3261. serialize(parent: any): any;
  3262. }
  3263. class PlayAnimationAction extends Action {
  3264. from: number;
  3265. to: number;
  3266. loop: boolean | undefined;
  3267. private _target;
  3268. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean | undefined, condition?: Condition);
  3269. _prepare(): void;
  3270. execute(): void;
  3271. serialize(parent: any): any;
  3272. }
  3273. class StopAnimationAction extends Action {
  3274. private _target;
  3275. constructor(triggerOptions: any, target: any, condition?: Condition);
  3276. _prepare(): void;
  3277. execute(): void;
  3278. serialize(parent: any): any;
  3279. }
  3280. class DoNothingAction extends Action {
  3281. constructor(triggerOptions?: any, condition?: Condition);
  3282. execute(): void;
  3283. serialize(parent: any): any;
  3284. }
  3285. class CombineAction extends Action {
  3286. children: Action[];
  3287. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  3288. _prepare(): void;
  3289. execute(evt: ActionEvent): void;
  3290. serialize(parent: any): any;
  3291. }
  3292. class ExecuteCodeAction extends Action {
  3293. func: (evt: ActionEvent) => void;
  3294. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  3295. execute(evt: ActionEvent): void;
  3296. }
  3297. class SetParentAction extends Action {
  3298. private _parent;
  3299. private _target;
  3300. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  3301. _prepare(): void;
  3302. execute(): void;
  3303. serialize(parent: any): any;
  3304. }
  3305. class PlaySoundAction extends Action {
  3306. private _sound;
  3307. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  3308. _prepare(): void;
  3309. execute(): void;
  3310. serialize(parent: any): any;
  3311. }
  3312. class StopSoundAction extends Action {
  3313. private _sound;
  3314. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  3315. _prepare(): void;
  3316. execute(): void;
  3317. serialize(parent: any): any;
  3318. }
  3319. }
  3320. declare module BABYLON {
  3321. class InterpolateValueAction extends Action {
  3322. propertyPath: string;
  3323. value: any;
  3324. duration: number;
  3325. stopOtherAnimations: boolean | undefined;
  3326. onInterpolationDone: (() => void) | undefined;
  3327. private _target;
  3328. private _effectiveTarget;
  3329. private _property;
  3330. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  3331. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean | undefined, onInterpolationDone?: (() => void) | undefined);
  3332. _prepare(): void;
  3333. execute(): void;
  3334. serialize(parent: any): any;
  3335. }
  3336. }
  3337. declare module BABYLON {
  3338. /**
  3339. * Class used to work with sound analyzer using fast fourier transform (FFT)
  3340. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  3341. */
  3342. class Analyser {
  3343. /**
  3344. * Gets or sets the smoothing
  3345. * @ignorenaming
  3346. */
  3347. SMOOTHING: number;
  3348. /**
  3349. * Gets or sets the FFT table size
  3350. * @ignorenaming
  3351. */
  3352. FFT_SIZE: number;
  3353. /**
  3354. * Gets or sets the bar graph amplitude
  3355. * @ignorenaming
  3356. */
  3357. BARGRAPHAMPLITUDE: number;
  3358. /**
  3359. * Gets or sets the position of the debug canvas
  3360. * @ignorenaming
  3361. */
  3362. DEBUGCANVASPOS: {
  3363. x: number;
  3364. y: number;
  3365. };
  3366. /**
  3367. * Gets or sets the debug canvas size
  3368. * @ignorenaming
  3369. */
  3370. DEBUGCANVASSIZE: {
  3371. width: number;
  3372. height: number;
  3373. };
  3374. private _byteFreqs;
  3375. private _byteTime;
  3376. private _floatFreqs;
  3377. private _webAudioAnalyser;
  3378. private _debugCanvas;
  3379. private _debugCanvasContext;
  3380. private _scene;
  3381. private _registerFunc;
  3382. private _audioEngine;
  3383. /**
  3384. * Creates a new analyser
  3385. * @param scene defines hosting scene
  3386. */
  3387. constructor(scene: Scene);
  3388. /**
  3389. * Get the number of data values you will have to play with for the visualization
  3390. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  3391. * @returns a number
  3392. */
  3393. getFrequencyBinCount(): number;
  3394. /**
  3395. * Gets the current frequency data as a byte array
  3396. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  3397. * @returns a Uint8Array
  3398. */
  3399. getByteFrequencyData(): Uint8Array;
  3400. /**
  3401. * Gets the current waveform as a byte array
  3402. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  3403. * @returns a Uint8Array
  3404. */
  3405. getByteTimeDomainData(): Uint8Array;
  3406. /**
  3407. * Gets the current frequency data as a float array
  3408. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  3409. * @returns a Float32Array
  3410. */
  3411. getFloatFrequencyData(): Float32Array;
  3412. /**
  3413. * Renders the debug canvas
  3414. */
  3415. drawDebugCanvas(): void;
  3416. /**
  3417. * Stops rendering the debug canvas and removes it
  3418. */
  3419. stopDebugCanvas(): void;
  3420. /**
  3421. * Connects two audio nodes
  3422. * @param inputAudioNode defines first node to connect
  3423. * @param outputAudioNode defines second node to connect
  3424. */
  3425. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  3426. /**
  3427. * Releases all associated resources
  3428. */
  3429. dispose(): void;
  3430. }
  3431. }
  3432. declare module BABYLON {
  3433. class AudioEngine {
  3434. private _audioContext;
  3435. private _audioContextInitialized;
  3436. canUseWebAudio: boolean;
  3437. masterGain: GainNode;
  3438. private _connectedAnalyser;
  3439. WarnedWebAudioUnsupported: boolean;
  3440. unlocked: boolean;
  3441. onAudioUnlocked: () => any;
  3442. isMP3supported: boolean;
  3443. isOGGsupported: boolean;
  3444. readonly audioContext: Nullable<AudioContext>;
  3445. constructor();
  3446. private _unlockiOSaudio();
  3447. private _initializeAudioContext();
  3448. dispose(): void;
  3449. getGlobalVolume(): number;
  3450. setGlobalVolume(newVolume: number): void;
  3451. connectToAnalyser(analyser: Analyser): void;
  3452. }
  3453. }
  3454. declare module BABYLON {
  3455. class Sound {
  3456. name: string;
  3457. autoplay: boolean;
  3458. loop: boolean;
  3459. useCustomAttenuation: boolean;
  3460. soundTrackId: number;
  3461. spatialSound: boolean;
  3462. refDistance: number;
  3463. rolloffFactor: number;
  3464. maxDistance: number;
  3465. distanceModel: string;
  3466. private _panningModel;
  3467. onended: () => any;
  3468. private _playbackRate;
  3469. private _streaming;
  3470. private _startTime;
  3471. private _startOffset;
  3472. private _position;
  3473. private _localDirection;
  3474. private _volume;
  3475. private _isReadyToPlay;
  3476. isPlaying: boolean;
  3477. isPaused: boolean;
  3478. private _isDirectional;
  3479. private _readyToPlayCallback;
  3480. private _audioBuffer;
  3481. private _soundSource;
  3482. private _streamingSource;
  3483. private _soundPanner;
  3484. private _soundGain;
  3485. private _inputAudioNode;
  3486. private _ouputAudioNode;
  3487. private _coneInnerAngle;
  3488. private _coneOuterAngle;
  3489. private _coneOuterGain;
  3490. private _scene;
  3491. private _connectedMesh;
  3492. private _customAttenuationFunction;
  3493. private _registerFunc;
  3494. private _isOutputConnected;
  3495. private _htmlAudioElement;
  3496. private _urlType;
  3497. /**
  3498. * Create a sound and attach it to a scene
  3499. * @param name Name of your sound
  3500. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer
  3501. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  3502. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  3503. */
  3504. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: any);
  3505. dispose(): void;
  3506. isReady(): boolean;
  3507. private _soundLoaded(audioData);
  3508. setAudioBuffer(audioBuffer: AudioBuffer): void;
  3509. updateOptions(options: any): void;
  3510. private _createSpatialParameters();
  3511. private _updateSpatialParameters();
  3512. switchPanningModelToHRTF(): void;
  3513. switchPanningModelToEqualPower(): void;
  3514. private _switchPanningModel();
  3515. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  3516. /**
  3517. * Transform this sound into a directional source
  3518. * @param coneInnerAngle Size of the inner cone in degree
  3519. * @param coneOuterAngle Size of the outer cone in degree
  3520. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  3521. */
  3522. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  3523. setPosition(newPosition: Vector3): void;
  3524. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  3525. private _updateDirection();
  3526. updateDistanceFromListener(): void;
  3527. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  3528. /**
  3529. * Play the sound
  3530. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  3531. * @param offset (optional) Start the sound setting it at a specific time
  3532. */
  3533. play(time?: number, offset?: number): void;
  3534. private _onended();
  3535. /**
  3536. * Stop the sound
  3537. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  3538. */
  3539. stop(time?: number): void;
  3540. pause(): void;
  3541. setVolume(newVolume: number, time?: number): void;
  3542. setPlaybackRate(newPlaybackRate: number): void;
  3543. getVolume(): number;
  3544. attachToMesh(meshToConnectTo: AbstractMesh): void;
  3545. detachFromMesh(): void;
  3546. private _onRegisterAfterWorldMatrixUpdate(node);
  3547. clone(): Nullable<Sound>;
  3548. getAudioBuffer(): AudioBuffer | null;
  3549. serialize(): any;
  3550. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  3551. }
  3552. }
  3553. declare module BABYLON {
  3554. class SoundTrack {
  3555. private _outputAudioNode;
  3556. private _scene;
  3557. id: number;
  3558. soundCollection: Array<Sound>;
  3559. private _isMainTrack;
  3560. private _connectedAnalyser;
  3561. private _options;
  3562. private _isInitialized;
  3563. constructor(scene: Scene, options?: any);
  3564. private _initializeSoundTrackAudioGraph();
  3565. dispose(): void;
  3566. AddSound(sound: Sound): void;
  3567. RemoveSound(sound: Sound): void;
  3568. setVolume(newVolume: number): void;
  3569. switchPanningModelToHRTF(): void;
  3570. switchPanningModelToEqualPower(): void;
  3571. connectToAnalyser(analyser: Analyser): void;
  3572. }
  3573. }
  3574. declare module BABYLON {
  3575. class Animatable {
  3576. target: any;
  3577. fromFrame: number;
  3578. toFrame: number;
  3579. loopAnimation: boolean;
  3580. onAnimationEnd: (() => void) | null | undefined;
  3581. private _localDelayOffset;
  3582. private _pausedDelay;
  3583. private _runtimeAnimations;
  3584. private _paused;
  3585. private _scene;
  3586. private _speedRatio;
  3587. private _weight;
  3588. private _syncRoot;
  3589. animationStarted: boolean;
  3590. /**
  3591. * Observer raised when the animation ends
  3592. */
  3593. onAnimationEndObservable: Observable<Animatable>;
  3594. /**
  3595. * Gets the root Animatable used to synchronize and normalize animations
  3596. */
  3597. readonly syncRoot: Animatable;
  3598. /**
  3599. * Gets the current frame of the first RuntimeAnimation
  3600. * Used to synchronize Animatables
  3601. */
  3602. readonly masterFrame: number;
  3603. /**
  3604. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  3605. */
  3606. weight: number;
  3607. /**
  3608. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  3609. */
  3610. speedRatio: number;
  3611. constructor(scene: Scene, target: any, fromFrame?: number, toFrame?: number, loopAnimation?: boolean, speedRatio?: number, onAnimationEnd?: (() => void) | null | undefined, animations?: any);
  3612. /**
  3613. * Synchronize and normalize current Animatable with a source Animatable
  3614. * This is useful when using animation weights and when animations are not of the same length
  3615. * @param root defines the root Animatable to synchronize with
  3616. * @returns the current Animatable
  3617. */
  3618. syncWith(root: Animatable): Animatable;
  3619. getAnimations(): RuntimeAnimation[];
  3620. appendAnimations(target: any, animations: Animation[]): void;
  3621. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  3622. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  3623. reset(): void;
  3624. enableBlending(blendingSpeed: number): void;
  3625. disableBlending(): void;
  3626. goToFrame(frame: number): void;
  3627. pause(): void;
  3628. restart(): void;
  3629. private _raiseOnAnimationEnd();
  3630. stop(animationName?: string): void;
  3631. /**
  3632. * Wait asynchronously for the animation to end
  3633. * @returns a promise which will be fullfilled when the animation ends
  3634. */
  3635. waitAsync(): Promise<Animatable>;
  3636. /** @hidden */
  3637. _animate(delay: number): boolean;
  3638. }
  3639. }
  3640. declare module BABYLON {
  3641. /**
  3642. * Represents the range of an animation
  3643. */
  3644. class AnimationRange {
  3645. /**The name of the animation range**/
  3646. name: string;
  3647. /**The starting frame of the animation */
  3648. from: number;
  3649. /**The ending frame of the animation*/
  3650. to: number;
  3651. /**
  3652. * Initializes the range of an animation
  3653. * @param name The name of the animation range
  3654. * @param from The starting frame of the animation
  3655. * @param to The ending frame of the animation
  3656. */
  3657. constructor(
  3658. /**The name of the animation range**/
  3659. name: string,
  3660. /**The starting frame of the animation */
  3661. from: number,
  3662. /**The ending frame of the animation*/
  3663. to: number);
  3664. /**
  3665. * Makes a copy of the animation range
  3666. * @returns A copy of the animation range
  3667. */
  3668. clone(): AnimationRange;
  3669. }
  3670. /**
  3671. * Composed of a frame, and an action function
  3672. */
  3673. class AnimationEvent {
  3674. /** The frame for which the event is triggered **/
  3675. frame: number;
  3676. /** The event to perform when triggered **/
  3677. action: () => void;
  3678. /** Specifies if the event should be triggered only once**/
  3679. onlyOnce: boolean | undefined;
  3680. /**
  3681. * Specifies if the animation event is done
  3682. */
  3683. isDone: boolean;
  3684. /**
  3685. * Initializes the animation event
  3686. * @param frame The frame for which the event is triggered
  3687. * @param action The event to perform when triggered
  3688. * @param onlyOnce Specifies if the event should be triggered only once
  3689. */
  3690. constructor(
  3691. /** The frame for which the event is triggered **/
  3692. frame: number,
  3693. /** The event to perform when triggered **/
  3694. action: () => void,
  3695. /** Specifies if the event should be triggered only once**/
  3696. onlyOnce?: boolean | undefined);
  3697. /** @hidden */
  3698. _clone(): AnimationEvent;
  3699. }
  3700. /**
  3701. * A cursor which tracks a point on a path
  3702. */
  3703. class PathCursor {
  3704. private path;
  3705. /**
  3706. * Stores path cursor callbacks for when an onchange event is triggered
  3707. */
  3708. private _onchange;
  3709. /**
  3710. * The value of the path cursor
  3711. */
  3712. value: number;
  3713. /**
  3714. * The animation array of the path cursor
  3715. */
  3716. animations: Animation[];
  3717. /**
  3718. * Initializes the path cursor
  3719. * @param path The path to track
  3720. */
  3721. constructor(path: Path2);
  3722. /**
  3723. * Gets the cursor point on the path
  3724. * @returns A point on the path cursor at the cursor location
  3725. */
  3726. getPoint(): Vector3;
  3727. /**
  3728. * Moves the cursor ahead by the step amount
  3729. * @param step The amount to move the cursor forward
  3730. * @returns This path cursor
  3731. */
  3732. moveAhead(step?: number): PathCursor;
  3733. /**
  3734. * Moves the cursor behind by the step amount
  3735. * @param step The amount to move the cursor back
  3736. * @returns This path cursor
  3737. */
  3738. moveBack(step?: number): PathCursor;
  3739. /**
  3740. * Moves the cursor by the step amount
  3741. * If the step amount is greater than one, an exception is thrown
  3742. * @param step The amount to move the cursor
  3743. * @returns This path cursor
  3744. */
  3745. move(step: number): PathCursor;
  3746. /**
  3747. * Ensures that the value is limited between zero and one
  3748. * @returns This path cursor
  3749. */
  3750. private ensureLimits();
  3751. /**
  3752. * Runs onchange callbacks on change (used by the animation engine)
  3753. * @returns This path cursor
  3754. */
  3755. private raiseOnChange();
  3756. /**
  3757. * Executes a function on change
  3758. * @param f A path cursor onchange callback
  3759. * @returns This path cursor
  3760. */
  3761. onchange(f: (cursor: PathCursor) => void): PathCursor;
  3762. }
  3763. /**
  3764. * Defines an interface which represents an animation key frame
  3765. */
  3766. interface IAnimationKey {
  3767. /**
  3768. * Frame of the key frame
  3769. */
  3770. frame: number;
  3771. /**
  3772. * Value at the specifies key frame
  3773. */
  3774. value: any;
  3775. /**
  3776. * The input tangent for the cubic hermite spline
  3777. */
  3778. inTangent?: any;
  3779. /**
  3780. * The output tangent for the cubic hermite spline
  3781. */
  3782. outTangent?: any;
  3783. /**
  3784. * The animation interpolation type
  3785. */
  3786. interpolation?: AnimationKeyInterpolation;
  3787. }
  3788. /**
  3789. * Enum for the animation key frame interpolation type
  3790. */
  3791. enum AnimationKeyInterpolation {
  3792. /**
  3793. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  3794. */
  3795. STEP = 1,
  3796. }
  3797. /**
  3798. * Class used to store any kind of animation
  3799. */
  3800. class Animation {
  3801. /**Name of the animation */
  3802. name: string;
  3803. /**Property to animate */
  3804. targetProperty: string;
  3805. /**The frames per second of the animation */
  3806. framePerSecond: number;
  3807. /**The data type of the animation */
  3808. dataType: number;
  3809. /**The loop mode of the animation */
  3810. loopMode: number | undefined;
  3811. /**Specifies if blending should be enabled */
  3812. enableBlending: boolean | undefined;
  3813. /**
  3814. * Use matrix interpolation instead of using direct key value when animating matrices
  3815. */
  3816. static AllowMatricesInterpolation: boolean;
  3817. /**
  3818. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  3819. */
  3820. static AllowMatrixDecomposeForInterpolation: boolean;
  3821. /**
  3822. * Stores the key frames of the animation
  3823. */
  3824. private _keys;
  3825. /**
  3826. * Stores the easing function of the animation
  3827. */
  3828. private _easingFunction;
  3829. /**
  3830. * @hidden Internal use only
  3831. */
  3832. _runtimeAnimations: RuntimeAnimation[];
  3833. /**
  3834. * The set of event that will be linked to this animation
  3835. */
  3836. private _events;
  3837. /**
  3838. * Stores an array of target property paths
  3839. */
  3840. targetPropertyPath: string[];
  3841. /**
  3842. * Stores the blending speed of the animation
  3843. */
  3844. blendingSpeed: number;
  3845. /**
  3846. * Stores the animation ranges for the animation
  3847. */
  3848. private _ranges;
  3849. /**
  3850. * @hidden Internal use
  3851. */
  3852. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  3853. /**
  3854. * Sets up an animation
  3855. * @param property The property to animate
  3856. * @param animationType The animation type to apply
  3857. * @param framePerSecond The frames per second of the animation
  3858. * @param easingFunction The easing function used in the animation
  3859. * @returns The created animation
  3860. */
  3861. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  3862. /**
  3863. * Create and start an animation on a node
  3864. * @param name defines the name of the global animation that will be run on all nodes
  3865. * @param node defines the root node where the animation will take place
  3866. * @param targetProperty defines property to animate
  3867. * @param framePerSecond defines the number of frame per second yo use
  3868. * @param totalFrame defines the number of frames in total
  3869. * @param from defines the initial value
  3870. * @param to defines the final value
  3871. * @param loopMode defines which loop mode you want to use (off by default)
  3872. * @param easingFunction defines the easing function to use (linear by default)
  3873. * @param onAnimationEnd defines the callback to call when animation end
  3874. * @returns the animatable created for this animation
  3875. */
  3876. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  3877. /**
  3878. * Create and start an animation on a node and its descendants
  3879. * @param name defines the name of the global animation that will be run on all nodes
  3880. * @param node defines the root node where the animation will take place
  3881. * @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
  3882. * @param targetProperty defines property to animate
  3883. * @param framePerSecond defines the number of frame per second to use
  3884. * @param totalFrame defines the number of frames in total
  3885. * @param from defines the initial value
  3886. * @param to defines the final value
  3887. * @param loopMode defines which loop mode you want to use (off by default)
  3888. * @param easingFunction defines the easing function to use (linear by default)
  3889. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  3890. * @returns the list of animatables created for all nodes
  3891. * @example https://www.babylonjs-playground.com/#MH0VLI
  3892. */
  3893. 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[]>;
  3894. /**
  3895. * Creates a new animation, merges it with the existing animations and starts it
  3896. * @param name Name of the animation
  3897. * @param node Node which contains the scene that begins the animations
  3898. * @param targetProperty Specifies which property to animate
  3899. * @param framePerSecond The frames per second of the animation
  3900. * @param totalFrame The total number of frames
  3901. * @param from The frame at the beginning of the animation
  3902. * @param to The frame at the end of the animation
  3903. * @param loopMode Specifies the loop mode of the animation
  3904. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  3905. * @param onAnimationEnd Callback to run once the animation is complete
  3906. * @returns Nullable animation
  3907. */
  3908. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  3909. /**
  3910. * Transition property of an host to the target Value
  3911. * @param property The property to transition
  3912. * @param targetValue The target Value of the property
  3913. * @param host The object where the property to animate belongs
  3914. * @param scene Scene used to run the animation
  3915. * @param frameRate Framerate (in frame/s) to use
  3916. * @param transition The transition type we want to use
  3917. * @param duration The duration of the animation, in milliseconds
  3918. * @param onAnimationEnd Callback trigger at the end of the animation
  3919. * @returns Nullable animation
  3920. */
  3921. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  3922. /**
  3923. * Return the array of runtime animations currently using this animation
  3924. */
  3925. readonly runtimeAnimations: RuntimeAnimation[];
  3926. /**
  3927. * Specifies if any of the runtime animations are currently running
  3928. */
  3929. readonly hasRunningRuntimeAnimations: boolean;
  3930. /**
  3931. * Initializes the animation
  3932. * @param name Name of the animation
  3933. * @param targetProperty Property to animate
  3934. * @param framePerSecond The frames per second of the animation
  3935. * @param dataType The data type of the animation
  3936. * @param loopMode The loop mode of the animation
  3937. * @param enableBlendings Specifies if blending should be enabled
  3938. */
  3939. constructor(
  3940. /**Name of the animation */
  3941. name: string,
  3942. /**Property to animate */
  3943. targetProperty: string,
  3944. /**The frames per second of the animation */
  3945. framePerSecond: number,
  3946. /**The data type of the animation */
  3947. dataType: number,
  3948. /**The loop mode of the animation */
  3949. loopMode?: number | undefined,
  3950. /**Specifies if blending should be enabled */
  3951. enableBlending?: boolean | undefined);
  3952. /**
  3953. * Converts the animation to a string
  3954. * @param fullDetails support for multiple levels of logging within scene loading
  3955. * @returns String form of the animation
  3956. */
  3957. toString(fullDetails?: boolean): string;
  3958. /**
  3959. * Add an event to this animation
  3960. * @param event Event to add
  3961. */
  3962. addEvent(event: AnimationEvent): void;
  3963. /**
  3964. * Remove all events found at the given frame
  3965. * @param frame The frame to remove events from
  3966. */
  3967. removeEvents(frame: number): void;
  3968. /**
  3969. * Retrieves all the events from the animation
  3970. * @returns Events from the animation
  3971. */
  3972. getEvents(): AnimationEvent[];
  3973. /**
  3974. * Creates an animation range
  3975. * @param name Name of the animation range
  3976. * @param from Starting frame of the animation range
  3977. * @param to Ending frame of the animation
  3978. */
  3979. createRange(name: string, from: number, to: number): void;
  3980. /**
  3981. * Deletes an animation range by name
  3982. * @param name Name of the animation range to delete
  3983. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  3984. */
  3985. deleteRange(name: string, deleteFrames?: boolean): void;
  3986. /**
  3987. * Gets the animation range by name, or null if not defined
  3988. * @param name Name of the animation range
  3989. * @returns Nullable animation range
  3990. */
  3991. getRange(name: string): Nullable<AnimationRange>;
  3992. /**
  3993. * Gets the key frames from the animation
  3994. * @returns The key frames of the animation
  3995. */
  3996. getKeys(): Array<IAnimationKey>;
  3997. /**
  3998. * Gets the highest frame rate of the animation
  3999. * @returns Highest frame rate of the animation
  4000. */
  4001. getHighestFrame(): number;
  4002. /**
  4003. * Gets the easing function of the animation
  4004. * @returns Easing function of the animation
  4005. */
  4006. getEasingFunction(): IEasingFunction;
  4007. /**
  4008. * Sets the easing function of the animation
  4009. * @param easingFunction A custom mathematical formula for animation
  4010. */
  4011. setEasingFunction(easingFunction: EasingFunction): void;
  4012. /**
  4013. * Interpolates a scalar linearly
  4014. * @param startValue Start value of the animation curve
  4015. * @param endValue End value of the animation curve
  4016. * @param gradient Scalar amount to interpolate
  4017. * @returns Interpolated scalar value
  4018. */
  4019. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  4020. /**
  4021. * Interpolates a scalar cubically
  4022. * @param startValue Start value of the animation curve
  4023. * @param outTangent End tangent of the animation
  4024. * @param endValue End value of the animation curve
  4025. * @param inTangent Start tangent of the animation curve
  4026. * @param gradient Scalar amount to interpolate
  4027. * @returns Interpolated scalar value
  4028. */
  4029. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  4030. /**
  4031. * Interpolates a quaternion using a spherical linear interpolation
  4032. * @param startValue Start value of the animation curve
  4033. * @param endValue End value of the animation curve
  4034. * @param gradient Scalar amount to interpolate
  4035. * @returns Interpolated quaternion value
  4036. */
  4037. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  4038. /**
  4039. * Interpolates a quaternion cubically
  4040. * @param startValue Start value of the animation curve
  4041. * @param outTangent End tangent of the animation curve
  4042. * @param endValue End value of the animation curve
  4043. * @param inTangent Start tangent of the animation curve
  4044. * @param gradient Scalar amount to interpolate
  4045. * @returns Interpolated quaternion value
  4046. */
  4047. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  4048. /**
  4049. * Interpolates a Vector3 linearl
  4050. * @param startValue Start value of the animation curve
  4051. * @param endValue End value of the animation curve
  4052. * @param gradient Scalar amount to interpolate
  4053. * @returns Interpolated scalar value
  4054. */
  4055. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  4056. /**
  4057. * Interpolates a Vector3 cubically
  4058. * @param startValue Start value of the animation curve
  4059. * @param outTangent End tangent of the animation
  4060. * @param endValue End value of the animation curve
  4061. * @param inTangent Start tangent of the animation curve
  4062. * @param gradient Scalar amount to interpolate
  4063. * @returns InterpolatedVector3 value
  4064. */
  4065. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  4066. /**
  4067. * Interpolates a Vector2 linearly
  4068. * @param startValue Start value of the animation curve
  4069. * @param endValue End value of the animation curve
  4070. * @param gradient Scalar amount to interpolate
  4071. * @returns Interpolated Vector2 value
  4072. */
  4073. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  4074. /**
  4075. * Interpolates a Vector2 cubically
  4076. * @param startValue Start value of the animation curve
  4077. * @param outTangent End tangent of the animation
  4078. * @param endValue End value of the animation curve
  4079. * @param inTangent Start tangent of the animation curve
  4080. * @param gradient Scalar amount to interpolate
  4081. * @returns Interpolated Vector2 value
  4082. */
  4083. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  4084. /**
  4085. * Interpolates a size linearly
  4086. * @param startValue Start value of the animation curve
  4087. * @param endValue End value of the animation curve
  4088. * @param gradient Scalar amount to interpolate
  4089. * @returns Interpolated Size value
  4090. */
  4091. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  4092. /**
  4093. * Interpolates a Color3 linearly
  4094. * @param startValue Start value of the animation curve
  4095. * @param endValue End value of the animation curve
  4096. * @param gradient Scalar amount to interpolate
  4097. * @returns Interpolated Color3 value
  4098. */
  4099. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  4100. /**
  4101. * @hidden Internal use only
  4102. */
  4103. _getKeyValue(value: any): any;
  4104. /**
  4105. * @hidden Internal use only
  4106. */
  4107. _interpolate(currentFrame: number, repeatCount: number, workValue?: any, loopMode?: number, offsetValue?: any, highLimitValue?: any): any;
  4108. /**
  4109. * Defines the function to use to interpolate matrices
  4110. * @param startValue defines the start matrix
  4111. * @param endValue defines the end matrix
  4112. * @param gradient defines the gradient between both matrices
  4113. * @param result defines an optional target matrix where to store the interpolation
  4114. * @returns the interpolated matrix
  4115. */
  4116. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  4117. /**
  4118. * Makes a copy of the animation
  4119. * @returns Cloned animation
  4120. */
  4121. clone(): Animation;
  4122. /**
  4123. * Sets the key frames of the animation
  4124. * @param values The animation key frames to set
  4125. */
  4126. setKeys(values: Array<IAnimationKey>): void;
  4127. /**
  4128. * Serializes the animation to an object
  4129. * @returns Serialized object
  4130. */
  4131. serialize(): any;
  4132. /**
  4133. * Float animation type
  4134. */
  4135. private static _ANIMATIONTYPE_FLOAT;
  4136. /**
  4137. * Vector3 animation type
  4138. */
  4139. private static _ANIMATIONTYPE_VECTOR3;
  4140. /**
  4141. * Quaternion animation type
  4142. */
  4143. private static _ANIMATIONTYPE_QUATERNION;
  4144. /**
  4145. * Matrix animation type
  4146. */
  4147. private static _ANIMATIONTYPE_MATRIX;
  4148. /**
  4149. * Color3 animation type
  4150. */
  4151. private static _ANIMATIONTYPE_COLOR3;
  4152. /**
  4153. * Vector2 animation type
  4154. */
  4155. private static _ANIMATIONTYPE_VECTOR2;
  4156. /**
  4157. * Size animation type
  4158. */
  4159. private static _ANIMATIONTYPE_SIZE;
  4160. /**
  4161. * Relative Loop Mode
  4162. */
  4163. private static _ANIMATIONLOOPMODE_RELATIVE;
  4164. /**
  4165. * Cycle Loop Mode
  4166. */
  4167. private static _ANIMATIONLOOPMODE_CYCLE;
  4168. /**
  4169. * Constant Loop Mode
  4170. */
  4171. private static _ANIMATIONLOOPMODE_CONSTANT;
  4172. /**
  4173. * Get the float animation type
  4174. */
  4175. static readonly ANIMATIONTYPE_FLOAT: number;
  4176. /**
  4177. * Get the Vector3 animation type
  4178. */
  4179. static readonly ANIMATIONTYPE_VECTOR3: number;
  4180. /**
  4181. * Get the Vectpr2 animation type
  4182. */
  4183. static readonly ANIMATIONTYPE_VECTOR2: number;
  4184. /**
  4185. * Get the Size animation type
  4186. */
  4187. static readonly ANIMATIONTYPE_SIZE: number;
  4188. /**
  4189. * Get the Quaternion animation type
  4190. */
  4191. static readonly ANIMATIONTYPE_QUATERNION: number;
  4192. /**
  4193. * Get the Matrix animation type
  4194. */
  4195. static readonly ANIMATIONTYPE_MATRIX: number;
  4196. /**
  4197. * Get the Color3 animation type
  4198. */
  4199. static readonly ANIMATIONTYPE_COLOR3: number;
  4200. /**
  4201. * Get the Relative Loop Mode
  4202. */
  4203. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  4204. /**
  4205. * Get the Cycle Loop Mode
  4206. */
  4207. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  4208. /**
  4209. * Get the Constant Loop Mode
  4210. */
  4211. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  4212. /** @hidden */
  4213. static _UniversalLerp(left: any, right: any, amount: number): any;
  4214. /**
  4215. * Parses an animation object and creates an animation
  4216. * @param parsedAnimation Parsed animation object
  4217. * @returns Animation object
  4218. */
  4219. static Parse(parsedAnimation: any): Animation;
  4220. /**
  4221. * Appends the serialized animations from the source animations
  4222. * @param source Source containing the animations
  4223. * @param destination Target to store the animations
  4224. */
  4225. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  4226. }
  4227. }
  4228. declare module BABYLON {
  4229. /**
  4230. * This class defines the direct association between an animation and a target
  4231. */
  4232. class TargetedAnimation {
  4233. animation: Animation;
  4234. target: any;
  4235. }
  4236. /**
  4237. * Use this class to create coordinated animations on multiple targets
  4238. */
  4239. class AnimationGroup implements IDisposable {
  4240. name: string;
  4241. private _scene;
  4242. private _targetedAnimations;
  4243. private _animatables;
  4244. private _from;
  4245. private _to;
  4246. private _isStarted;
  4247. private _speedRatio;
  4248. onAnimationEndObservable: Observable<TargetedAnimation>;
  4249. /**
  4250. * This observable will notify when all animations have ended.
  4251. */
  4252. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  4253. /**
  4254. * Gets the first frame
  4255. */
  4256. readonly from: number;
  4257. /**
  4258. * Gets the last frame
  4259. */
  4260. readonly to: number;
  4261. /**
  4262. * Define if the animations are started
  4263. */
  4264. readonly isStarted: boolean;
  4265. /**
  4266. * Gets or sets the speed ratio to use for all animations
  4267. */
  4268. /**
  4269. * Gets or sets the speed ratio to use for all animations
  4270. */
  4271. speedRatio: number;
  4272. /**
  4273. * Gets the targeted animations for this animation group
  4274. */
  4275. readonly targetedAnimations: Array<TargetedAnimation>;
  4276. /**
  4277. * returning the list of animatables controlled by this animation group.
  4278. */
  4279. readonly animatables: Array<Animatable>;
  4280. constructor(name: string, scene?: Nullable<Scene>);
  4281. /**
  4282. * Add an animation (with its target) in the group
  4283. * @param animation defines the animation we want to add
  4284. * @param target defines the target of the animation
  4285. * @returns the {BABYLON.TargetedAnimation} object
  4286. */
  4287. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  4288. /**
  4289. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  4290. * It can add constant keys at begin or end
  4291. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  4292. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  4293. */
  4294. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  4295. /**
  4296. * Start all animations on given targets
  4297. * @param loop defines if animations must loop
  4298. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  4299. * @param from defines the from key (optional)
  4300. * @param to defines the to key (optional)
  4301. * @returns the current animation group
  4302. */
  4303. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  4304. /**
  4305. * Pause all animations
  4306. */
  4307. pause(): AnimationGroup;
  4308. /**
  4309. * Play all animations to initial state
  4310. * This function will start() the animations if they were not started or will restart() them if they were paused
  4311. * @param loop defines if animations must loop
  4312. */
  4313. play(loop?: boolean): AnimationGroup;
  4314. /**
  4315. * Reset all animations to initial state
  4316. */
  4317. reset(): AnimationGroup;
  4318. /**
  4319. * Restart animations from key 0
  4320. */
  4321. restart(): AnimationGroup;
  4322. /**
  4323. * Stop all animations
  4324. */
  4325. stop(): AnimationGroup;
  4326. /**
  4327. * Set animation weight for all animatables
  4328. * @param weight defines the weight to use
  4329. * @return the animationGroup
  4330. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  4331. */
  4332. setWeightForAllAnimatables(weight: number): AnimationGroup;
  4333. /**
  4334. * Synchronize and normalize all animatables with a source animatable
  4335. * @param root defines the root animatable to synchronize with
  4336. * @return the animationGroup
  4337. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  4338. */
  4339. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  4340. /**
  4341. * Goes to a specific frame in this animation group
  4342. * @param frame the frame number to go to
  4343. * @return the animationGroup
  4344. */
  4345. goToFrame(frame: number): AnimationGroup;
  4346. /**
  4347. * Dispose all associated resources
  4348. */
  4349. dispose(): void;
  4350. private _checkAnimationGroupEnded(animatable);
  4351. }
  4352. }
  4353. declare module BABYLON {
  4354. /**
  4355. * Class used to override all child animations of a given target
  4356. */
  4357. class AnimationPropertiesOverride {
  4358. /**
  4359. * Gets or sets a value indicating if animation blending must be used
  4360. */
  4361. enableBlending: boolean;
  4362. /**
  4363. * Gets or sets the blending speed to use when enableBlending is true
  4364. */
  4365. blendingSpeed: number;
  4366. /**
  4367. * Gets or sets the default loop mode to use
  4368. */
  4369. loopMode: number;
  4370. }
  4371. }
  4372. declare module BABYLON {
  4373. interface IEasingFunction {
  4374. ease(gradient: number): number;
  4375. }
  4376. class EasingFunction implements IEasingFunction {
  4377. private static _EASINGMODE_EASEIN;
  4378. private static _EASINGMODE_EASEOUT;
  4379. private static _EASINGMODE_EASEINOUT;
  4380. static readonly EASINGMODE_EASEIN: number;
  4381. static readonly EASINGMODE_EASEOUT: number;
  4382. static readonly EASINGMODE_EASEINOUT: number;
  4383. private _easingMode;
  4384. setEasingMode(easingMode: number): void;
  4385. getEasingMode(): number;
  4386. easeInCore(gradient: number): number;
  4387. ease(gradient: number): number;
  4388. }
  4389. class CircleEase extends EasingFunction implements IEasingFunction {
  4390. easeInCore(gradient: number): number;
  4391. }
  4392. class BackEase extends EasingFunction implements IEasingFunction {
  4393. amplitude: number;
  4394. constructor(amplitude?: number);
  4395. easeInCore(gradient: number): number;
  4396. }
  4397. class BounceEase extends EasingFunction implements IEasingFunction {
  4398. bounces: number;
  4399. bounciness: number;
  4400. constructor(bounces?: number, bounciness?: number);
  4401. easeInCore(gradient: number): number;
  4402. }
  4403. class CubicEase extends EasingFunction implements IEasingFunction {
  4404. easeInCore(gradient: number): number;
  4405. }
  4406. class ElasticEase extends EasingFunction implements IEasingFunction {
  4407. oscillations: number;
  4408. springiness: number;
  4409. constructor(oscillations?: number, springiness?: number);
  4410. easeInCore(gradient: number): number;
  4411. }
  4412. class ExponentialEase extends EasingFunction implements IEasingFunction {
  4413. exponent: number;
  4414. constructor(exponent?: number);
  4415. easeInCore(gradient: number): number;
  4416. }
  4417. class PowerEase extends EasingFunction implements IEasingFunction {
  4418. power: number;
  4419. constructor(power?: number);
  4420. easeInCore(gradient: number): number;
  4421. }
  4422. class QuadraticEase extends EasingFunction implements IEasingFunction {
  4423. easeInCore(gradient: number): number;
  4424. }
  4425. class QuarticEase extends EasingFunction implements IEasingFunction {
  4426. easeInCore(gradient: number): number;
  4427. }
  4428. class QuinticEase extends EasingFunction implements IEasingFunction {
  4429. easeInCore(gradient: number): number;
  4430. }
  4431. class SineEase extends EasingFunction implements IEasingFunction {
  4432. easeInCore(gradient: number): number;
  4433. }
  4434. class BezierCurveEase extends EasingFunction implements IEasingFunction {
  4435. x1: number;
  4436. y1: number;
  4437. x2: number;
  4438. y2: number;
  4439. constructor(x1?: number, y1?: number, x2?: number, y2?: number);
  4440. easeInCore(gradient: number): number;
  4441. }
  4442. }
  4443. declare module BABYLON {
  4444. /**
  4445. * Defines a runtime animation
  4446. */
  4447. class RuntimeAnimation {
  4448. private _events;
  4449. /**
  4450. * The current frame of the runtime animation
  4451. */
  4452. private _currentFrame;
  4453. /**
  4454. * The animation used by the runtime animation
  4455. */
  4456. private _animation;
  4457. /**
  4458. * The target of the runtime animation
  4459. */
  4460. private _target;
  4461. /**
  4462. * The initiating animatable
  4463. */
  4464. private _host;
  4465. /**
  4466. * The original value of the runtime animation
  4467. */
  4468. private _originalValue;
  4469. /**
  4470. * The original blend value of the runtime animation
  4471. */
  4472. private _originalBlendValue;
  4473. /**
  4474. * The offsets cache of the runtime animation
  4475. */
  4476. private _offsetsCache;
  4477. /**
  4478. * The high limits cache of the runtime animation
  4479. */
  4480. private _highLimitsCache;
  4481. /**
  4482. * Specifies if the runtime animation has been stopped
  4483. */
  4484. private _stopped;
  4485. /**
  4486. * The blending factor of the runtime animation
  4487. */
  4488. private _blendingFactor;
  4489. /**
  4490. * The BabylonJS scene
  4491. */
  4492. private _scene;
  4493. /**
  4494. * The current value of the runtime animation
  4495. */
  4496. private _currentValue;
  4497. /** @hidden */
  4498. _workValue: any;
  4499. /**
  4500. * The active target of the runtime animation
  4501. */
  4502. private _activeTarget;
  4503. /**
  4504. * The target path of the runtime animation
  4505. */
  4506. private _targetPath;
  4507. /**
  4508. * The weight of the runtime animation
  4509. */
  4510. private _weight;
  4511. /**
  4512. * The ratio offset of the runtime animation
  4513. */
  4514. private _ratioOffset;
  4515. /**
  4516. * The previous delay of the runtime animation
  4517. */
  4518. private _previousDelay;
  4519. /**
  4520. * The previous ratio of the runtime animation
  4521. */
  4522. private _previousRatio;
  4523. /**
  4524. * Gets the current frame of the runtime animation
  4525. */
  4526. readonly currentFrame: number;
  4527. /**
  4528. * Gets the weight of the runtime animation
  4529. */
  4530. readonly weight: number;
  4531. /**
  4532. * Gets the current value of the runtime animation
  4533. */
  4534. readonly currentValue: any;
  4535. /**
  4536. * Gets the target path of the runtime animation
  4537. */
  4538. readonly targetPath: string;
  4539. /**
  4540. * Gets the actual target of the runtime animation
  4541. */
  4542. readonly target: any;
  4543. /**
  4544. * Create a new RuntimeAnimation object
  4545. * @param target defines the target of the animation
  4546. * @param animation defines the source animation object
  4547. * @param scene defines the hosting scene
  4548. * @param host defines the initiating Animatable
  4549. */
  4550. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  4551. /**
  4552. * Gets the animation from the runtime animation
  4553. */
  4554. readonly animation: Animation;
  4555. /**
  4556. * Resets the runtime animation to the beginning
  4557. * @param restoreOriginal defines whether to restore the target property to the original value
  4558. */
  4559. reset(restoreOriginal?: boolean): void;
  4560. /**
  4561. * Specifies if the runtime animation is stopped
  4562. * @returns Boolean specifying if the runtime animation is stopped
  4563. */
  4564. isStopped(): boolean;
  4565. /**
  4566. * Disposes of the runtime animation
  4567. */
  4568. dispose(): void;
  4569. /**
  4570. * Interpolates the animation from the current frame
  4571. * @param currentFrame The frame to interpolate the animation to
  4572. * @param repeatCount The number of times that the animation should loop
  4573. * @param loopMode The type of looping mode to use
  4574. * @param offsetValue Animation offset value
  4575. * @param highLimitValue The high limit value
  4576. * @returns The interpolated value
  4577. */
  4578. private _interpolate(currentFrame, repeatCount, loopMode?, offsetValue?, highLimitValue?);
  4579. /**
  4580. * Apply the interpolated value to the target
  4581. * @param currentValue defines the value computed by the animation
  4582. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  4583. */
  4584. setValue(currentValue: any, weight?: number): void;
  4585. private _setValue(target, currentValue, weight, targetIndex?);
  4586. /**
  4587. * Gets the loop pmode of the runtime animation
  4588. * @returns Loop Mode
  4589. */
  4590. private _getCorrectLoopMode();
  4591. /**
  4592. * Move the current animation to a given frame
  4593. * @param frame defines the frame to move to
  4594. */
  4595. goToFrame(frame: number): void;
  4596. /**
  4597. * @hidden Internal use only
  4598. */
  4599. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  4600. /**
  4601. * Execute the current animation
  4602. * @param delay defines the delay to add to the current frame
  4603. * @param from defines the lower bound of the animation range
  4604. * @param to defines the upper bound of the animation range
  4605. * @param loop defines if the current animation must loop
  4606. * @param speedRatio defines the current speed ratio
  4607. * @param weight defines the weight of the animation (default is -1 so no weight)
  4608. * @returns a boolean indicating if the animation has ended
  4609. */
  4610. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  4611. }
  4612. }
  4613. declare module BABYLON {
  4614. /**
  4615. * Interface used to define a behavior
  4616. */
  4617. interface Behavior<T> {
  4618. /** gets or sets behavior's name */
  4619. name: string;
  4620. /**
  4621. * Function called when the behavior needs to be initialized (after attaching it to a target)
  4622. */
  4623. init(): void;
  4624. /**
  4625. * Called when the behavior is attached to a target
  4626. * @param target defines the target where the behavior is attached to
  4627. */
  4628. attach(target: T): void;
  4629. /**
  4630. * Called when the behavior is detached from its target
  4631. */
  4632. detach(): void;
  4633. }
  4634. /**
  4635. * Interface implemented by classes supporting behaviors
  4636. */
  4637. interface IBehaviorAware<T> {
  4638. /**
  4639. * Attach a behavior
  4640. * @param behavior defines the behavior to attach
  4641. * @returns the current host
  4642. */
  4643. addBehavior(behavior: Behavior<T>): T;
  4644. /**
  4645. * Remove a behavior from the current object
  4646. * @param behavior defines the behavior to detach
  4647. * @returns the current host
  4648. */
  4649. removeBehavior(behavior: Behavior<T>): T;
  4650. /**
  4651. * Gets a behavior using its name to search
  4652. * @param name defines the name to search
  4653. * @returns the behavior or null if not found
  4654. */
  4655. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  4656. }
  4657. }
  4658. declare module BABYLON {
  4659. /**
  4660. * Class used to store bone information
  4661. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  4662. */
  4663. class Bone extends Node {
  4664. /**
  4665. * defines the bone name
  4666. */
  4667. name: string;
  4668. private static _tmpVecs;
  4669. private static _tmpQuat;
  4670. private static _tmpMats;
  4671. /**
  4672. * Gets the list of child bones
  4673. */
  4674. children: Bone[];
  4675. /** Gets the animations associated with this bone */
  4676. animations: Animation[];
  4677. /**
  4678. * Gets or sets bone length
  4679. */
  4680. length: number;
  4681. /**
  4682. * @hidden Internal only
  4683. * Set this value to map this bone to a different index in the transform matrices
  4684. * Set this value to -1 to exclude the bone from the transform matrices
  4685. */
  4686. _index: Nullable<number>;
  4687. private _skeleton;
  4688. private _localMatrix;
  4689. private _restPose;
  4690. private _baseMatrix;
  4691. private _absoluteTransform;
  4692. private _invertedAbsoluteTransform;
  4693. private _parent;
  4694. private _scalingDeterminant;
  4695. private _worldTransform;
  4696. private _localScaling;
  4697. private _localRotation;
  4698. private _localPosition;
  4699. private _needToDecompose;
  4700. private _needToCompose;
  4701. /** @hidden */
  4702. /** @hidden */
  4703. _matrix: Matrix;
  4704. /**
  4705. * Create a new bone
  4706. * @param name defines the bone name
  4707. * @param skeleton defines the parent skeleton
  4708. * @param parentBone defines the parent (can be null if the bone is the root)
  4709. * @param localMatrix defines the local matrix
  4710. * @param restPose defines the rest pose matrix
  4711. * @param baseMatrix defines the base matrix
  4712. * @param index defines index of the bone in the hiearchy
  4713. */
  4714. constructor(
  4715. /**
  4716. * defines the bone name
  4717. */
  4718. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  4719. /**
  4720. * Gets the parent skeleton
  4721. * @returns a skeleton
  4722. */
  4723. getSkeleton(): Skeleton;
  4724. /**
  4725. * Gets parent bone
  4726. * @returns a bone or null if the bone is the root of the bone hierarchy
  4727. */
  4728. getParent(): Nullable<Bone>;
  4729. /**
  4730. * Sets the parent bone
  4731. * @param parent defines the parent (can be null if the bone is the root)
  4732. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  4733. */
  4734. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  4735. /**
  4736. * Gets the local matrix
  4737. * @returns a matrix
  4738. */
  4739. getLocalMatrix(): Matrix;
  4740. /**
  4741. * Gets the base matrix (initial matrix which remains unchanged)
  4742. * @returns a matrix
  4743. */
  4744. getBaseMatrix(): Matrix;
  4745. /**
  4746. * Gets the rest pose matrix
  4747. * @returns a matrix
  4748. */
  4749. getRestPose(): Matrix;
  4750. /**
  4751. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  4752. */
  4753. getWorldMatrix(): Matrix;
  4754. /**
  4755. * Sets the local matrix to rest pose matrix
  4756. */
  4757. returnToRest(): void;
  4758. /**
  4759. * Gets the inverse of the absolute transform matrix.
  4760. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  4761. * @returns a matrix
  4762. */
  4763. getInvertedAbsoluteTransform(): Matrix;
  4764. /**
  4765. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  4766. * @returns a matrix
  4767. */
  4768. getAbsoluteTransform(): Matrix;
  4769. /** Gets or sets current position (in local space) */
  4770. position: Vector3;
  4771. /** Gets or sets current rotation (in local space) */
  4772. rotation: Vector3;
  4773. /** Gets or sets current rotation quaternion (in local space) */
  4774. rotationQuaternion: Quaternion;
  4775. /** Gets or sets current scaling (in local space) */
  4776. scaling: Vector3;
  4777. /**
  4778. * Gets the animation properties override
  4779. */
  4780. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  4781. private _decompose();
  4782. private _compose();
  4783. /**
  4784. * Update the base and local matrices
  4785. * @param matrix defines the new base or local matrix
  4786. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  4787. * @param updateLocalMatrix defines if the local matrix should be updated
  4788. */
  4789. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  4790. /** @hidden */
  4791. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  4792. /**
  4793. * Flag the bone as dirty (Forcing it to update everything)
  4794. */
  4795. markAsDirty(): void;
  4796. private _markAsDirtyAndCompose();
  4797. private _markAsDirtyAndDecompose();
  4798. /**
  4799. * Copy an animation range from another bone
  4800. * @param source defines the source bone
  4801. * @param rangeName defines the range name to copy
  4802. * @param frameOffset defines the frame offset
  4803. * @param rescaleAsRequired defines if rescaling must be applied if required
  4804. * @param skelDimensionsRatio defines the scaling ratio
  4805. * @returns true if operation was successful
  4806. */
  4807. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired?: boolean, skelDimensionsRatio?: Nullable<Vector3>): boolean;
  4808. /**
  4809. * Translate the bone in local or world space
  4810. * @param vec The amount to translate the bone
  4811. * @param space The space that the translation is in
  4812. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4813. */
  4814. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  4815. /**
  4816. * Set the postion of the bone in local or world space
  4817. * @param position The position to set the bone
  4818. * @param space The space that the position is in
  4819. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4820. */
  4821. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  4822. /**
  4823. * Set the absolute position of the bone (world space)
  4824. * @param position The position to set the bone
  4825. * @param mesh The mesh that this bone is attached to
  4826. */
  4827. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  4828. /**
  4829. * Scale the bone on the x, y and z axes (in local space)
  4830. * @param x The amount to scale the bone on the x axis
  4831. * @param y The amount to scale the bone on the y axis
  4832. * @param z The amount to scale the bone on the z axis
  4833. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  4834. */
  4835. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  4836. /**
  4837. * Set the bone scaling in local space
  4838. * @param scale defines the scaling vector
  4839. */
  4840. setScale(scale: Vector3): void;
  4841. /**
  4842. * Gets the current scaling in local space
  4843. * @returns the current scaling vector
  4844. */
  4845. getScale(): Vector3;
  4846. /**
  4847. * Gets the current scaling in local space and stores it in a target vector
  4848. * @param result defines the target vector
  4849. */
  4850. getScaleToRef(result: Vector3): void;
  4851. /**
  4852. * Set the yaw, pitch, and roll of the bone in local or world space
  4853. * @param yaw The rotation of the bone on the y axis
  4854. * @param pitch The rotation of the bone on the x axis
  4855. * @param roll The rotation of the bone on the z axis
  4856. * @param space The space that the axes of rotation are in
  4857. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4858. */
  4859. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  4860. /**
  4861. * Add a rotation to the bone on an axis in local or world space
  4862. * @param axis The axis to rotate the bone on
  4863. * @param amount The amount to rotate the bone
  4864. * @param space The space that the axis is in
  4865. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4866. */
  4867. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  4868. /**
  4869. * Set the rotation of the bone to a particular axis angle in local or world space
  4870. * @param axis The axis to rotate the bone on
  4871. * @param angle The angle that the bone should be rotated to
  4872. * @param space The space that the axis is in
  4873. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4874. */
  4875. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  4876. /**
  4877. * Set the euler rotation of the bone in local of world space
  4878. * @param rotation The euler rotation that the bone should be set to
  4879. * @param space The space that the rotation is in
  4880. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4881. */
  4882. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  4883. /**
  4884. * Set the quaternion rotation of the bone in local of world space
  4885. * @param quat The quaternion rotation that the bone should be set to
  4886. * @param space The space that the rotation is in
  4887. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4888. */
  4889. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  4890. /**
  4891. * Set the rotation matrix of the bone in local of world space
  4892. * @param rotMat The rotation matrix that the bone should be set to
  4893. * @param space The space that the rotation is in
  4894. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4895. */
  4896. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  4897. private _rotateWithMatrix(rmat, space?, mesh?);
  4898. private _getNegativeRotationToRef(rotMatInv, mesh?);
  4899. /**
  4900. * Get the position of the bone in local or world space
  4901. * @param space The space that the returned position is in
  4902. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4903. * @returns The position of the bone
  4904. */
  4905. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  4906. /**
  4907. * Copy the position of the bone to a vector3 in local or world space
  4908. * @param space The space that the returned position is in
  4909. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4910. * @param result The vector3 to copy the position to
  4911. */
  4912. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  4913. /**
  4914. * Get the absolute position of the bone (world space)
  4915. * @param mesh The mesh that this bone is attached to
  4916. * @returns The absolute position of the bone
  4917. */
  4918. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  4919. /**
  4920. * Copy the absolute position of the bone (world space) to the result param
  4921. * @param mesh The mesh that this bone is attached to
  4922. * @param result The vector3 to copy the absolute position to
  4923. */
  4924. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  4925. /**
  4926. * Compute the absolute transforms of this bone and its children
  4927. */
  4928. computeAbsoluteTransforms(): void;
  4929. /**
  4930. * Get the world direction from an axis that is in the local space of the bone
  4931. * @param localAxis The local direction that is used to compute the world direction
  4932. * @param mesh The mesh that this bone is attached to
  4933. * @returns The world direction
  4934. */
  4935. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  4936. /**
  4937. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  4938. * @param localAxis The local direction that is used to compute the world direction
  4939. * @param mesh The mesh that this bone is attached to
  4940. * @param result The vector3 that the world direction will be copied to
  4941. */
  4942. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  4943. /**
  4944. * Get the euler rotation of the bone in local or world space
  4945. * @param space The space that the rotation should be in
  4946. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4947. * @returns The euler rotation
  4948. */
  4949. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  4950. /**
  4951. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  4952. * @param space The space that the rotation should be in
  4953. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4954. * @param result The vector3 that the rotation should be copied to
  4955. */
  4956. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  4957. /**
  4958. * Get the quaternion rotation of the bone in either local or world space
  4959. * @param space The space that the rotation should be in
  4960. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4961. * @returns The quaternion rotation
  4962. */
  4963. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  4964. /**
  4965. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  4966. * @param space The space that the rotation should be in
  4967. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4968. * @param result The quaternion that the rotation should be copied to
  4969. */
  4970. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  4971. /**
  4972. * Get the rotation matrix of the bone in local or world space
  4973. * @param space The space that the rotation should be in
  4974. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4975. * @returns The rotation matrix
  4976. */
  4977. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  4978. /**
  4979. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  4980. * @param space The space that the rotation should be in
  4981. * @param mesh The mesh that this bone is attached to. This is only used in world space
  4982. * @param result The quaternion that the rotation should be copied to
  4983. */
  4984. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  4985. /**
  4986. * Get the world position of a point that is in the local space of the bone
  4987. * @param position The local position
  4988. * @param mesh The mesh that this bone is attached to
  4989. * @returns The world position
  4990. */
  4991. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  4992. /**
  4993. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  4994. * @param position The local position
  4995. * @param mesh The mesh that this bone is attached to
  4996. * @param result The vector3 that the world position should be copied to
  4997. */
  4998. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  4999. /**
  5000. * Get the local position of a point that is in world space
  5001. * @param position The world position
  5002. * @param mesh The mesh that this bone is attached to
  5003. * @returns The local position
  5004. */
  5005. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  5006. /**
  5007. * Get the local position of a point that is in world space and copy it to the result param
  5008. * @param position The world position
  5009. * @param mesh The mesh that this bone is attached to
  5010. * @param result The vector3 that the local position should be copied to
  5011. */
  5012. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  5013. }
  5014. }
  5015. declare module BABYLON {
  5016. /**
  5017. * Class used to apply inverse kinematics to bones
  5018. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  5019. */
  5020. class BoneIKController {
  5021. private static _tmpVecs;
  5022. private static _tmpQuat;
  5023. private static _tmpMats;
  5024. /**
  5025. * Gets or sets the target mesh
  5026. */
  5027. targetMesh: AbstractMesh;
  5028. /** Gets or sets the mesh used as pole */
  5029. poleTargetMesh: AbstractMesh;
  5030. /**
  5031. * Gets or sets the bone used as pole
  5032. */
  5033. poleTargetBone: Nullable<Bone>;
  5034. /**
  5035. * Gets or sets the target position
  5036. */
  5037. targetPosition: Vector3;
  5038. /**
  5039. * Gets or sets the pole target position
  5040. */
  5041. poleTargetPosition: Vector3;
  5042. /**
  5043. * Gets or sets the pole target local offset
  5044. */
  5045. poleTargetLocalOffset: Vector3;
  5046. /**
  5047. * Gets or sets the pole angle
  5048. */
  5049. poleAngle: number;
  5050. /**
  5051. * Gets or sets the mesh associated with the controller
  5052. */
  5053. mesh: AbstractMesh;
  5054. /**
  5055. * 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)
  5056. */
  5057. slerpAmount: number;
  5058. private _bone1Quat;
  5059. private _bone1Mat;
  5060. private _bone2Ang;
  5061. private _bone1;
  5062. private _bone2;
  5063. private _bone1Length;
  5064. private _bone2Length;
  5065. private _maxAngle;
  5066. private _maxReach;
  5067. private _rightHandedSystem;
  5068. private _bendAxis;
  5069. private _slerping;
  5070. private _adjustRoll;
  5071. /**
  5072. * Gets or sets maximum allowed angle
  5073. */
  5074. maxAngle: number;
  5075. /**
  5076. * Creates a new BoneIKController
  5077. * @param mesh defines the mesh to control
  5078. * @param bone defines the bone to control
  5079. * @param options defines options to set up the controller
  5080. */
  5081. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  5082. targetMesh?: AbstractMesh;
  5083. poleTargetMesh?: AbstractMesh;
  5084. poleTargetBone?: Bone;
  5085. poleTargetLocalOffset?: Vector3;
  5086. poleAngle?: number;
  5087. bendAxis?: Vector3;
  5088. maxAngle?: number;
  5089. slerpAmount?: number;
  5090. });
  5091. private _setMaxAngle(ang);
  5092. /**
  5093. * Force the controller to update the bones
  5094. */
  5095. update(): void;
  5096. }
  5097. }
  5098. declare module BABYLON {
  5099. /**
  5100. * Class used to make a bone look toward a point in space
  5101. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  5102. */
  5103. class BoneLookController {
  5104. private static _tmpVecs;
  5105. private static _tmpQuat;
  5106. private static _tmpMats;
  5107. /**
  5108. * The target Vector3 that the bone will look at
  5109. */
  5110. target: Vector3;
  5111. /**
  5112. * The mesh that the bone is attached to
  5113. */
  5114. mesh: AbstractMesh;
  5115. /**
  5116. * The bone that will be looking to the target
  5117. */
  5118. bone: Bone;
  5119. /**
  5120. * The up axis of the coordinate system that is used when the bone is rotated
  5121. */
  5122. upAxis: Vector3;
  5123. /**
  5124. * The space that the up axis is in - BABYLON.Space.BONE, BABYLON.Space.LOCAL (default), or BABYLON.Space.WORLD
  5125. */
  5126. upAxisSpace: Space;
  5127. /**
  5128. * Used to make an adjustment to the yaw of the bone
  5129. */
  5130. adjustYaw: number;
  5131. /**
  5132. * Used to make an adjustment to the pitch of the bone
  5133. */
  5134. adjustPitch: number;
  5135. /**
  5136. * Used to make an adjustment to the roll of the bone
  5137. */
  5138. adjustRoll: number;
  5139. /**
  5140. * 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)
  5141. */
  5142. slerpAmount: number;
  5143. private _minYaw;
  5144. private _maxYaw;
  5145. private _minPitch;
  5146. private _maxPitch;
  5147. private _minYawSin;
  5148. private _minYawCos;
  5149. private _maxYawSin;
  5150. private _maxYawCos;
  5151. private _midYawConstraint;
  5152. private _minPitchTan;
  5153. private _maxPitchTan;
  5154. private _boneQuat;
  5155. private _slerping;
  5156. private _transformYawPitch;
  5157. private _transformYawPitchInv;
  5158. private _firstFrameSkipped;
  5159. private _yawRange;
  5160. private _fowardAxis;
  5161. /**
  5162. * Gets or sets the minimum yaw angle that the bone can look to
  5163. */
  5164. minYaw: number;
  5165. /**
  5166. * Gets or sets the maximum yaw angle that the bone can look to
  5167. */
  5168. maxYaw: number;
  5169. /**
  5170. * Gets or sets the minimum pitch angle that the bone can look to
  5171. */
  5172. minPitch: number;
  5173. /**
  5174. * Gets or sets the maximum pitch angle that the bone can look to
  5175. */
  5176. maxPitch: number;
  5177. /**
  5178. * Create a BoneLookController
  5179. * @param mesh the mesh that the bone belongs to
  5180. * @param bone the bone that will be looking to the target
  5181. * @param target the target Vector3 to look at
  5182. * @param settings optional settings:
  5183. * * maxYaw: the maximum angle the bone will yaw to
  5184. * * minYaw: the minimum angle the bone will yaw to
  5185. * * maxPitch: the maximum angle the bone will pitch to
  5186. * * minPitch: the minimum angle the bone will yaw to
  5187. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  5188. * * upAxis: the up axis of the coordinate system
  5189. * * upAxisSpace: the space that the up axis is in - BABYLON.Space.BONE, BABYLON.Space.LOCAL (default), or BABYLON.Space.WORLD.
  5190. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  5191. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  5192. * * adjustYaw: used to make an adjustment to the yaw of the bone
  5193. * * adjustPitch: used to make an adjustment to the pitch of the bone
  5194. * * adjustRoll: used to make an adjustment to the roll of the bone
  5195. **/
  5196. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  5197. maxYaw?: number;
  5198. minYaw?: number;
  5199. maxPitch?: number;
  5200. minPitch?: number;
  5201. slerpAmount?: number;
  5202. upAxis?: Vector3;
  5203. upAxisSpace?: Space;
  5204. yawAxis?: Vector3;
  5205. pitchAxis?: Vector3;
  5206. adjustYaw?: number;
  5207. adjustPitch?: number;
  5208. adjustRoll?: number;
  5209. });
  5210. /**
  5211. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  5212. */
  5213. update(): void;
  5214. private _getAngleDiff(ang1, ang2);
  5215. private _getAngleBetween(ang1, ang2);
  5216. private _isAngleBetween(ang, ang1, ang2);
  5217. }
  5218. }
  5219. declare module BABYLON {
  5220. /**
  5221. * Class used to handle skinning animations
  5222. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  5223. */
  5224. class Skeleton implements IAnimatable {
  5225. /** defines the skeleton name */
  5226. name: string;
  5227. /** defines the skeleton Id */
  5228. id: string;
  5229. /**
  5230. * Gets the list of child bones
  5231. */
  5232. bones: Bone[];
  5233. /**
  5234. * Gets an estimate of the dimension of the skeleton at rest
  5235. */
  5236. dimensionsAtRest: Vector3;
  5237. /**
  5238. * Gets a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  5239. */
  5240. needInitialSkinMatrix: boolean;
  5241. /**
  5242. * Gets the list of animations attached to this skeleton
  5243. */
  5244. animations: Array<Animation>;
  5245. private _scene;
  5246. private _isDirty;
  5247. private _transformMatrices;
  5248. private _meshesWithPoseMatrix;
  5249. private _animatables;
  5250. private _identity;
  5251. private _synchronizedWithMesh;
  5252. private _ranges;
  5253. private _lastAbsoluteTransformsUpdateId;
  5254. /**
  5255. * Specifies if the skeleton should be serialized
  5256. */
  5257. doNotSerialize: boolean;
  5258. private _animationPropertiesOverride;
  5259. /**
  5260. * Gets or sets the animation properties override
  5261. */
  5262. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  5263. /**
  5264. * An observable triggered before computing the skeleton's matrices
  5265. */
  5266. onBeforeComputeObservable: Observable<Skeleton>;
  5267. /**
  5268. * Creates a new skeleton
  5269. * @param name defines the skeleton name
  5270. * @param id defines the skeleton Id
  5271. * @param scene defines the hosting scene
  5272. */
  5273. constructor(
  5274. /** defines the skeleton name */
  5275. name: string,
  5276. /** defines the skeleton Id */
  5277. id: string, scene: Scene);
  5278. /**
  5279. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  5280. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  5281. * @returns a Float32Array containing matrices data
  5282. */
  5283. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  5284. /**
  5285. * Gets the current hosting scene
  5286. * @returns a scene object
  5287. */
  5288. getScene(): Scene;
  5289. /**
  5290. * Gets a string representing the current skeleton data
  5291. * @param fullDetails defines a boolean indicating if we want a verbose version
  5292. * @returns a string representing the current skeleton data
  5293. */
  5294. toString(fullDetails?: boolean): string;
  5295. /**
  5296. * Get bone's index searching by name
  5297. * @param name defines bone's name to search for
  5298. * @return the indice of the bone. Returns -1 if not found
  5299. */
  5300. getBoneIndexByName(name: string): number;
  5301. /**
  5302. * Creater a new animation range
  5303. * @param name defines the name of the range
  5304. * @param from defines the start key
  5305. * @param to defines the end key
  5306. */
  5307. createAnimationRange(name: string, from: number, to: number): void;
  5308. /**
  5309. * Delete a specific animation range
  5310. * @param name defines the name of the range
  5311. * @param deleteFrames defines if frames must be removed as well
  5312. */
  5313. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  5314. /**
  5315. * Gets a specific animation range
  5316. * @param name defines the name of the range to look for
  5317. * @returns the requested animation range or null if not found
  5318. */
  5319. getAnimationRange(name: string): Nullable<AnimationRange>;
  5320. /**
  5321. * Gets the list of all animation ranges defined on this skeleton
  5322. * @returns an array
  5323. */
  5324. getAnimationRanges(): Nullable<AnimationRange>[];
  5325. /**
  5326. * Copy animation range from a source skeleton.
  5327. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  5328. * @param source defines the source skeleton
  5329. * @param name defines the name of the range to copy
  5330. * @param rescaleAsRequired defines if rescaling must be applied if required
  5331. * @returns true if operation was successful
  5332. */
  5333. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  5334. /**
  5335. * Forces the skeleton to go to rest pose
  5336. */
  5337. returnToRest(): void;
  5338. private _getHighestAnimationFrame();
  5339. /**
  5340. * Begin a specific animation range
  5341. * @param name defines the name of the range to start
  5342. * @param loop defines if looping must be turned on (false by default)
  5343. * @param speedRatio defines the speed ratio to apply (1 by default)
  5344. * @param onAnimationEnd defines a callback which will be called when animation will end
  5345. * @returns a new animatable
  5346. */
  5347. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  5348. /** @hidden */
  5349. _markAsDirty(): void;
  5350. /** @hidden */
  5351. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  5352. /** @hidden */
  5353. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  5354. /** @hidden */
  5355. _computeTransformMatrices(targetMatrix: Float32Array, initialSkinMatrix: Nullable<Matrix>): void;
  5356. /**
  5357. * Build all resources required to render a skeleton
  5358. */
  5359. prepare(): void;
  5360. /**
  5361. * Gets the list of animatables currently running for this skeleton
  5362. * @returns an array of animatables
  5363. */
  5364. getAnimatables(): IAnimatable[];
  5365. /**
  5366. * Clone the current skeleton
  5367. * @param name defines the name of the new skeleton
  5368. * @param id defines the id of the enw skeleton
  5369. * @returns the new skeleton
  5370. */
  5371. clone(name: string, id: string): Skeleton;
  5372. /**
  5373. * Enable animation blending for this skeleton
  5374. * @param blendingSpeed defines the blending speed to apply
  5375. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  5376. */
  5377. enableBlending(blendingSpeed?: number): void;
  5378. /**
  5379. * Releases all resources associated with the current skeleton
  5380. */
  5381. dispose(): void;
  5382. /**
  5383. * Serialize the skeleton in a JSON object
  5384. * @returns a JSON object
  5385. */
  5386. serialize(): any;
  5387. /**
  5388. * Creates a new skeleton from serialized data
  5389. * @param parsedSkeleton defines the serialized data
  5390. * @param scene defines the hosting scene
  5391. * @returns a new skeleton
  5392. */
  5393. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  5394. /**
  5395. * Compute all node absolute transforms
  5396. * @param forceUpdate defines if computation must be done even if cache is up to date
  5397. */
  5398. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  5399. /**
  5400. * Gets the root pose matrix
  5401. * @returns a matrix
  5402. */
  5403. getPoseMatrix(): Nullable<Matrix>;
  5404. /**
  5405. * Sorts bones per internal index
  5406. */
  5407. sortBones(): void;
  5408. private _sortBones(index, bones, visited);
  5409. }
  5410. }
  5411. declare module BABYLON {
  5412. class Collider {
  5413. /** Define if a collision was found */
  5414. collisionFound: boolean;
  5415. /**
  5416. * Define last intersection point in local space
  5417. */
  5418. intersectionPoint: Vector3;
  5419. /**
  5420. * Define last collided mesh
  5421. */
  5422. collidedMesh: Nullable<AbstractMesh>;
  5423. private _collisionPoint;
  5424. private _planeIntersectionPoint;
  5425. private _tempVector;
  5426. private _tempVector2;
  5427. private _tempVector3;
  5428. private _tempVector4;
  5429. private _edge;
  5430. private _baseToVertex;
  5431. private _destinationPoint;
  5432. private _slidePlaneNormal;
  5433. private _displacementVector;
  5434. _radius: Vector3;
  5435. _retry: number;
  5436. private _velocity;
  5437. private _basePoint;
  5438. private _epsilon;
  5439. _velocityWorldLength: number;
  5440. _basePointWorld: Vector3;
  5441. private _velocityWorld;
  5442. private _normalizedVelocity;
  5443. _initialVelocity: Vector3;
  5444. _initialPosition: Vector3;
  5445. private _nearestDistance;
  5446. private _collisionMask;
  5447. collisionMask: number;
  5448. /**
  5449. * Gets the plane normal used to compute the sliding response (in local space)
  5450. */
  5451. readonly slidePlaneNormal: Vector3;
  5452. _initialize(source: Vector3, dir: Vector3, e: number): void;
  5453. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  5454. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  5455. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  5456. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  5457. _getResponse(pos: Vector3, vel: Vector3): void;
  5458. }
  5459. }
  5460. declare module BABYLON {
  5461. var CollisionWorker: string;
  5462. interface ICollisionCoordinator {
  5463. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  5464. init(scene: Scene): void;
  5465. destroy(): void;
  5466. onMeshAdded(mesh: AbstractMesh): void;
  5467. onMeshUpdated(mesh: AbstractMesh): void;
  5468. onMeshRemoved(mesh: AbstractMesh): void;
  5469. onGeometryAdded(geometry: Geometry): void;
  5470. onGeometryUpdated(geometry: Geometry): void;
  5471. onGeometryDeleted(geometry: Geometry): void;
  5472. }
  5473. interface SerializedMesh {
  5474. id: string;
  5475. name: string;
  5476. uniqueId: number;
  5477. geometryId: Nullable<string>;
  5478. sphereCenter: Array<number>;
  5479. sphereRadius: number;
  5480. boxMinimum: Array<number>;
  5481. boxMaximum: Array<number>;
  5482. worldMatrixFromCache: any;
  5483. subMeshes: Array<SerializedSubMesh>;
  5484. checkCollisions: boolean;
  5485. }
  5486. interface SerializedSubMesh {
  5487. position: number;
  5488. verticesStart: number;
  5489. verticesCount: number;
  5490. indexStart: number;
  5491. indexCount: number;
  5492. hasMaterial: boolean;
  5493. sphereCenter: Array<number>;
  5494. sphereRadius: number;
  5495. boxMinimum: Array<number>;
  5496. boxMaximum: Array<number>;
  5497. }
  5498. /**
  5499. * Interface describing the value associated with a geometry
  5500. */
  5501. interface SerializedGeometry {
  5502. /**
  5503. * Defines the unique ID of the geometry
  5504. */
  5505. id: string;
  5506. /**
  5507. * Defines the array containing the positions
  5508. */
  5509. positions: Float32Array;
  5510. /**
  5511. * Defines the array containing the indices
  5512. */
  5513. indices: Uint32Array;
  5514. /**
  5515. * Defines the array containing the normals
  5516. */
  5517. normals: Float32Array;
  5518. }
  5519. interface BabylonMessage {
  5520. taskType: WorkerTaskType;
  5521. payload: InitPayload | CollidePayload | UpdatePayload;
  5522. }
  5523. interface SerializedColliderToWorker {
  5524. position: Array<number>;
  5525. velocity: Array<number>;
  5526. radius: Array<number>;
  5527. }
  5528. /** Defines supported task for worker process */
  5529. enum WorkerTaskType {
  5530. /** Initialization */
  5531. INIT = 0,
  5532. /** Update of geometry */
  5533. UPDATE = 1,
  5534. /** Evaluate collision */
  5535. COLLIDE = 2,
  5536. }
  5537. interface WorkerReply {
  5538. error: WorkerReplyType;
  5539. taskType: WorkerTaskType;
  5540. payload?: any;
  5541. }
  5542. interface CollisionReplyPayload {
  5543. newPosition: Array<number>;
  5544. collisionId: number;
  5545. collidedMeshUniqueId: number;
  5546. }
  5547. interface InitPayload {
  5548. }
  5549. interface CollidePayload {
  5550. collisionId: number;
  5551. collider: SerializedColliderToWorker;
  5552. maximumRetry: number;
  5553. excludedMeshUniqueId: Nullable<number>;
  5554. }
  5555. interface UpdatePayload {
  5556. updatedMeshes: {
  5557. [n: number]: SerializedMesh;
  5558. };
  5559. updatedGeometries: {
  5560. [s: string]: SerializedGeometry;
  5561. };
  5562. removedMeshes: Array<number>;
  5563. removedGeometries: Array<string>;
  5564. }
  5565. /** Defines kind of replies returned by worker */
  5566. enum WorkerReplyType {
  5567. /** Success */
  5568. SUCCESS = 0,
  5569. /** Unkown error */
  5570. UNKNOWN_ERROR = 1,
  5571. }
  5572. class CollisionCoordinatorWorker implements ICollisionCoordinator {
  5573. private _scene;
  5574. private _scaledPosition;
  5575. private _scaledVelocity;
  5576. private _collisionsCallbackArray;
  5577. private _init;
  5578. private _runningUpdated;
  5579. private _worker;
  5580. private _addUpdateMeshesList;
  5581. private _addUpdateGeometriesList;
  5582. private _toRemoveMeshesArray;
  5583. private _toRemoveGeometryArray;
  5584. constructor();
  5585. static SerializeMesh: (mesh: AbstractMesh) => SerializedMesh;
  5586. static SerializeGeometry: (geometry: Geometry) => SerializedGeometry;
  5587. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  5588. init(scene: Scene): void;
  5589. destroy(): void;
  5590. onMeshAdded(mesh: AbstractMesh): void;
  5591. onMeshUpdated: (transformNode: TransformNode) => void;
  5592. onMeshRemoved(mesh: AbstractMesh): void;
  5593. onGeometryAdded(geometry: Geometry): void;
  5594. onGeometryUpdated: (geometry: Geometry) => void;
  5595. onGeometryDeleted(geometry: Geometry): void;
  5596. private _afterRender;
  5597. private _onMessageFromWorker;
  5598. }
  5599. class CollisionCoordinatorLegacy implements ICollisionCoordinator {
  5600. private _scene;
  5601. private _scaledPosition;
  5602. private _scaledVelocity;
  5603. private _finalPosition;
  5604. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  5605. init(scene: Scene): void;
  5606. destroy(): void;
  5607. onMeshAdded(mesh: AbstractMesh): void;
  5608. onMeshUpdated(mesh: AbstractMesh): void;
  5609. onMeshRemoved(mesh: AbstractMesh): void;
  5610. onGeometryAdded(geometry: Geometry): void;
  5611. onGeometryUpdated(geometry: Geometry): void;
  5612. onGeometryDeleted(geometry: Geometry): void;
  5613. private _collideWithWorld(position, velocity, collider, maximumRetry, finalPosition, excludedMesh?);
  5614. }
  5615. }
  5616. declare function importScripts(...urls: string[]): void;
  5617. declare const safePostMessage: any;
  5618. declare module BABYLON {
  5619. var WorkerIncluded: boolean;
  5620. class CollisionCache {
  5621. private _meshes;
  5622. private _geometries;
  5623. getMeshes(): {
  5624. [n: number]: SerializedMesh;
  5625. };
  5626. getGeometries(): {
  5627. [s: number]: SerializedGeometry;
  5628. };
  5629. getMesh(id: any): SerializedMesh;
  5630. addMesh(mesh: SerializedMesh): void;
  5631. removeMesh(uniqueId: number): void;
  5632. getGeometry(id: string): SerializedGeometry;
  5633. addGeometry(geometry: SerializedGeometry): void;
  5634. removeGeometry(id: string): void;
  5635. }
  5636. class CollideWorker {
  5637. collider: Collider;
  5638. private _collisionCache;
  5639. private finalPosition;
  5640. private collisionsScalingMatrix;
  5641. private collisionTranformationMatrix;
  5642. constructor(collider: Collider, _collisionCache: CollisionCache, finalPosition: Vector3);
  5643. collideWithWorld(position: Vector3, velocity: Vector3, maximumRetry: number, excludedMeshUniqueId: Nullable<number>): void;
  5644. private checkCollision(mesh);
  5645. private processCollisionsForSubMeshes(transformMatrix, mesh);
  5646. private collideForSubMesh(subMesh, transformMatrix, meshGeometry);
  5647. private checkSubmeshCollision(subMesh);
  5648. }
  5649. interface ICollisionDetector {
  5650. onInit(payload: InitPayload): void;
  5651. onUpdate(payload: UpdatePayload): void;
  5652. onCollision(payload: CollidePayload): void;
  5653. }
  5654. class CollisionDetectorTransferable implements ICollisionDetector {
  5655. private _collisionCache;
  5656. onInit(payload: InitPayload): void;
  5657. onUpdate(payload: UpdatePayload): void;
  5658. onCollision(payload: CollidePayload): void;
  5659. }
  5660. }
  5661. declare module BABYLON {
  5662. class IntersectionInfo {
  5663. bu: Nullable<number>;
  5664. bv: Nullable<number>;
  5665. distance: number;
  5666. faceId: number;
  5667. subMeshId: number;
  5668. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  5669. }
  5670. /**
  5671. * Information about the result of picking within a scene
  5672. * See https://doc.babylonjs.com/babylon101/picking_collisions
  5673. */
  5674. class PickingInfo {
  5675. /**
  5676. * If the pick collided with an object
  5677. */
  5678. hit: boolean;
  5679. /**
  5680. * Distance away where the pick collided
  5681. */
  5682. distance: number;
  5683. /**
  5684. * The location of pick collision
  5685. */
  5686. pickedPoint: Nullable<Vector3>;
  5687. /**
  5688. * The mesh corrisponding the the pick collision
  5689. */
  5690. pickedMesh: Nullable<AbstractMesh>;
  5691. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calulating the texture coordinates of the collision.*/
  5692. bu: number;
  5693. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calulating the texture coordinates of the collision.*/
  5694. bv: number;
  5695. /** The id of the face on the mesh that was picked */
  5696. faceId: number;
  5697. /** Id of the the submesh that was picked */
  5698. subMeshId: number;
  5699. /** If a sprite was picked, this will be the sprite the pick collided with */
  5700. pickedSprite: Nullable<Sprite>;
  5701. /**
  5702. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  5703. */
  5704. originMesh: Nullable<AbstractMesh>;
  5705. /**
  5706. * The ray that was used to perform the picking.
  5707. */
  5708. ray: Nullable<Ray>;
  5709. /**
  5710. * Gets the normal corrispodning to the face the pick collided with
  5711. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  5712. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  5713. * @returns The normal corrispodning to the face the pick collided with
  5714. */
  5715. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  5716. /**
  5717. * Gets the texture coordinates of where the pick occured
  5718. * @returns the vector containing the coordnates of the texture
  5719. */
  5720. getTextureCoordinates(): Nullable<Vector2>;
  5721. }
  5722. }
  5723. /**
  5724. * Module Debug contains the (visual) components to debug a scene correctly
  5725. */
  5726. declare module BABYLON.Debug {
  5727. /**
  5728. * The Axes viewer will show 3 axes in a specific point in space
  5729. */
  5730. class AxesViewer {
  5731. private _xline;
  5732. private _yline;
  5733. private _zline;
  5734. private _xmesh;
  5735. private _ymesh;
  5736. private _zmesh;
  5737. scene: Nullable<Scene>;
  5738. scaleLines: number;
  5739. constructor(scene: Scene, scaleLines?: number);
  5740. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  5741. dispose(): void;
  5742. }
  5743. }
  5744. declare module BABYLON.Debug {
  5745. /**
  5746. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  5747. */
  5748. class BoneAxesViewer extends AxesViewer {
  5749. mesh: Nullable<Mesh>;
  5750. bone: Nullable<Bone>;
  5751. pos: Vector3;
  5752. xaxis: Vector3;
  5753. yaxis: Vector3;
  5754. zaxis: Vector3;
  5755. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  5756. update(): void;
  5757. dispose(): void;
  5758. }
  5759. }
  5760. declare module BABYLON {
  5761. class DebugLayer {
  5762. private _scene;
  5763. static InspectorURL: string;
  5764. private _inspector;
  5765. private BJSINSPECTOR;
  5766. constructor(scene: Scene);
  5767. /** Creates the inspector window. */
  5768. private _createInspector(config?);
  5769. isVisible(): boolean;
  5770. hide(): void;
  5771. show(config?: {
  5772. popup?: boolean;
  5773. initialTab?: number;
  5774. parentElement?: HTMLElement;
  5775. newColors?: {
  5776. backgroundColor?: string;
  5777. backgroundColorLighter?: string;
  5778. backgroundColorLighter2?: string;
  5779. backgroundColorLighter3?: string;
  5780. color?: string;
  5781. colorTop?: string;
  5782. colorBot?: string;
  5783. };
  5784. }): void;
  5785. /**
  5786. * Gets the active tab
  5787. * @return the index of the active tab or -1 if the inspector is hidden
  5788. */
  5789. getActiveTab(): number;
  5790. }
  5791. }
  5792. declare module BABYLON.Debug {
  5793. /**
  5794. * Used to show the physics impostor around the specific mesh.
  5795. */
  5796. class PhysicsViewer {
  5797. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  5798. protected _meshes: Array<Nullable<AbstractMesh>>;
  5799. protected _scene: Nullable<Scene>;
  5800. protected _numMeshes: number;
  5801. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  5802. private _renderFunction;
  5803. private _debugBoxMesh;
  5804. private _debugSphereMesh;
  5805. private _debugMaterial;
  5806. constructor(scene: Scene);
  5807. protected _updateDebugMeshes(): void;
  5808. showImpostor(impostor: PhysicsImpostor): void;
  5809. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  5810. private _getDebugMaterial(scene);
  5811. private _getDebugBoxMesh(scene);
  5812. private _getDebugSphereMesh(scene);
  5813. private _getDebugMesh(impostor, scene);
  5814. dispose(): void;
  5815. }
  5816. }
  5817. declare module BABYLON {
  5818. class RayHelper {
  5819. ray: Nullable<Ray>;
  5820. private _renderPoints;
  5821. private _renderLine;
  5822. private _renderFunction;
  5823. private _scene;
  5824. private _updateToMeshFunction;
  5825. private _attachedToMesh;
  5826. private _meshSpaceDirection;
  5827. private _meshSpaceOrigin;
  5828. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  5829. constructor(ray: Ray);
  5830. show(scene: Scene, color: Color3): void;
  5831. hide(): void;
  5832. private _render();
  5833. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  5834. detachFromMesh(): void;
  5835. private _updateToMesh();
  5836. dispose(): void;
  5837. }
  5838. }
  5839. declare module BABYLON.Debug {
  5840. /**
  5841. * Demo available here: http://www.babylonjs-playground.com/#1BZJVJ#8
  5842. */
  5843. class SkeletonViewer {
  5844. skeleton: Skeleton;
  5845. mesh: AbstractMesh;
  5846. autoUpdateBonesMatrices: boolean;
  5847. renderingGroupId: number;
  5848. color: Color3;
  5849. private _scene;
  5850. private _debugLines;
  5851. private _debugMesh;
  5852. private _isEnabled;
  5853. private _renderFunction;
  5854. constructor(skeleton: Skeleton, mesh: AbstractMesh, scene: Scene, autoUpdateBonesMatrices?: boolean, renderingGroupId?: number);
  5855. isEnabled: boolean;
  5856. private _getBonePosition(position, bone, meshMat, x?, y?, z?);
  5857. private _getLinesForBonesWithLength(bones, meshMat);
  5858. private _getLinesForBonesNoLength(bones, meshMat);
  5859. update(): void;
  5860. dispose(): void;
  5861. }
  5862. }
  5863. declare module BABYLON {
  5864. class BoundingBox implements ICullable {
  5865. vectors: Vector3[];
  5866. center: Vector3;
  5867. centerWorld: Vector3;
  5868. extendSize: Vector3;
  5869. extendSizeWorld: Vector3;
  5870. directions: Vector3[];
  5871. vectorsWorld: Vector3[];
  5872. minimumWorld: Vector3;
  5873. maximumWorld: Vector3;
  5874. minimum: Vector3;
  5875. maximum: Vector3;
  5876. private _worldMatrix;
  5877. /**
  5878. * Creates a new bounding box
  5879. * @param min defines the minimum vector (in local space)
  5880. * @param max defines the maximum vector (in local space)
  5881. */
  5882. constructor(min: Vector3, max: Vector3);
  5883. /**
  5884. * Recreates the entire bounding box from scratch
  5885. * @param min defines the new minimum vector (in local space)
  5886. * @param max defines the new maximum vector (in local space)
  5887. */
  5888. reConstruct(min: Vector3, max: Vector3): void;
  5889. getWorldMatrix(): Matrix;
  5890. setWorldMatrix(matrix: Matrix): BoundingBox;
  5891. _update(world: Matrix): void;
  5892. isInFrustum(frustumPlanes: Plane[]): boolean;
  5893. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  5894. intersectsPoint(point: Vector3): boolean;
  5895. intersectsSphere(sphere: BoundingSphere): boolean;
  5896. intersectsMinMax(min: Vector3, max: Vector3): boolean;
  5897. static Intersects(box0: BoundingBox, box1: BoundingBox): boolean;
  5898. static IntersectsSphere(minPoint: Vector3, maxPoint: Vector3, sphereCenter: Vector3, sphereRadius: number): boolean;
  5899. static IsCompletelyInFrustum(boundingVectors: Vector3[], frustumPlanes: Plane[]): boolean;
  5900. static IsInFrustum(boundingVectors: Vector3[], frustumPlanes: Plane[]): boolean;
  5901. }
  5902. }
  5903. declare module BABYLON {
  5904. interface ICullable {
  5905. isInFrustum(frustumPlanes: Plane[]): boolean;
  5906. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  5907. }
  5908. class BoundingInfo implements ICullable {
  5909. minimum: Vector3;
  5910. maximum: Vector3;
  5911. boundingBox: BoundingBox;
  5912. boundingSphere: BoundingSphere;
  5913. private _isLocked;
  5914. constructor(minimum: Vector3, maximum: Vector3);
  5915. isLocked: boolean;
  5916. update(world: Matrix): void;
  5917. /**
  5918. * Recreate the bounding info to be centered around a specific point given a specific extend.
  5919. * @param center New center of the bounding info
  5920. * @param extend New extend of the bounding info
  5921. */
  5922. centerOn(center: Vector3, extend: Vector3): BoundingInfo;
  5923. isInFrustum(frustumPlanes: Plane[]): boolean;
  5924. /**
  5925. * Gets the world distance between the min and max points of the bounding box
  5926. */
  5927. readonly diagonalLength: number;
  5928. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  5929. _checkCollision(collider: Collider): boolean;
  5930. intersectsPoint(point: Vector3): boolean;
  5931. intersects(boundingInfo: BoundingInfo, precise: boolean): boolean;
  5932. }
  5933. }
  5934. declare module BABYLON {
  5935. class BoundingSphere {
  5936. center: Vector3;
  5937. radius: number;
  5938. centerWorld: Vector3;
  5939. radiusWorld: number;
  5940. minimum: Vector3;
  5941. maximum: Vector3;
  5942. private _tempRadiusVector;
  5943. /**
  5944. * Creates a new bounding sphere
  5945. * @param min defines the minimum vector (in local space)
  5946. * @param max defines the maximum vector (in local space)
  5947. */
  5948. constructor(min: Vector3, max: Vector3);
  5949. /**
  5950. * Recreates the entire bounding sphere from scratch
  5951. * @param min defines the new minimum vector (in local space)
  5952. * @param max defines the new maximum vector (in local space)
  5953. */
  5954. reConstruct(min: Vector3, max: Vector3): void;
  5955. _update(world: Matrix): void;
  5956. isInFrustum(frustumPlanes: Plane[]): boolean;
  5957. intersectsPoint(point: Vector3): boolean;
  5958. static Intersects(sphere0: BoundingSphere, sphere1: BoundingSphere): boolean;
  5959. }
  5960. }
  5961. declare module BABYLON {
  5962. class Ray {
  5963. origin: Vector3;
  5964. direction: Vector3;
  5965. length: number;
  5966. private _edge1;
  5967. private _edge2;
  5968. private _pvec;
  5969. private _tvec;
  5970. private _qvec;
  5971. private _tmpRay;
  5972. constructor(origin: Vector3, direction: Vector3, length?: number);
  5973. intersectsBoxMinMax(minimum: Vector3, maximum: Vector3): boolean;
  5974. intersectsBox(box: BoundingBox): boolean;
  5975. intersectsSphere(sphere: BoundingSphere): boolean;
  5976. intersectsTriangle(vertex0: Vector3, vertex1: Vector3, vertex2: Vector3): Nullable<IntersectionInfo>;
  5977. intersectsPlane(plane: Plane): Nullable<number>;
  5978. intersectsMesh(mesh: AbstractMesh, fastCheck?: boolean): PickingInfo;
  5979. intersectsMeshes(meshes: Array<AbstractMesh>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  5980. private _comparePickingInfo(pickingInfoA, pickingInfoB);
  5981. private static smallnum;
  5982. private static rayl;
  5983. /**
  5984. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  5985. * @param sega the first point of the segment to test the intersection against
  5986. * @param segb the second point of the segment to test the intersection against
  5987. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  5988. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  5989. */
  5990. intersectionSegment(sega: Vector3, segb: Vector3, threshold: number): number;
  5991. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix): Ray;
  5992. static Zero(): Ray;
  5993. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix): Ray;
  5994. /**
  5995. * 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
  5996. * transformed to the given world matrix.
  5997. * @param origin The origin point
  5998. * @param end The end point
  5999. * @param world a matrix to transform the ray to. Default is the identity matrix.
  6000. */
  6001. static CreateNewFromTo(origin: Vector3, end: Vector3, world?: Matrix): Ray;
  6002. static Transform(ray: Ray, matrix: Matrix): Ray;
  6003. static TransformToRef(ray: Ray, matrix: Matrix, result: Ray): void;
  6004. }
  6005. }
  6006. declare module BABYLON {
  6007. class ArcRotateCamera extends TargetCamera {
  6008. alpha: number;
  6009. beta: number;
  6010. radius: number;
  6011. protected _target: Vector3;
  6012. protected _targetHost: Nullable<AbstractMesh>;
  6013. target: Vector3;
  6014. inertialAlphaOffset: number;
  6015. inertialBetaOffset: number;
  6016. inertialRadiusOffset: number;
  6017. lowerAlphaLimit: Nullable<number>;
  6018. upperAlphaLimit: Nullable<number>;
  6019. lowerBetaLimit: number;
  6020. upperBetaLimit: number;
  6021. lowerRadiusLimit: Nullable<number>;
  6022. upperRadiusLimit: Nullable<number>;
  6023. inertialPanningX: number;
  6024. inertialPanningY: number;
  6025. pinchToPanMaxDistance: number;
  6026. panningDistanceLimit: Nullable<number>;
  6027. panningOriginTarget: Vector3;
  6028. panningInertia: number;
  6029. angularSensibilityX: number;
  6030. angularSensibilityY: number;
  6031. pinchPrecision: number;
  6032. pinchDeltaPercentage: number;
  6033. panningSensibility: number;
  6034. keysUp: number[];
  6035. keysDown: number[];
  6036. keysLeft: number[];
  6037. keysRight: number[];
  6038. wheelPrecision: number;
  6039. wheelDeltaPercentage: number;
  6040. zoomOnFactor: number;
  6041. targetScreenOffset: Vector2;
  6042. allowUpsideDown: boolean;
  6043. _viewMatrix: Matrix;
  6044. _useCtrlForPanning: boolean;
  6045. _panningMouseButton: number;
  6046. inputs: ArcRotateCameraInputsManager;
  6047. _reset: () => void;
  6048. panningAxis: Vector3;
  6049. protected _localDirection: Vector3;
  6050. protected _transformedDirection: Vector3;
  6051. private _bouncingBehavior;
  6052. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  6053. useBouncingBehavior: boolean;
  6054. private _framingBehavior;
  6055. readonly framingBehavior: Nullable<FramingBehavior>;
  6056. useFramingBehavior: boolean;
  6057. private _autoRotationBehavior;
  6058. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  6059. useAutoRotationBehavior: boolean;
  6060. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  6061. onCollide: (collidedMesh: AbstractMesh) => void;
  6062. checkCollisions: boolean;
  6063. collisionRadius: Vector3;
  6064. protected _collider: Collider;
  6065. protected _previousPosition: Vector3;
  6066. protected _collisionVelocity: Vector3;
  6067. protected _newPosition: Vector3;
  6068. protected _previousAlpha: number;
  6069. protected _previousBeta: number;
  6070. protected _previousRadius: number;
  6071. protected _collisionTriggered: boolean;
  6072. protected _targetBoundingCenter: Nullable<Vector3>;
  6073. private _computationVector;
  6074. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  6075. _initCache(): void;
  6076. _updateCache(ignoreParentClass?: boolean): void;
  6077. protected _getTargetPosition(): Vector3;
  6078. /**
  6079. * Store current camera state (fov, position, etc..)
  6080. */
  6081. private _storedAlpha;
  6082. private _storedBeta;
  6083. private _storedRadius;
  6084. private _storedTarget;
  6085. storeState(): Camera;
  6086. /**
  6087. * Restored camera state. You must call storeState() first
  6088. */
  6089. _restoreStateValues(): boolean;
  6090. _isSynchronizedViewMatrix(): boolean;
  6091. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  6092. detachControl(element: HTMLElement): void;
  6093. _checkInputs(): void;
  6094. protected _checkLimits(): void;
  6095. rebuildAnglesAndRadius(): void;
  6096. setPosition(position: Vector3): void;
  6097. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  6098. _getViewMatrix(): Matrix;
  6099. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  6100. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  6101. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  6102. min: Vector3;
  6103. max: Vector3;
  6104. distance: number;
  6105. }, doNotUpdateMaxZ?: boolean): void;
  6106. /**
  6107. * @override
  6108. * Override Camera.createRigCamera
  6109. */
  6110. createRigCamera(name: string, cameraIndex: number): Camera;
  6111. /**
  6112. * @override
  6113. * Override Camera._updateRigCameras
  6114. */
  6115. _updateRigCameras(): void;
  6116. dispose(): void;
  6117. getClassName(): string;
  6118. }
  6119. }
  6120. declare module BABYLON {
  6121. class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  6122. constructor(camera: ArcRotateCamera);
  6123. addMouseWheel(): ArcRotateCameraInputsManager;
  6124. addPointers(): ArcRotateCameraInputsManager;
  6125. addKeyboard(): ArcRotateCameraInputsManager;
  6126. addGamepad(): ArcRotateCameraInputsManager;
  6127. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  6128. }
  6129. }
  6130. declare module BABYLON {
  6131. class Camera extends Node {
  6132. inputs: CameraInputsManager<Camera>;
  6133. private static _PERSPECTIVE_CAMERA;
  6134. private static _ORTHOGRAPHIC_CAMERA;
  6135. private static _FOVMODE_VERTICAL_FIXED;
  6136. private static _FOVMODE_HORIZONTAL_FIXED;
  6137. private static _RIG_MODE_NONE;
  6138. private static _RIG_MODE_STEREOSCOPIC_ANAGLYPH;
  6139. private static _RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL;
  6140. private static _RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED;
  6141. private static _RIG_MODE_STEREOSCOPIC_OVERUNDER;
  6142. private static _RIG_MODE_VR;
  6143. private static _RIG_MODE_WEBVR;
  6144. static readonly PERSPECTIVE_CAMERA: number;
  6145. static readonly ORTHOGRAPHIC_CAMERA: number;
  6146. /**
  6147. * This is the default FOV mode for perspective cameras.
  6148. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  6149. *
  6150. */
  6151. static readonly FOVMODE_VERTICAL_FIXED: number;
  6152. /**
  6153. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  6154. *
  6155. */
  6156. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  6157. static readonly RIG_MODE_NONE: number;
  6158. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  6159. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  6160. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  6161. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  6162. static readonly RIG_MODE_VR: number;
  6163. static readonly RIG_MODE_WEBVR: number;
  6164. static ForceAttachControlToAlwaysPreventDefault: boolean;
  6165. static UseAlternateWebVRRendering: boolean;
  6166. position: Vector3;
  6167. /**
  6168. * The vector the camera should consider as up.
  6169. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  6170. */
  6171. upVector: Vector3;
  6172. orthoLeft: Nullable<number>;
  6173. orthoRight: Nullable<number>;
  6174. orthoBottom: Nullable<number>;
  6175. orthoTop: Nullable<number>;
  6176. /**
  6177. * FOV is set in Radians. (default is 0.8)
  6178. */
  6179. fov: number;
  6180. minZ: number;
  6181. maxZ: number;
  6182. inertia: number;
  6183. mode: number;
  6184. isIntermediate: boolean;
  6185. viewport: Viewport;
  6186. /**
  6187. * Restricts the camera to viewing objects with the same layerMask.
  6188. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  6189. */
  6190. layerMask: number;
  6191. /**
  6192. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  6193. */
  6194. fovMode: number;
  6195. cameraRigMode: number;
  6196. interaxialDistance: number;
  6197. isStereoscopicSideBySide: boolean;
  6198. _cameraRigParams: any;
  6199. _rigCameras: Camera[];
  6200. _rigPostProcess: Nullable<PostProcess>;
  6201. protected _webvrViewMatrix: Matrix;
  6202. _skipRendering: boolean;
  6203. _alternateCamera: Camera;
  6204. customRenderTargets: RenderTargetTexture[];
  6205. onViewMatrixChangedObservable: Observable<Camera>;
  6206. onProjectionMatrixChangedObservable: Observable<Camera>;
  6207. onAfterCheckInputsObservable: Observable<Camera>;
  6208. onRestoreStateObservable: Observable<Camera>;
  6209. private _computedViewMatrix;
  6210. _projectionMatrix: Matrix;
  6211. private _doNotComputeProjectionMatrix;
  6212. private _worldMatrix;
  6213. _postProcesses: Nullable<PostProcess>[];
  6214. private _transformMatrix;
  6215. _activeMeshes: SmartArray<AbstractMesh>;
  6216. protected _globalPosition: Vector3;
  6217. private _frustumPlanes;
  6218. private _refreshFrustumPlanes;
  6219. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  6220. private _storedFov;
  6221. private _stateStored;
  6222. /**
  6223. * Store current camera state (fov, position, etc..)
  6224. */
  6225. storeState(): Camera;
  6226. /**
  6227. * Restores the camera state values if it has been stored. You must call storeState() first
  6228. */
  6229. protected _restoreStateValues(): boolean;
  6230. /**
  6231. * Restored camera state. You must call storeState() first
  6232. */
  6233. restoreState(): boolean;
  6234. getClassName(): string;
  6235. /**
  6236. * @param {boolean} fullDetails - support for multiple levels of logging within scene loading
  6237. */
  6238. toString(fullDetails?: boolean): string;
  6239. readonly globalPosition: Vector3;
  6240. getActiveMeshes(): SmartArray<AbstractMesh>;
  6241. isActiveMesh(mesh: Mesh): boolean;
  6242. /**
  6243. * Is this camera ready to be used/rendered
  6244. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  6245. * @return true if the camera is ready
  6246. */
  6247. isReady(completeCheck?: boolean): boolean;
  6248. _initCache(): void;
  6249. _updateCache(ignoreParentClass?: boolean): void;
  6250. _isSynchronized(): boolean;
  6251. _isSynchronizedViewMatrix(): boolean;
  6252. _isSynchronizedProjectionMatrix(): boolean;
  6253. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6254. detachControl(element: HTMLElement): void;
  6255. update(): void;
  6256. _checkInputs(): void;
  6257. readonly rigCameras: Camera[];
  6258. readonly rigPostProcess: Nullable<PostProcess>;
  6259. /**
  6260. * Internal, gets the first post proces.
  6261. * @returns the first post process to be run on this camera.
  6262. */
  6263. _getFirstPostProcess(): Nullable<PostProcess>;
  6264. private _cascadePostProcessesToRigCams();
  6265. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  6266. detachPostProcess(postProcess: PostProcess): void;
  6267. getWorldMatrix(): Matrix;
  6268. _getViewMatrix(): Matrix;
  6269. getViewMatrix(force?: boolean): Matrix;
  6270. freezeProjectionMatrix(projection?: Matrix): void;
  6271. unfreezeProjectionMatrix(): void;
  6272. getProjectionMatrix(force?: boolean): Matrix;
  6273. getTranformationMatrix(): Matrix;
  6274. private updateFrustumPlanes();
  6275. isInFrustum(target: ICullable): boolean;
  6276. isCompletelyInFrustum(target: ICullable): boolean;
  6277. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  6278. /**
  6279. * Releases resources associated with this node.
  6280. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  6281. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  6282. */
  6283. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  6284. readonly leftCamera: Nullable<FreeCamera>;
  6285. readonly rightCamera: Nullable<FreeCamera>;
  6286. getLeftTarget(): Nullable<Vector3>;
  6287. getRightTarget(): Nullable<Vector3>;
  6288. setCameraRigMode(mode: number, rigParams: any): void;
  6289. private _getVRProjectionMatrix();
  6290. protected _updateCameraRotationMatrix(): void;
  6291. protected _updateWebVRCameraRotationMatrix(): void;
  6292. /**
  6293. * This function MUST be overwritten by the different WebVR cameras available.
  6294. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  6295. */
  6296. protected _getWebVRProjectionMatrix(): Matrix;
  6297. /**
  6298. * This function MUST be overwritten by the different WebVR cameras available.
  6299. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  6300. */
  6301. protected _getWebVRViewMatrix(): Matrix;
  6302. setCameraRigParameter(name: string, value: any): void;
  6303. /**
  6304. * needs to be overridden by children so sub has required properties to be copied
  6305. */
  6306. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  6307. /**
  6308. * May need to be overridden by children
  6309. */
  6310. _updateRigCameras(): void;
  6311. _setupInputs(): void;
  6312. serialize(): any;
  6313. clone(name: string): Camera;
  6314. getDirection(localAxis: Vector3): Vector3;
  6315. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  6316. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  6317. computeWorldMatrix(): Matrix;
  6318. static Parse(parsedCamera: any, scene: Scene): Camera;
  6319. }
  6320. }
  6321. declare module BABYLON {
  6322. var CameraInputTypes: {};
  6323. interface ICameraInput<TCamera extends Camera> {
  6324. camera: Nullable<TCamera>;
  6325. getClassName(): string;
  6326. getSimpleName(): string;
  6327. attachControl: (element: HTMLElement, noPreventDefault?: boolean) => void;
  6328. detachControl: (element: Nullable<HTMLElement>) => void;
  6329. checkInputs?: () => void;
  6330. }
  6331. interface CameraInputsMap<TCamera extends Camera> {
  6332. [name: string]: ICameraInput<TCamera>;
  6333. [idx: number]: ICameraInput<TCamera>;
  6334. }
  6335. class CameraInputsManager<TCamera extends Camera> {
  6336. attached: CameraInputsMap<TCamera>;
  6337. attachedElement: Nullable<HTMLElement>;
  6338. noPreventDefault: boolean;
  6339. camera: TCamera;
  6340. checkInputs: () => void;
  6341. constructor(camera: TCamera);
  6342. /**
  6343. * Add an input method to a camera.
  6344. * builtin inputs example: camera.inputs.addGamepad();
  6345. * custom inputs example: camera.inputs.add(new BABYLON.FreeCameraGamepadInput());
  6346. * @param input camera input method
  6347. */
  6348. add(input: ICameraInput<TCamera>): void;
  6349. /**
  6350. * Remove a specific input method from a camera
  6351. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6352. * @param inputToRemove camera input method
  6353. */
  6354. remove(inputToRemove: ICameraInput<TCamera>): void;
  6355. removeByType(inputType: string): void;
  6356. private _addCheckInputs(fn);
  6357. attachInput(input: ICameraInput<TCamera>): void;
  6358. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6359. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6360. rebuildInputCheck(): void;
  6361. /**
  6362. * Remove all attached input methods from a camera
  6363. */
  6364. clear(): void;
  6365. serialize(serializedCamera: any): void;
  6366. parse(parsedCamera: any): void;
  6367. }
  6368. }
  6369. declare module BABYLON {
  6370. /**
  6371. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  6372. * being tilted forward or back and left or right.
  6373. */
  6374. class DeviceOrientationCamera extends FreeCamera {
  6375. private _initialQuaternion;
  6376. private _quaternionCache;
  6377. /**
  6378. * Creates a new device orientation camera
  6379. * @param name The name of the camera
  6380. * @param position The start position camera
  6381. * @param scene The scene the camera belongs to
  6382. */
  6383. constructor(name: string, position: Vector3, scene: Scene);
  6384. /**
  6385. * Gets the current instance class name ("DeviceOrientationCamera").
  6386. * This helps avoiding instanceof at run time.
  6387. * @returns the class name
  6388. */
  6389. getClassName(): string;
  6390. /**
  6391. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  6392. */
  6393. _checkInputs(): void;
  6394. /**
  6395. * Reset the camera to its default orientation on the specified axis only.
  6396. * @param axis The axis to reset
  6397. */
  6398. resetToCurrentRotation(axis?: Axis): void;
  6399. }
  6400. }
  6401. declare module BABYLON {
  6402. class FollowCamera extends TargetCamera {
  6403. radius: number;
  6404. rotationOffset: number;
  6405. heightOffset: number;
  6406. cameraAcceleration: number;
  6407. maxCameraSpeed: number;
  6408. lockedTarget: Nullable<AbstractMesh>;
  6409. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  6410. private getRadians(degrees);
  6411. private follow(cameraTarget);
  6412. _checkInputs(): void;
  6413. getClassName(): string;
  6414. }
  6415. class ArcFollowCamera extends TargetCamera {
  6416. alpha: number;
  6417. beta: number;
  6418. radius: number;
  6419. target: Nullable<AbstractMesh>;
  6420. private _cartesianCoordinates;
  6421. constructor(name: string, alpha: number, beta: number, radius: number, target: Nullable<AbstractMesh>, scene: Scene);
  6422. private follow();
  6423. _checkInputs(): void;
  6424. getClassName(): string;
  6425. }
  6426. }
  6427. declare module BABYLON {
  6428. class FreeCamera extends TargetCamera {
  6429. ellipsoid: Vector3;
  6430. ellipsoidOffset: Vector3;
  6431. checkCollisions: boolean;
  6432. applyGravity: boolean;
  6433. inputs: FreeCameraInputsManager;
  6434. /**
  6435. * Gets the input sensibility for a mouse input. (default is 2000.0)
  6436. * Higher values reduce sensitivity.
  6437. */
  6438. /**
  6439. * Sets the input sensibility for a mouse input. (default is 2000.0)
  6440. * Higher values reduce sensitivity.
  6441. */
  6442. angularSensibility: number;
  6443. keysUp: number[];
  6444. keysDown: number[];
  6445. keysLeft: number[];
  6446. keysRight: number[];
  6447. onCollide: (collidedMesh: AbstractMesh) => void;
  6448. private _collider;
  6449. private _needMoveForGravity;
  6450. private _oldPosition;
  6451. private _diffPosition;
  6452. private _newPosition;
  6453. _localDirection: Vector3;
  6454. _transformedDirection: Vector3;
  6455. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  6456. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6457. detachControl(element: HTMLElement): void;
  6458. private _collisionMask;
  6459. collisionMask: number;
  6460. _collideWithWorld(displacement: Vector3): void;
  6461. private _onCollisionPositionChange;
  6462. _checkInputs(): void;
  6463. _decideIfNeedsToMove(): boolean;
  6464. _updatePosition(): void;
  6465. dispose(): void;
  6466. getClassName(): string;
  6467. }
  6468. }
  6469. declare module BABYLON {
  6470. class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  6471. constructor(camera: FreeCamera);
  6472. addKeyboard(): FreeCameraInputsManager;
  6473. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  6474. addGamepad(): FreeCameraInputsManager;
  6475. addDeviceOrientation(): FreeCameraInputsManager;
  6476. addTouch(): FreeCameraInputsManager;
  6477. addVirtualJoystick(): FreeCameraInputsManager;
  6478. }
  6479. }
  6480. declare module BABYLON {
  6481. class GamepadCamera extends UniversalCamera {
  6482. gamepadAngularSensibility: number;
  6483. gamepadMoveSensibility: number;
  6484. constructor(name: string, position: Vector3, scene: Scene);
  6485. getClassName(): string;
  6486. }
  6487. }
  6488. declare module BABYLON {
  6489. /**
  6490. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  6491. */
  6492. class AnaglyphFreeCamera extends FreeCamera {
  6493. /**
  6494. * Creates a new AnaglyphFreeCamera
  6495. * @param name defines camera name
  6496. * @param position defines initial position
  6497. * @param interaxialDistance defines distance between each color axis
  6498. * @param scene defines the hosting scene
  6499. */
  6500. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  6501. /**
  6502. * Gets camera class name
  6503. * @returns AnaglyphFreeCamera
  6504. */
  6505. getClassName(): string;
  6506. }
  6507. /**
  6508. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  6509. */
  6510. class AnaglyphArcRotateCamera extends ArcRotateCamera {
  6511. /**
  6512. * Creates a new AnaglyphArcRotateCamera
  6513. * @param name defines camera name
  6514. * @param alpha defines alpha angle (in radians)
  6515. * @param beta defines beta angle (in radians)
  6516. * @param radius defines radius
  6517. * @param target defines camera target
  6518. * @param interaxialDistance defines distance between each color axis
  6519. * @param scene defines the hosting scene
  6520. */
  6521. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  6522. /**
  6523. * Gets camera class name
  6524. * @returns AnaglyphArcRotateCamera
  6525. */
  6526. getClassName(): string;
  6527. }
  6528. /**
  6529. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  6530. */
  6531. class AnaglyphGamepadCamera extends GamepadCamera {
  6532. /**
  6533. * Creates a new AnaglyphGamepadCamera
  6534. * @param name defines camera name
  6535. * @param position defines initial position
  6536. * @param interaxialDistance defines distance between each color axis
  6537. * @param scene defines the hosting scene
  6538. */
  6539. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  6540. /**
  6541. * Gets camera class name
  6542. * @returns AnaglyphGamepadCamera
  6543. */
  6544. getClassName(): string;
  6545. }
  6546. /**
  6547. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  6548. */
  6549. class AnaglyphUniversalCamera extends UniversalCamera {
  6550. /**
  6551. * Creates a new AnaglyphUniversalCamera
  6552. * @param name defines camera name
  6553. * @param position defines initial position
  6554. * @param interaxialDistance defines distance between each color axis
  6555. * @param scene defines the hosting scene
  6556. */
  6557. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  6558. /**
  6559. * Gets camera class name
  6560. * @returns AnaglyphUniversalCamera
  6561. */
  6562. getClassName(): string;
  6563. }
  6564. /**
  6565. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  6566. */
  6567. class StereoscopicFreeCamera extends FreeCamera {
  6568. /**
  6569. * Creates a new StereoscopicFreeCamera
  6570. * @param name defines camera name
  6571. * @param position defines initial position
  6572. * @param interaxialDistance defines distance between each color axis
  6573. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  6574. * @param scene defines the hosting scene
  6575. */
  6576. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  6577. /**
  6578. * Gets camera class name
  6579. * @returns StereoscopicFreeCamera
  6580. */
  6581. getClassName(): string;
  6582. }
  6583. /**
  6584. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  6585. */
  6586. class StereoscopicArcRotateCamera extends ArcRotateCamera {
  6587. /**
  6588. * Creates a new StereoscopicArcRotateCamera
  6589. * @param name defines camera name
  6590. * @param alpha defines alpha angle (in radians)
  6591. * @param beta defines beta angle (in radians)
  6592. * @param radius defines radius
  6593. * @param target defines camera target
  6594. * @param interaxialDistance defines distance between each color axis
  6595. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  6596. * @param scene defines the hosting scene
  6597. */
  6598. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  6599. /**
  6600. * Gets camera class name
  6601. * @returns StereoscopicArcRotateCamera
  6602. */
  6603. getClassName(): string;
  6604. }
  6605. /**
  6606. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  6607. */
  6608. class StereoscopicGamepadCamera extends GamepadCamera {
  6609. /**
  6610. * Creates a new StereoscopicGamepadCamera
  6611. * @param name defines camera name
  6612. * @param position defines initial position
  6613. * @param interaxialDistance defines distance between each color axis
  6614. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  6615. * @param scene defines the hosting scene
  6616. */
  6617. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  6618. /**
  6619. * Gets camera class name
  6620. * @returns StereoscopicGamepadCamera
  6621. */
  6622. getClassName(): string;
  6623. }
  6624. /**
  6625. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  6626. */
  6627. class StereoscopicUniversalCamera extends UniversalCamera {
  6628. /**
  6629. * Creates a new StereoscopicUniversalCamera
  6630. * @param name defines camera name
  6631. * @param position defines initial position
  6632. * @param interaxialDistance defines distance between each color axis
  6633. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  6634. * @param scene defines the hosting scene
  6635. */
  6636. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  6637. /**
  6638. * Gets camera class name
  6639. * @returns StereoscopicUniversalCamera
  6640. */
  6641. getClassName(): string;
  6642. }
  6643. }
  6644. declare module BABYLON {
  6645. class TargetCamera extends Camera {
  6646. cameraDirection: Vector3;
  6647. cameraRotation: Vector2;
  6648. rotation: Vector3;
  6649. rotationQuaternion: Quaternion;
  6650. speed: number;
  6651. noRotationConstraint: boolean;
  6652. lockedTarget: any;
  6653. _currentTarget: Vector3;
  6654. _viewMatrix: Matrix;
  6655. _camMatrix: Matrix;
  6656. _cameraTransformMatrix: Matrix;
  6657. _cameraRotationMatrix: Matrix;
  6658. private _rigCamTransformMatrix;
  6659. _referencePoint: Vector3;
  6660. private _currentUpVector;
  6661. _transformedReferencePoint: Vector3;
  6662. protected _globalCurrentTarget: Vector3;
  6663. protected _globalCurrentUpVector: Vector3;
  6664. _reset: () => void;
  6665. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  6666. getFrontPosition(distance: number): Vector3;
  6667. _getLockedTargetPosition(): Nullable<Vector3>;
  6668. /**
  6669. * Store current camera state (fov, position, etc..)
  6670. */
  6671. private _storedPosition;
  6672. private _storedRotation;
  6673. private _storedRotationQuaternion;
  6674. storeState(): Camera;
  6675. /**
  6676. * Restored camera state. You must call storeState() first
  6677. */
  6678. _restoreStateValues(): boolean;
  6679. _initCache(): void;
  6680. _updateCache(ignoreParentClass?: boolean): void;
  6681. _isSynchronizedViewMatrix(): boolean;
  6682. _computeLocalCameraSpeed(): number;
  6683. setTarget(target: Vector3): void;
  6684. /**
  6685. * Return the current target position of the camera. This value is expressed in local space.
  6686. */
  6687. getTarget(): Vector3;
  6688. _decideIfNeedsToMove(): boolean;
  6689. _updatePosition(): void;
  6690. _checkInputs(): void;
  6691. protected _updateCameraRotationMatrix(): void;
  6692. _getViewMatrix(): Matrix;
  6693. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  6694. /**
  6695. * @override
  6696. * Override Camera.createRigCamera
  6697. */
  6698. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  6699. /**
  6700. * @override
  6701. * Override Camera._updateRigCameras
  6702. */
  6703. _updateRigCameras(): void;
  6704. private _getRigCamPosition(halfSpace, result);
  6705. getClassName(): string;
  6706. }
  6707. }
  6708. declare module BABYLON {
  6709. class TouchCamera extends FreeCamera {
  6710. touchAngularSensibility: number;
  6711. touchMoveSensibility: number;
  6712. constructor(name: string, position: Vector3, scene: Scene);
  6713. getClassName(): string;
  6714. _setupInputs(): void;
  6715. }
  6716. }
  6717. declare module BABYLON {
  6718. class UniversalCamera extends TouchCamera {
  6719. gamepadAngularSensibility: number;
  6720. gamepadMoveSensibility: number;
  6721. constructor(name: string, position: Vector3, scene: Scene);
  6722. getClassName(): string;
  6723. }
  6724. }
  6725. declare module BABYLON {
  6726. class VirtualJoysticksCamera extends FreeCamera {
  6727. constructor(name: string, position: Vector3, scene: Scene);
  6728. getClassName(): string;
  6729. }
  6730. }
  6731. interface VRDisplay extends EventTarget {
  6732. /**
  6733. * Dictionary of capabilities describing the VRDisplay.
  6734. */
  6735. readonly capabilities: VRDisplayCapabilities;
  6736. /**
  6737. * z-depth defining the far plane of the eye view frustum
  6738. * enables mapping of values in the render target depth
  6739. * attachment to scene coordinates. Initially set to 10000.0.
  6740. */
  6741. depthFar: number;
  6742. /**
  6743. * z-depth defining the near plane of the eye view frustum
  6744. * enables mapping of values in the render target depth
  6745. * attachment to scene coordinates. Initially set to 0.01.
  6746. */
  6747. depthNear: number;
  6748. /**
  6749. * An identifier for this distinct VRDisplay. Used as an
  6750. * association point in the Gamepad API.
  6751. */
  6752. readonly displayId: number;
  6753. /**
  6754. * A display name, a user-readable name identifying it.
  6755. */
  6756. readonly displayName: string;
  6757. readonly isConnected: boolean;
  6758. readonly isPresenting: boolean;
  6759. /**
  6760. * If this VRDisplay supports room-scale experiences, the optional
  6761. * stage attribute contains details on the room-scale parameters.
  6762. */
  6763. readonly stageParameters: VRStageParameters | null;
  6764. /**
  6765. * Passing the value returned by `requestAnimationFrame` to
  6766. * `cancelAnimationFrame` will unregister the callback.
  6767. */
  6768. cancelAnimationFrame(handle: number): void;
  6769. /**
  6770. * Stops presenting to the VRDisplay.
  6771. */
  6772. exitPresent(): Promise<void>;
  6773. getEyeParameters(whichEye: string): VREyeParameters;
  6774. /**
  6775. * Populates the passed VRFrameData with the information required to render
  6776. * the current frame.
  6777. */
  6778. getFrameData(frameData: VRFrameData): boolean;
  6779. /**
  6780. * Get the layers currently being presented.
  6781. */
  6782. getLayers(): VRLayer[];
  6783. /**
  6784. * Return a VRPose containing the future predicted pose of the VRDisplay
  6785. * when the current frame will be presented. The value returned will not
  6786. * change until JavaScript has returned control to the browser.
  6787. *
  6788. * The VRPose will contain the position, orientation, velocity,
  6789. * and acceleration of each of these properties.
  6790. */
  6791. getPose(): VRPose;
  6792. /**
  6793. * Return the current instantaneous pose of the VRDisplay, with no
  6794. * prediction applied.
  6795. */
  6796. getImmediatePose(): VRPose;
  6797. /**
  6798. * The callback passed to `requestAnimationFrame` will be called
  6799. * any time a new frame should be rendered. When the VRDisplay is
  6800. * presenting the callback will be called at the native refresh
  6801. * rate of the HMD. When not presenting this function acts
  6802. * identically to how window.requestAnimationFrame acts. Content should
  6803. * make no assumptions of frame rate or vsync behavior as the HMD runs
  6804. * asynchronously from other displays and at differing refresh rates.
  6805. */
  6806. requestAnimationFrame(callback: FrameRequestCallback): number;
  6807. /**
  6808. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  6809. * Repeat calls while already presenting will update the VRLayers being displayed.
  6810. */
  6811. requestPresent(layers: VRLayer[]): Promise<void>;
  6812. /**
  6813. * Reset the pose for this display, treating its current position and
  6814. * orientation as the "origin/zero" values. VRPose.position,
  6815. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  6816. * updated when calling resetPose(). This should be called in only
  6817. * sitting-space experiences.
  6818. */
  6819. resetPose(): void;
  6820. /**
  6821. * The VRLayer provided to the VRDisplay will be captured and presented
  6822. * in the HMD. Calling this function has the same effect on the source
  6823. * canvas as any other operation that uses its source image, and canvases
  6824. * created without preserveDrawingBuffer set to true will be cleared.
  6825. */
  6826. submitFrame(pose?: VRPose): void;
  6827. }
  6828. declare var VRDisplay: {
  6829. prototype: VRDisplay;
  6830. new (): VRDisplay;
  6831. };
  6832. interface VRLayer {
  6833. leftBounds?: number[] | null;
  6834. rightBounds?: number[] | null;
  6835. source?: HTMLCanvasElement | null;
  6836. }
  6837. interface VRDisplayCapabilities {
  6838. readonly canPresent: boolean;
  6839. readonly hasExternalDisplay: boolean;
  6840. readonly hasOrientation: boolean;
  6841. readonly hasPosition: boolean;
  6842. readonly maxLayers: number;
  6843. }
  6844. interface VREyeParameters {
  6845. /** @deprecated */
  6846. readonly fieldOfView: VRFieldOfView;
  6847. readonly offset: Float32Array;
  6848. readonly renderHeight: number;
  6849. readonly renderWidth: number;
  6850. }
  6851. interface VRFieldOfView {
  6852. readonly downDegrees: number;
  6853. readonly leftDegrees: number;
  6854. readonly rightDegrees: number;
  6855. readonly upDegrees: number;
  6856. }
  6857. interface VRFrameData {
  6858. readonly leftProjectionMatrix: Float32Array;
  6859. readonly leftViewMatrix: Float32Array;
  6860. readonly pose: VRPose;
  6861. readonly rightProjectionMatrix: Float32Array;
  6862. readonly rightViewMatrix: Float32Array;
  6863. readonly timestamp: number;
  6864. }
  6865. interface VRPose {
  6866. readonly angularAcceleration: Float32Array | null;
  6867. readonly angularVelocity: Float32Array | null;
  6868. readonly linearAcceleration: Float32Array | null;
  6869. readonly linearVelocity: Float32Array | null;
  6870. readonly orientation: Float32Array | null;
  6871. readonly position: Float32Array | null;
  6872. readonly timestamp: number;
  6873. }
  6874. interface VRStageParameters {
  6875. sittingToStandingTransform?: Float32Array;
  6876. sizeX?: number;
  6877. sizeY?: number;
  6878. }
  6879. interface Navigator {
  6880. getVRDisplays(): Promise<VRDisplay[]>;
  6881. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  6882. }
  6883. interface Window {
  6884. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  6885. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  6886. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  6887. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  6888. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  6889. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  6890. }
  6891. interface Gamepad {
  6892. readonly displayId: number;
  6893. }
  6894. declare module BABYLON {
  6895. class KeyboardEventTypes {
  6896. static _KEYDOWN: number;
  6897. static _KEYUP: number;
  6898. static readonly KEYDOWN: number;
  6899. static readonly KEYUP: number;
  6900. }
  6901. class KeyboardInfo {
  6902. type: number;
  6903. event: KeyboardEvent;
  6904. constructor(type: number, event: KeyboardEvent);
  6905. }
  6906. /**
  6907. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  6908. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  6909. */
  6910. class KeyboardInfoPre extends KeyboardInfo {
  6911. constructor(type: number, event: KeyboardEvent);
  6912. skipOnPointerObservable: boolean;
  6913. }
  6914. }
  6915. declare module BABYLON {
  6916. class PointerEventTypes {
  6917. static _POINTERDOWN: number;
  6918. static _POINTERUP: number;
  6919. static _POINTERMOVE: number;
  6920. static _POINTERWHEEL: number;
  6921. static _POINTERPICK: number;
  6922. static _POINTERTAP: number;
  6923. static _POINTERDOUBLETAP: number;
  6924. static readonly POINTERDOWN: number;
  6925. static readonly POINTERUP: number;
  6926. static readonly POINTERMOVE: number;
  6927. static readonly POINTERWHEEL: number;
  6928. static readonly POINTERPICK: number;
  6929. static readonly POINTERTAP: number;
  6930. static readonly POINTERDOUBLETAP: number;
  6931. }
  6932. class PointerInfoBase {
  6933. type: number;
  6934. event: PointerEvent | MouseWheelEvent;
  6935. constructor(type: number, event: PointerEvent | MouseWheelEvent);
  6936. }
  6937. /**
  6938. * This class is used to store pointer related info for the onPrePointerObservable event.
  6939. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  6940. */
  6941. class PointerInfoPre extends PointerInfoBase {
  6942. /**
  6943. * Ray from a pointer if availible (eg. 6dof controller)
  6944. */
  6945. ray: Nullable<Ray>;
  6946. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  6947. localPosition: Vector2;
  6948. skipOnPointerObservable: boolean;
  6949. }
  6950. /**
  6951. * This type contains all the data related to a pointer event in Babylon.js.
  6952. * 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.
  6953. */
  6954. class PointerInfo extends PointerInfoBase {
  6955. pickInfo: Nullable<PickingInfo>;
  6956. constructor(type: number, event: PointerEvent | MouseWheelEvent, pickInfo: Nullable<PickingInfo>);
  6957. }
  6958. }
  6959. declare module BABYLON {
  6960. class StickValues {
  6961. x: number;
  6962. y: number;
  6963. constructor(x: number, y: number);
  6964. }
  6965. interface GamepadButtonChanges {
  6966. changed: boolean;
  6967. pressChanged: boolean;
  6968. touchChanged: boolean;
  6969. valueChanged: boolean;
  6970. }
  6971. class Gamepad {
  6972. id: string;
  6973. index: number;
  6974. browserGamepad: any;
  6975. type: number;
  6976. private _leftStick;
  6977. private _rightStick;
  6978. _isConnected: boolean;
  6979. private _leftStickAxisX;
  6980. private _leftStickAxisY;
  6981. private _rightStickAxisX;
  6982. private _rightStickAxisY;
  6983. private _onleftstickchanged;
  6984. private _onrightstickchanged;
  6985. static GAMEPAD: number;
  6986. static GENERIC: number;
  6987. static XBOX: number;
  6988. static POSE_ENABLED: number;
  6989. protected _invertLeftStickY: boolean;
  6990. readonly isConnected: boolean;
  6991. constructor(id: string, index: number, browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  6992. onleftstickchanged(callback: (values: StickValues) => void): void;
  6993. onrightstickchanged(callback: (values: StickValues) => void): void;
  6994. leftStick: StickValues;
  6995. rightStick: StickValues;
  6996. update(): void;
  6997. dispose(): void;
  6998. }
  6999. class GenericPad extends Gamepad {
  7000. private _buttons;
  7001. private _onbuttondown;
  7002. private _onbuttonup;
  7003. onButtonDownObservable: Observable<number>;
  7004. onButtonUpObservable: Observable<number>;
  7005. onbuttondown(callback: (buttonPressed: number) => void): void;
  7006. onbuttonup(callback: (buttonReleased: number) => void): void;
  7007. constructor(id: string, index: number, browserGamepad: any);
  7008. private _setButtonValue(newValue, currentValue, buttonIndex);
  7009. update(): void;
  7010. dispose(): void;
  7011. }
  7012. }
  7013. declare module BABYLON {
  7014. class GamepadManager {
  7015. private _scene;
  7016. private _babylonGamepads;
  7017. private _oneGamepadConnected;
  7018. _isMonitoring: boolean;
  7019. private _gamepadEventSupported;
  7020. private _gamepadSupport;
  7021. onGamepadConnectedObservable: Observable<Gamepad>;
  7022. onGamepadDisconnectedObservable: Observable<Gamepad>;
  7023. private _onGamepadConnectedEvent;
  7024. private _onGamepadDisconnectedEvent;
  7025. constructor(_scene?: Scene | undefined);
  7026. readonly gamepads: Gamepad[];
  7027. getGamepadByType(type?: number): Nullable<Gamepad>;
  7028. dispose(): void;
  7029. private _addNewGamepad(gamepad);
  7030. private _startMonitoringGamepads();
  7031. private _stopMonitoringGamepads();
  7032. _checkGamepadsStatus(): void;
  7033. private _updateGamepadObjects();
  7034. }
  7035. }
  7036. declare module BABYLON {
  7037. /**
  7038. * Defines supported buttons for XBox360 compatible gamepads
  7039. */
  7040. enum Xbox360Button {
  7041. /** A */
  7042. A = 0,
  7043. /** B */
  7044. B = 1,
  7045. /** X */
  7046. X = 2,
  7047. /** Y */
  7048. Y = 3,
  7049. /** Start */
  7050. Start = 4,
  7051. /** Back */
  7052. Back = 5,
  7053. /** Left button */
  7054. LB = 6,
  7055. /** Right button */
  7056. RB = 7,
  7057. /** Left stick */
  7058. LeftStick = 8,
  7059. /** Right stick */
  7060. RightStick = 9,
  7061. }
  7062. /** Defines values for XBox360 DPad */
  7063. enum Xbox360Dpad {
  7064. /** Up */
  7065. Up = 0,
  7066. /** Down */
  7067. Down = 1,
  7068. /** Left */
  7069. Left = 2,
  7070. /** Right */
  7071. Right = 3,
  7072. }
  7073. /**
  7074. * Defines a XBox360 gamepad
  7075. */
  7076. class Xbox360Pad extends Gamepad {
  7077. private _leftTrigger;
  7078. private _rightTrigger;
  7079. private _onlefttriggerchanged;
  7080. private _onrighttriggerchanged;
  7081. private _onbuttondown;
  7082. private _onbuttonup;
  7083. private _ondpaddown;
  7084. private _ondpadup;
  7085. /** Observable raised when a button is pressed */
  7086. onButtonDownObservable: Observable<Xbox360Button>;
  7087. /** Observable raised when a button is released */
  7088. onButtonUpObservable: Observable<Xbox360Button>;
  7089. /** Observable raised when a pad is pressed */
  7090. onPadDownObservable: Observable<Xbox360Dpad>;
  7091. /** Observable raised when a pad is released */
  7092. onPadUpObservable: Observable<Xbox360Dpad>;
  7093. private _buttonA;
  7094. private _buttonB;
  7095. private _buttonX;
  7096. private _buttonY;
  7097. private _buttonBack;
  7098. private _buttonStart;
  7099. private _buttonLB;
  7100. private _buttonRB;
  7101. private _buttonLeftStick;
  7102. private _buttonRightStick;
  7103. private _dPadUp;
  7104. private _dPadDown;
  7105. private _dPadLeft;
  7106. private _dPadRight;
  7107. private _isXboxOnePad;
  7108. /**
  7109. * Creates a new XBox360 gamepad object
  7110. * @param id defines the id of this gamepad
  7111. * @param index defines its index
  7112. * @param gamepad defines the internal HTML gamepad object
  7113. * @param xboxOne defines if it is a XBox One gamepad
  7114. */
  7115. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  7116. /**
  7117. * Defines the callback to call when left trigger is pressed
  7118. * @param callback defines the callback to use
  7119. */
  7120. onlefttriggerchanged(callback: (value: number) => void): void;
  7121. /**
  7122. * Defines the callback to call when right trigger is pressed
  7123. * @param callback defines the callback to use
  7124. */
  7125. onrighttriggerchanged(callback: (value: number) => void): void;
  7126. /**
  7127. * Gets or sets left trigger value
  7128. */
  7129. leftTrigger: number;
  7130. /**
  7131. * Gets or sets right trigger value
  7132. */
  7133. rightTrigger: number;
  7134. /**
  7135. * Defines the callback to call when a button is pressed
  7136. * @param callback defines the callback to use
  7137. */
  7138. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  7139. /**
  7140. * Defines the callback to call when a button is released
  7141. * @param callback defines the callback to use
  7142. */
  7143. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  7144. /**
  7145. * Defines the callback to call when a pad is pressed
  7146. * @param callback defines the callback to use
  7147. */
  7148. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  7149. /**
  7150. * Defines the callback to call when a pad is released
  7151. * @param callback defines the callback to use
  7152. */
  7153. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  7154. private _setButtonValue(newValue, currentValue, buttonType);
  7155. private _setDPadValue(newValue, currentValue, buttonType);
  7156. /** Gets or sets value of A button */
  7157. buttonA: number;
  7158. /** Gets or sets value of B button */
  7159. buttonB: number;
  7160. /** Gets or sets value of X button */
  7161. buttonX: number;
  7162. /** Gets or sets value of Y button */
  7163. buttonY: number;
  7164. /** Gets or sets value of Start button */
  7165. buttonStart: number;
  7166. /** Gets or sets value of Back button */
  7167. buttonBack: number;
  7168. /** Gets or sets value of Left button */
  7169. buttonLB: number;
  7170. /** Gets or sets value of Right button */
  7171. buttonRB: number;
  7172. /** Gets or sets value of left stick */
  7173. buttonLeftStick: number;
  7174. /** Gets or sets value of right stick */
  7175. buttonRightStick: number;
  7176. /** Gets or sets value of DPad up */
  7177. dPadUp: number;
  7178. /** Gets or sets value of DPad down */
  7179. dPadDown: number;
  7180. /** Gets or sets value of DPad left */
  7181. dPadLeft: number;
  7182. /** Gets or sets value of DPad right */
  7183. dPadRight: number;
  7184. /**
  7185. * Force the gamepad to synchronize with device values
  7186. */
  7187. update(): void;
  7188. dispose(): void;
  7189. }
  7190. }
  7191. declare module BABYLON {
  7192. /**
  7193. * Interface for attribute information associated with buffer instanciation
  7194. */
  7195. class InstancingAttributeInfo {
  7196. /**
  7197. * Index/offset of the attribute in the vertex shader
  7198. */
  7199. index: number;
  7200. /**
  7201. * size of the attribute, 1, 2, 3 or 4
  7202. */
  7203. attributeSize: number;
  7204. /**
  7205. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  7206. * default is FLOAT
  7207. */
  7208. attribyteType: number;
  7209. /**
  7210. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  7211. */
  7212. normalized: boolean;
  7213. /**
  7214. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  7215. */
  7216. offset: number;
  7217. /**
  7218. * Name of the GLSL attribute, for debugging purpose only
  7219. */
  7220. attributeName: string;
  7221. }
  7222. /**
  7223. * Define options used to create a render target texture
  7224. */
  7225. class RenderTargetCreationOptions {
  7226. /**
  7227. * Specifies is mipmaps must be generated
  7228. */
  7229. generateMipMaps?: boolean;
  7230. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  7231. generateDepthBuffer?: boolean;
  7232. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  7233. generateStencilBuffer?: boolean;
  7234. /** Defines texture type (int by default) */
  7235. type?: number;
  7236. /** Defines sampling mode (trilinear by default) */
  7237. samplingMode?: number;
  7238. /** Defines format (RGBA by default) */
  7239. format?: number;
  7240. }
  7241. /**
  7242. * Define options used to create a depth texture
  7243. */
  7244. class DepthTextureCreationOptions {
  7245. /** Specifies whether or not a stencil should be allocated in the texture */
  7246. generateStencil?: boolean;
  7247. /** Specifies whether or not bilinear filtering is enable on the texture */
  7248. bilinearFiltering?: boolean;
  7249. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7250. comparisonFunction?: number;
  7251. /** Specifies if the created texture is a cube texture */
  7252. isCube?: boolean;
  7253. }
  7254. /**
  7255. * Class used to describe the capabilities of the engine relatively to the current browser
  7256. */
  7257. class EngineCapabilities {
  7258. /** Maximum textures units per fragment shader */
  7259. maxTexturesImageUnits: number;
  7260. /** Maximum texture units per vertex shader */
  7261. maxVertexTextureImageUnits: number;
  7262. /** Maximum textures units in the entire pipeline */
  7263. maxCombinedTexturesImageUnits: number;
  7264. /** Maximum texture size */
  7265. maxTextureSize: number;
  7266. /** Maximum cube texture size */
  7267. maxCubemapTextureSize: number;
  7268. /** Maximum render texture size */
  7269. maxRenderTextureSize: number;
  7270. /** Maximum number of vertex attributes */
  7271. maxVertexAttribs: number;
  7272. /** Maximum number of varyings */
  7273. maxVaryingVectors: number;
  7274. /** Maximum number of uniforms per vertex shader */
  7275. maxVertexUniformVectors: number;
  7276. /** Maximum number of uniforms per fragment shader */
  7277. maxFragmentUniformVectors: number;
  7278. /** Defines if standard derivates (dx/dy) are supported */
  7279. standardDerivatives: boolean;
  7280. /** Defines if s3tc texture compression is supported */
  7281. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  7282. /** Defines if pvrtc texture compression is supported */
  7283. pvrtc: any;
  7284. /** Defines if etc1 texture compression is supported */
  7285. etc1: any;
  7286. /** Defines if etc2 texture compression is supported */
  7287. etc2: any;
  7288. /** Defines if astc texture compression is supported */
  7289. astc: any;
  7290. /** Defines if float textures are supported */
  7291. textureFloat: boolean;
  7292. /** Defines if vertex array objects are supported */
  7293. vertexArrayObject: boolean;
  7294. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  7295. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  7296. /** Gets the maximum level of anisotropy supported */
  7297. maxAnisotropy: number;
  7298. /** Defines if instancing is supported */
  7299. instancedArrays: boolean;
  7300. /** Defines if 32 bits indices are supported */
  7301. uintIndices: boolean;
  7302. /** Defines if high precision shaders are supported */
  7303. highPrecisionShaderSupported: boolean;
  7304. /** Defines if depth reading in the fragment shader is supported */
  7305. fragmentDepthSupported: boolean;
  7306. /** Defines if float texture linear filtering is supported*/
  7307. textureFloatLinearFiltering: boolean;
  7308. /** Defines if rendering to float textures is supported */
  7309. textureFloatRender: boolean;
  7310. /** Defines if half float textures are supported*/
  7311. textureHalfFloat: boolean;
  7312. /** Defines if half float texture linear filtering is supported*/
  7313. textureHalfFloatLinearFiltering: boolean;
  7314. /** Defines if rendering to half float textures is supported */
  7315. textureHalfFloatRender: boolean;
  7316. /** Defines if textureLOD shader command is supported */
  7317. textureLOD: boolean;
  7318. /** Defines if draw buffers extension is supported */
  7319. drawBuffersExtension: boolean;
  7320. /** Defines if depth textures are supported */
  7321. depthTextureExtension: boolean;
  7322. /** Defines if float color buffer are supported */
  7323. colorBufferFloat: boolean;
  7324. /** Gets disjoint timer query extension (null if not supported) */
  7325. timerQuery: EXT_disjoint_timer_query;
  7326. /** Defines if timestamp can be used with timer query */
  7327. canUseTimestampForTimerQuery: boolean;
  7328. }
  7329. /** Interface defining initialization parameters for Engine class */
  7330. interface EngineOptions extends WebGLContextAttributes {
  7331. /**
  7332. * Defines if the engine should no exceed a specified device ratio
  7333. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  7334. */
  7335. limitDeviceRatio?: number;
  7336. /**
  7337. * Defines if webvr should be enabled automatically
  7338. * @see http://doc.babylonjs.com/how_to/webvr_camera
  7339. */
  7340. autoEnableWebVR?: boolean;
  7341. /**
  7342. * Defines if webgl2 should be turned off even if supported
  7343. * @see http://doc.babylonjs.com/features/webgl2
  7344. */
  7345. disableWebGL2Support?: boolean;
  7346. /**
  7347. * Defines if webaudio should be initialized as well
  7348. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  7349. */
  7350. audioEngine?: boolean;
  7351. /**
  7352. * Defines if animations should run using a deterministic lock step
  7353. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  7354. */
  7355. deterministicLockstep?: boolean;
  7356. /** Defines the maximum steps to use with deterministic lock step mode */
  7357. lockstepMaxSteps?: number;
  7358. /**
  7359. * Defines that engine should ignore context lost events
  7360. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  7361. */
  7362. doNotHandleContextLost?: boolean;
  7363. }
  7364. /**
  7365. * Defines the interface used by display changed events
  7366. */
  7367. interface IDisplayChangedEventArgs {
  7368. /** Gets the vrDisplay object (if any) */
  7369. vrDisplay: Nullable<any>;
  7370. /** Gets a boolean indicating if webVR is supported */
  7371. vrSupported: boolean;
  7372. }
  7373. /**
  7374. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  7375. */
  7376. class Engine {
  7377. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  7378. static ExceptionList: ({
  7379. key: string;
  7380. capture: string;
  7381. captureConstraint: number;
  7382. targets: string[];
  7383. } | {
  7384. key: string;
  7385. capture: null;
  7386. captureConstraint: null;
  7387. targets: string[];
  7388. })[];
  7389. /** Gets the list of created engines */
  7390. static Instances: Engine[];
  7391. /**
  7392. * Gets the latest created engine
  7393. */
  7394. static readonly LastCreatedEngine: Nullable<Engine>;
  7395. /**
  7396. * Gets the latest created scene
  7397. */
  7398. static readonly LastCreatedScene: Nullable<Scene>;
  7399. /**
  7400. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  7401. * @param flag defines which part of the materials must be marked as dirty
  7402. * @param predicate defines a predicate used to filter which materials should be affected
  7403. */
  7404. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  7405. private static _ALPHA_DISABLE;
  7406. private static _ALPHA_ADD;
  7407. private static _ALPHA_COMBINE;
  7408. private static _ALPHA_SUBTRACT;
  7409. private static _ALPHA_MULTIPLY;
  7410. private static _ALPHA_MAXIMIZED;
  7411. private static _ALPHA_ONEONE;
  7412. private static _ALPHA_PREMULTIPLIED;
  7413. private static _ALPHA_PREMULTIPLIED_PORTERDUFF;
  7414. private static _ALPHA_INTERPOLATE;
  7415. private static _ALPHA_SCREENMODE;
  7416. private static _DELAYLOADSTATE_NONE;
  7417. private static _DELAYLOADSTATE_LOADED;
  7418. private static _DELAYLOADSTATE_LOADING;
  7419. private static _DELAYLOADSTATE_NOTLOADED;
  7420. private static _TEXTUREFORMAT_ALPHA;
  7421. private static _TEXTUREFORMAT_LUMINANCE;
  7422. private static _TEXTUREFORMAT_LUMINANCE_ALPHA;
  7423. private static _TEXTUREFORMAT_RGB;
  7424. private static _TEXTUREFORMAT_RGBA;
  7425. private static _TEXTUREFORMAT_R32F;
  7426. private static _TEXTUREFORMAT_RG32F;
  7427. private static _TEXTUREFORMAT_RGB32F;
  7428. private static _TEXTUREFORMAT_RGBA32F;
  7429. private static _TEXTURETYPE_UNSIGNED_INT;
  7430. private static _TEXTURETYPE_FLOAT;
  7431. private static _TEXTURETYPE_HALF_FLOAT;
  7432. private static _NEVER;
  7433. private static _ALWAYS;
  7434. private static _LESS;
  7435. private static _EQUAL;
  7436. private static _LEQUAL;
  7437. private static _GREATER;
  7438. private static _GEQUAL;
  7439. private static _NOTEQUAL;
  7440. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  7441. static readonly NEVER: number;
  7442. /** 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 */
  7443. static readonly ALWAYS: number;
  7444. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  7445. static readonly LESS: number;
  7446. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  7447. static readonly EQUAL: number;
  7448. /** 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 */
  7449. static readonly LEQUAL: number;
  7450. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  7451. static readonly GREATER: number;
  7452. /** 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 */
  7453. static readonly GEQUAL: number;
  7454. /** 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 */
  7455. static readonly NOTEQUAL: number;
  7456. private static _KEEP;
  7457. private static _REPLACE;
  7458. private static _INCR;
  7459. private static _DECR;
  7460. private static _INVERT;
  7461. private static _INCR_WRAP;
  7462. private static _DECR_WRAP;
  7463. /** Passed to stencilOperation to specify that stencil value must be kept */
  7464. static readonly KEEP: number;
  7465. /** Passed to stencilOperation to specify that stencil value must be replaced */
  7466. static readonly REPLACE: number;
  7467. /** Passed to stencilOperation to specify that stencil value must be incremented */
  7468. static readonly INCR: number;
  7469. /** Passed to stencilOperation to specify that stencil value must be decremented */
  7470. static readonly DECR: number;
  7471. /** Passed to stencilOperation to specify that stencil value must be inverted */
  7472. static readonly INVERT: number;
  7473. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  7474. static readonly INCR_WRAP: number;
  7475. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  7476. static readonly DECR_WRAP: number;
  7477. /** Defines that alpha blending is disabled */
  7478. static readonly ALPHA_DISABLE: number;
  7479. /** Defines that alpha blending to SRC + DEST */
  7480. static readonly ALPHA_ONEONE: number;
  7481. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  7482. static readonly ALPHA_ADD: number;
  7483. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  7484. static readonly ALPHA_COMBINE: number;
  7485. /** Defines that alpha blending to DEST - SRC * DEST */
  7486. static readonly ALPHA_SUBTRACT: number;
  7487. /** Defines that alpha blending to SRC * DEST */
  7488. static readonly ALPHA_MULTIPLY: number;
  7489. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  7490. static readonly ALPHA_MAXIMIZED: number;
  7491. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  7492. static readonly ALPHA_PREMULTIPLIED: number;
  7493. /**
  7494. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  7495. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  7496. */
  7497. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  7498. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  7499. static readonly ALPHA_INTERPOLATE: number;
  7500. /**
  7501. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  7502. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  7503. */
  7504. static readonly ALPHA_SCREENMODE: number;
  7505. /** Defines that the ressource is not delayed*/
  7506. static readonly DELAYLOADSTATE_NONE: number;
  7507. /** Defines that the ressource was successfully delay loaded */
  7508. static readonly DELAYLOADSTATE_LOADED: number;
  7509. /** Defines that the ressource is currently delay loading */
  7510. static readonly DELAYLOADSTATE_LOADING: number;
  7511. /** Defines that the ressource is delayed and has not started loading */
  7512. static readonly DELAYLOADSTATE_NOTLOADED: number;
  7513. /** ALPHA */
  7514. static readonly TEXTUREFORMAT_ALPHA: number;
  7515. /** LUMINANCE */
  7516. static readonly TEXTUREFORMAT_LUMINANCE: number;
  7517. /**
  7518. * R32F
  7519. */
  7520. static readonly TEXTUREFORMAT_R32F: number;
  7521. /**
  7522. * RG32F
  7523. */
  7524. static readonly TEXTUREFORMAT_RG32F: number;
  7525. /**
  7526. * RGB32F
  7527. */
  7528. static readonly TEXTUREFORMAT_RGB32F: number;
  7529. /**
  7530. * RGBA32F
  7531. */
  7532. static readonly TEXTUREFORMAT_RGBA32F: number;
  7533. /** LUMINANCE_ALPHA */
  7534. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  7535. /** RGB */
  7536. static readonly TEXTUREFORMAT_RGB: number;
  7537. /** RGBA */
  7538. static readonly TEXTUREFORMAT_RGBA: number;
  7539. /** UNSIGNED_INT */
  7540. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  7541. /** FLOAT */
  7542. static readonly TEXTURETYPE_FLOAT: number;
  7543. /** HALF_FLOAT */
  7544. static readonly TEXTURETYPE_HALF_FLOAT: number;
  7545. private static _SCALEMODE_FLOOR;
  7546. private static _SCALEMODE_NEAREST;
  7547. private static _SCALEMODE_CEILING;
  7548. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  7549. static readonly SCALEMODE_FLOOR: number;
  7550. /** Defines that texture rescaling will look for the nearest power of 2 size */
  7551. static readonly SCALEMODE_NEAREST: number;
  7552. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  7553. static readonly SCALEMODE_CEILING: number;
  7554. /**
  7555. * Returns the current version of the framework
  7556. */
  7557. static readonly Version: string;
  7558. /**
  7559. * Gets or sets the epsilon value used by collision engine
  7560. */
  7561. static CollisionsEpsilon: number;
  7562. /**
  7563. * Gets or sets the relative url used to load code if using the engine in non-minified mode
  7564. */
  7565. static CodeRepository: string;
  7566. /**
  7567. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  7568. */
  7569. static ShadersRepository: string;
  7570. /**
  7571. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  7572. */
  7573. forcePOTTextures: boolean;
  7574. /**
  7575. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  7576. */
  7577. isFullscreen: boolean;
  7578. /**
  7579. * Gets a boolean indicating if the pointer is currently locked
  7580. */
  7581. isPointerLock: boolean;
  7582. /**
  7583. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  7584. */
  7585. cullBackFaces: boolean;
  7586. /**
  7587. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  7588. */
  7589. renderEvenInBackground: boolean;
  7590. /**
  7591. * Gets or sets a boolean indicating that cache can be kept between frames
  7592. */
  7593. preventCacheWipeBetweenFrames: boolean;
  7594. /**
  7595. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  7596. **/
  7597. enableOfflineSupport: boolean;
  7598. /**
  7599. * 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)
  7600. **/
  7601. disableManifestCheck: boolean;
  7602. /**
  7603. * Gets the list of created scenes
  7604. */
  7605. scenes: Scene[];
  7606. /**
  7607. * Gets the list of created postprocesses
  7608. */
  7609. postProcesses: PostProcess[];
  7610. /**
  7611. * Observable event triggered each time the rendering canvas is resized
  7612. */
  7613. onResizeObservable: Observable<Engine>;
  7614. /**
  7615. * Observable event triggered each time the canvas loses focus
  7616. */
  7617. onCanvasBlurObservable: Observable<Engine>;
  7618. /**
  7619. * Observable event triggered each time the canvas gains focus
  7620. */
  7621. onCanvasFocusObservable: Observable<Engine>;
  7622. /**
  7623. * Observable event triggered each time the canvas receives pointerout event
  7624. */
  7625. onCanvasPointerOutObservable: Observable<PointerEvent>;
  7626. /**
  7627. * Observable event triggered before each texture is initialized
  7628. */
  7629. onBeforeTextureInitObservable: Observable<Texture>;
  7630. private _vrDisplay;
  7631. private _vrSupported;
  7632. private _oldSize;
  7633. private _oldHardwareScaleFactor;
  7634. private _vrExclusivePointerMode;
  7635. private _webVRInitPromise;
  7636. /**
  7637. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  7638. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  7639. */
  7640. readonly isInVRExclusivePointerMode: boolean;
  7641. /**
  7642. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  7643. */
  7644. disableUniformBuffers: boolean;
  7645. /** @hidden */
  7646. _uniformBuffers: UniformBuffer[];
  7647. /**
  7648. * Gets a boolean indicating that the engine supports uniform buffers
  7649. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7650. */
  7651. readonly supportsUniformBuffers: boolean;
  7652. /**
  7653. * Observable raised when the engine begins a new frame
  7654. */
  7655. onBeginFrameObservable: Observable<Engine>;
  7656. /**
  7657. * Observable raised when the engine ends the current frame
  7658. */
  7659. onEndFrameObservable: Observable<Engine>;
  7660. /**
  7661. * Observable raised when the engine is about to compile a shader
  7662. */
  7663. onBeforeShaderCompilationObservable: Observable<Engine>;
  7664. /**
  7665. * Observable raised when the engine has jsut compiled a shader
  7666. */
  7667. onAfterShaderCompilationObservable: Observable<Engine>;
  7668. private _gl;
  7669. private _renderingCanvas;
  7670. private _windowIsBackground;
  7671. private _webGLVersion;
  7672. /**
  7673. * Gets a boolean indicating that only power of 2 textures are supported
  7674. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  7675. */
  7676. readonly needPOTTextures: boolean;
  7677. /** @hidden */
  7678. _badOS: boolean;
  7679. /** @hidden */
  7680. _badDesktopOS: boolean;
  7681. /**
  7682. * Gets or sets a value indicating if we want to disable texture binding optmization.
  7683. * This could be required on some buggy drivers which wants to have textures bound in a progressive order.
  7684. * By default Babylon.js will try to let textures bound where they are and only update the samplers to point where the texture is
  7685. */
  7686. disableTextureBindingOptimization: boolean;
  7687. /**
  7688. * Gets the audio engine
  7689. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  7690. * @ignorenaming
  7691. */
  7692. static audioEngine: AudioEngine;
  7693. private _onFocus;
  7694. private _onBlur;
  7695. private _onCanvasPointerOut;
  7696. private _onCanvasBlur;
  7697. private _onCanvasFocus;
  7698. private _onFullscreenChange;
  7699. private _onPointerLockChange;
  7700. private _onVRDisplayPointerRestricted;
  7701. private _onVRDisplayPointerUnrestricted;
  7702. private _onVrDisplayConnect;
  7703. private _onVrDisplayDisconnect;
  7704. private _onVrDisplayPresentChange;
  7705. /**
  7706. * Observable signaled when VR display mode changes
  7707. */
  7708. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  7709. /**
  7710. * Observable signaled when VR request present is complete
  7711. */
  7712. onVRRequestPresentComplete: Observable<boolean>;
  7713. /**
  7714. * Observable signaled when VR request present starts
  7715. */
  7716. onVRRequestPresentStart: Observable<Engine>;
  7717. private _hardwareScalingLevel;
  7718. /** @hidden */
  7719. protected _caps: EngineCapabilities;
  7720. private _pointerLockRequested;
  7721. private _isStencilEnable;
  7722. private _colorWrite;
  7723. private _loadingScreen;
  7724. /** @hidden */
  7725. _drawCalls: PerfCounter;
  7726. /** @hidden */
  7727. _textureCollisions: PerfCounter;
  7728. private _glVersion;
  7729. private _glRenderer;
  7730. private _glVendor;
  7731. private _videoTextureSupported;
  7732. private _renderingQueueLaunched;
  7733. private _activeRenderLoops;
  7734. private _deterministicLockstep;
  7735. private _lockstepMaxSteps;
  7736. /**
  7737. * Observable signaled when a context lost event is raised
  7738. */
  7739. onContextLostObservable: Observable<Engine>;
  7740. /**
  7741. * Observable signaled when a context restored event is raised
  7742. */
  7743. onContextRestoredObservable: Observable<Engine>;
  7744. private _onContextLost;
  7745. private _onContextRestored;
  7746. private _contextWasLost;
  7747. private _doNotHandleContextLost;
  7748. /**
  7749. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  7750. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  7751. */
  7752. doNotHandleContextLost: boolean;
  7753. private _performanceMonitor;
  7754. private _fps;
  7755. private _deltaTime;
  7756. /**
  7757. * Turn this value on if you want to pause FPS computation when in background
  7758. */
  7759. disablePerformanceMonitorInBackground: boolean;
  7760. /**
  7761. * Gets the performance monitor attached to this engine
  7762. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  7763. */
  7764. readonly performanceMonitor: PerformanceMonitor;
  7765. /** @hidden */
  7766. protected _depthCullingState: _DepthCullingState;
  7767. /** @hidden */
  7768. protected _stencilState: _StencilState;
  7769. /** @hidden */
  7770. protected _alphaState: _AlphaState;
  7771. /** @hidden */
  7772. protected _alphaMode: number;
  7773. protected _internalTexturesCache: InternalTexture[];
  7774. /** @hidden */
  7775. protected _activeChannel: number;
  7776. private _currentTextureChannel;
  7777. /** @hidden */
  7778. protected _boundTexturesCache: {
  7779. [key: string]: Nullable<InternalTexture>;
  7780. };
  7781. /** @hidden */
  7782. protected _currentEffect: Nullable<Effect>;
  7783. /** @hidden */
  7784. protected _currentProgram: Nullable<WebGLProgram>;
  7785. private _compiledEffects;
  7786. private _vertexAttribArraysEnabled;
  7787. /** @hidden */
  7788. protected _cachedViewport: Nullable<Viewport>;
  7789. private _cachedVertexArrayObject;
  7790. /** @hidden */
  7791. protected _cachedVertexBuffers: any;
  7792. /** @hidden */
  7793. protected _cachedIndexBuffer: Nullable<WebGLBuffer>;
  7794. /** @hidden */
  7795. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  7796. /** @hidden */
  7797. protected _currentRenderTarget: Nullable<InternalTexture>;
  7798. private _uintIndicesCurrentlySet;
  7799. private _currentBoundBuffer;
  7800. /** @hidden */
  7801. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  7802. private _currentBufferPointers;
  7803. private _currentInstanceLocations;
  7804. private _currentInstanceBuffers;
  7805. private _textureUnits;
  7806. private _firstBoundInternalTextureTracker;
  7807. private _lastBoundInternalTextureTracker;
  7808. private _workingCanvas;
  7809. private _workingContext;
  7810. private _rescalePostProcess;
  7811. private _dummyFramebuffer;
  7812. private _externalData;
  7813. private _bindedRenderFunction;
  7814. private _vaoRecordInProgress;
  7815. private _mustWipeVertexAttributes;
  7816. private _emptyTexture;
  7817. private _emptyCubeTexture;
  7818. private _emptyTexture3D;
  7819. private _frameHandler;
  7820. private _nextFreeTextureSlots;
  7821. private _maxSimultaneousTextures;
  7822. private _activeRequests;
  7823. private _texturesSupported;
  7824. private _textureFormatInUse;
  7825. /**
  7826. * Gets the list of texture formats supported
  7827. */
  7828. readonly texturesSupported: Array<string>;
  7829. /**
  7830. * Gets the list of texture formats in use
  7831. */
  7832. readonly textureFormatInUse: Nullable<string>;
  7833. /**
  7834. * Gets the current viewport
  7835. */
  7836. readonly currentViewport: Nullable<Viewport>;
  7837. /**
  7838. * Gets the default empty texture
  7839. */
  7840. readonly emptyTexture: InternalTexture;
  7841. /**
  7842. * Gets the default empty 3D texture
  7843. */
  7844. readonly emptyTexture3D: InternalTexture;
  7845. /**
  7846. * Gets the default empty cube texture
  7847. */
  7848. readonly emptyCubeTexture: InternalTexture;
  7849. /**
  7850. * Creates a new engine
  7851. * @param canvasOrContext defines the canvas or WebGL context to use for rendering
  7852. * @param antialias defines enable antialiasing (default: false)
  7853. * @param options defines further options to be sent to the getContext() function
  7854. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  7855. */
  7856. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  7857. private _rebuildInternalTextures();
  7858. private _rebuildEffects();
  7859. private _rebuildBuffers();
  7860. private _initGLContext();
  7861. /**
  7862. * Gets version of the current webGL context
  7863. */
  7864. readonly webGLVersion: number;
  7865. /**
  7866. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  7867. */
  7868. readonly isStencilEnable: boolean;
  7869. private _prepareWorkingCanvas();
  7870. /**
  7871. * Reset the texture cache to empty state
  7872. */
  7873. resetTextureCache(): void;
  7874. /**
  7875. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  7876. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  7877. * @returns true if engine is in deterministic lock step mode
  7878. */
  7879. isDeterministicLockStep(): boolean;
  7880. /**
  7881. * Gets the max steps when engine is running in deterministic lock step
  7882. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  7883. * @returns the max steps
  7884. */
  7885. getLockstepMaxSteps(): number;
  7886. /**
  7887. * Gets an object containing information about the current webGL context
  7888. * @returns an object containing the vender, the renderer and the version of the current webGL context
  7889. */
  7890. getGlInfo(): {
  7891. vendor: string;
  7892. renderer: string;
  7893. version: string;
  7894. };
  7895. /**
  7896. * Gets current aspect ratio
  7897. * @param camera defines the camera to use to get the aspect ratio
  7898. * @param useScreen defines if screen size must be used (or the current render target if any)
  7899. * @returns a number defining the aspect ratio
  7900. */
  7901. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  7902. /**
  7903. * Gets current screen aspect ratio
  7904. * @returns a number defining the aspect ratio
  7905. */
  7906. getScreenAspectRatio(): number;
  7907. /**
  7908. * Gets the current render width
  7909. * @param useScreen defines if screen size must be used (or the current render target if any)
  7910. * @returns a number defining the current render width
  7911. */
  7912. getRenderWidth(useScreen?: boolean): number;
  7913. /**
  7914. * Gets the current render height
  7915. * @param useScreen defines if screen size must be used (or the current render target if any)
  7916. * @returns a number defining the current render height
  7917. */
  7918. getRenderHeight(useScreen?: boolean): number;
  7919. /**
  7920. * Gets the HTML canvas attached with the current webGL context
  7921. * @returns a HTML canvas
  7922. */
  7923. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  7924. /**
  7925. * Gets the client rect of the HTML canvas attached with the current webGL context
  7926. * @returns a client rectanglee
  7927. */
  7928. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  7929. /**
  7930. * Defines the hardware scaling level.
  7931. * By default the hardware scaling level is computed from the window device ratio.
  7932. * 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.
  7933. * @param level defines the level to use
  7934. */
  7935. setHardwareScalingLevel(level: number): void;
  7936. /**
  7937. * Gets the current hardware scaling level.
  7938. * By default the hardware scaling level is computed from the window device ratio.
  7939. * 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.
  7940. * @returns a number indicating the current hardware scaling level
  7941. */
  7942. getHardwareScalingLevel(): number;
  7943. /**
  7944. * Gets the list of loaded textures
  7945. * @returns an array containing all loaded textures
  7946. */
  7947. getLoadedTexturesCache(): InternalTexture[];
  7948. /**
  7949. * Gets the object containing all engine capabilities
  7950. * @returns the EngineCapabilities object
  7951. */
  7952. getCaps(): EngineCapabilities;
  7953. /** @hidden */
  7954. readonly drawCalls: number;
  7955. /** @hidden */
  7956. readonly drawCallsPerfCounter: Nullable<PerfCounter>;
  7957. /**
  7958. * Gets the current depth function
  7959. * @returns a number defining the depth function
  7960. */
  7961. getDepthFunction(): Nullable<number>;
  7962. /**
  7963. * Sets the current depth function
  7964. * @param depthFunc defines the function to use
  7965. */
  7966. setDepthFunction(depthFunc: number): void;
  7967. /**
  7968. * Sets the current depth function to GREATER
  7969. */
  7970. setDepthFunctionToGreater(): void;
  7971. /**
  7972. * Sets the current depth function to GEQUAL
  7973. */
  7974. setDepthFunctionToGreaterOrEqual(): void;
  7975. /**
  7976. * Sets the current depth function to LESS
  7977. */
  7978. setDepthFunctionToLess(): void;
  7979. /**
  7980. * Sets the current depth function to LEQUAL
  7981. */
  7982. setDepthFunctionToLessOrEqual(): void;
  7983. /**
  7984. * Gets a boolean indicating if stencil buffer is enabled
  7985. * @returns the current stencil buffer state
  7986. */
  7987. getStencilBuffer(): boolean;
  7988. /**
  7989. * Enable or disable the stencil buffer
  7990. * @param enable defines if the stencil buffer must be enabled or disabled
  7991. */
  7992. setStencilBuffer(enable: boolean): void;
  7993. /**
  7994. * Gets the current stencil mask
  7995. * @returns a number defining the new stencil mask to use
  7996. */
  7997. getStencilMask(): number;
  7998. /**
  7999. * Sets the current stencil mask
  8000. * @param mask defines the new stencil mask to use
  8001. */
  8002. setStencilMask(mask: number): void;
  8003. /**
  8004. * Gets the current stencil function
  8005. * @returns a number defining the stencil function to use
  8006. */
  8007. getStencilFunction(): number;
  8008. /**
  8009. * Gets the current stencil reference value
  8010. * @returns a number defining the stencil reference value to use
  8011. */
  8012. getStencilFunctionReference(): number;
  8013. /**
  8014. * Gets the current stencil mask
  8015. * @returns a number defining the stencil mask to use
  8016. */
  8017. getStencilFunctionMask(): number;
  8018. /**
  8019. * Sets the current stencil function
  8020. * @param stencilFunc defines the new stencil function to use
  8021. */
  8022. setStencilFunction(stencilFunc: number): void;
  8023. /**
  8024. * Sets the current stencil reference
  8025. * @param reference defines the new stencil reference to use
  8026. */
  8027. setStencilFunctionReference(reference: number): void;
  8028. /**
  8029. * Sets the current stencil mask
  8030. * @param mask defines the new stencil mask to use
  8031. */
  8032. setStencilFunctionMask(mask: number): void;
  8033. /**
  8034. * Gets the current stencil operation when stencil fails
  8035. * @returns a number defining stencil operation to use when stencil fails
  8036. */
  8037. getStencilOperationFail(): number;
  8038. /**
  8039. * Gets the current stencil operation when depth fails
  8040. * @returns a number defining stencil operation to use when depth fails
  8041. */
  8042. getStencilOperationDepthFail(): number;
  8043. /**
  8044. * Gets the current stencil operation when stencil passes
  8045. * @returns a number defining stencil operation to use when stencil passes
  8046. */
  8047. getStencilOperationPass(): number;
  8048. /**
  8049. * Sets the stencil operation to use when stencil fails
  8050. * @param operation defines the stencil operation to use when stencil fails
  8051. */
  8052. setStencilOperationFail(operation: number): void;
  8053. /**
  8054. * Sets the stencil operation to use when depth fails
  8055. * @param operation defines the stencil operation to use when depth fails
  8056. */
  8057. setStencilOperationDepthFail(operation: number): void;
  8058. /**
  8059. * Sets the stencil operation to use when stencil passes
  8060. * @param operation defines the stencil operation to use when stencil passes
  8061. */
  8062. setStencilOperationPass(operation: number): void;
  8063. /**
  8064. * Sets a boolean indicating if the dithering state is enabled or disabled
  8065. * @param value defines the dithering state
  8066. */
  8067. setDitheringState(value: boolean): void;
  8068. /**
  8069. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  8070. * @param value defines the rasterizer state
  8071. */
  8072. setRasterizerState(value: boolean): void;
  8073. /**
  8074. * stop executing a render loop function and remove it from the execution array
  8075. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  8076. */
  8077. stopRenderLoop(renderFunction?: () => void): void;
  8078. /** @hidden */
  8079. _renderLoop(): void;
  8080. /**
  8081. * Register and execute a render loop. The engine can have more than one render function
  8082. * @param renderFunction defines the function to continuously execute
  8083. */
  8084. runRenderLoop(renderFunction: () => void): void;
  8085. /**
  8086. * Toggle full screen mode
  8087. * @param requestPointerLock defines if a pointer lock should be requested from the user
  8088. * @param options defines an option object to be sent to the requestFullscreen function
  8089. */
  8090. switchFullscreen(requestPointerLock: boolean): void;
  8091. /**
  8092. * Clear the current render buffer or the current render target (if any is set up)
  8093. * @param color defines the color to use
  8094. * @param backBuffer defines if the back buffer must be cleared
  8095. * @param depth defines if the depth buffer must be cleared
  8096. * @param stencil defines if the stencil buffer must be cleared
  8097. */
  8098. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  8099. /**
  8100. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  8101. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  8102. * @param y defines the y-coordinate of the corner of the clear rectangle
  8103. * @param width defines the width of the clear rectangle
  8104. * @param height defines the height of the clear rectangle
  8105. * @param clearColor defines the clear color
  8106. */
  8107. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  8108. /**
  8109. * Set the WebGL's viewport
  8110. * @param viewport defines the viewport element to be used
  8111. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  8112. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  8113. */
  8114. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  8115. /**
  8116. * Directly set the WebGL Viewport
  8117. * @param x defines the x coordinate of the viewport (in screen space)
  8118. * @param y defines the y coordinate of the viewport (in screen space)
  8119. * @param width defines the width of the viewport (in screen space)
  8120. * @param height defines the height of the viewport (in screen space)
  8121. * @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
  8122. */
  8123. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  8124. /**
  8125. * Begin a new frame
  8126. */
  8127. beginFrame(): void;
  8128. /**
  8129. * Enf the current frame
  8130. */
  8131. endFrame(): void;
  8132. /**
  8133. * Resize the view according to the canvas' size
  8134. */
  8135. resize(): void;
  8136. /**
  8137. * Force a specific size of the canvas
  8138. * @param width defines the new canvas' width
  8139. * @param height defines the new canvas' height
  8140. */
  8141. setSize(width: number, height: number): void;
  8142. /**
  8143. * Gets a boolean indicating if a webVR device was detected
  8144. * @returns true if a webVR device was detected
  8145. */
  8146. isVRDevicePresent(): boolean;
  8147. /**
  8148. * Gets the current webVR device
  8149. * @returns the current webVR device (or null)
  8150. */
  8151. getVRDevice(): any;
  8152. /**
  8153. * Initializes a webVR display and starts listening to display change events
  8154. * The onVRDisplayChangedObservable will be notified upon these changes
  8155. * @returns The onVRDisplayChangedObservable
  8156. */
  8157. initWebVR(): Observable<IDisplayChangedEventArgs>;
  8158. /**
  8159. * Initializes a webVR display and starts listening to display change events
  8160. * The onVRDisplayChangedObservable will be notified upon these changes
  8161. * @returns A promise containing a VRDisplay and if vr is supported
  8162. */
  8163. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  8164. /**
  8165. * Call this function to switch to webVR mode
  8166. * Will do nothing if webVR is not supported or if there is no webVR device
  8167. * @see http://doc.babylonjs.com/how_to/webvr_camera
  8168. */
  8169. enableVR(): void;
  8170. /**
  8171. * Call this function to leave webVR mode
  8172. * Will do nothing if webVR is not supported or if there is no webVR device
  8173. * @see http://doc.babylonjs.com/how_to/webvr_camera
  8174. */
  8175. disableVR(): void;
  8176. private _onVRFullScreenTriggered;
  8177. private _getVRDisplaysAsync();
  8178. /**
  8179. * Binds the frame buffer to the specified texture.
  8180. * @param texture The texture to render to or null for the default canvas
  8181. * @param faceIndex The face of the texture to render to in case of cube texture
  8182. * @param requiredWidth The width of the target to render to
  8183. * @param requiredHeight The height of the target to render to
  8184. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  8185. * @param depthStencilTexture The depth stencil texture to use to render
  8186. */
  8187. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture): void;
  8188. private bindUnboundFramebuffer(framebuffer);
  8189. /**
  8190. * Unbind the current render target texture from the webGL context
  8191. * @param texture defines the render target texture to unbind
  8192. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  8193. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  8194. */
  8195. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  8196. /**
  8197. * Unbind a list of render target textures from the webGL context
  8198. * This is used only when drawBuffer extension or webGL2 are active
  8199. * @param textures defines the render target textures to unbind
  8200. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  8201. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  8202. */
  8203. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  8204. /**
  8205. * Force the mipmap generation for the given render target texture
  8206. * @param texture defines the render target texture to use
  8207. */
  8208. generateMipMapsForCubemap(texture: InternalTexture): void;
  8209. /**
  8210. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  8211. */
  8212. flushFramebuffer(): void;
  8213. /**
  8214. * Unbind the current render target and bind the default framebuffer
  8215. */
  8216. restoreDefaultFramebuffer(): void;
  8217. /**
  8218. * Create an uniform buffer
  8219. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  8220. * @param elements defines the content of the uniform buffer
  8221. * @returns the webGL uniform buffer
  8222. */
  8223. createUniformBuffer(elements: FloatArray): WebGLBuffer;
  8224. /**
  8225. * Create a dynamic uniform buffer
  8226. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  8227. * @param elements defines the content of the uniform buffer
  8228. * @returns the webGL uniform buffer
  8229. */
  8230. createDynamicUniformBuffer(elements: FloatArray): WebGLBuffer;
  8231. /**
  8232. * Update an existing uniform buffer
  8233. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  8234. * @param uniformBuffer defines the target uniform buffer
  8235. * @param elements defines the content to update
  8236. * @param offset defines the offset in the uniform buffer where update should start
  8237. * @param count defines the size of the data to update
  8238. */
  8239. updateUniformBuffer(uniformBuffer: WebGLBuffer, elements: FloatArray, offset?: number, count?: number): void;
  8240. private _resetVertexBufferBinding();
  8241. /**
  8242. * Creates a vertex buffer
  8243. * @param data the data for the vertex buffer
  8244. * @returns the new WebGL static buffer
  8245. */
  8246. createVertexBuffer(data: DataArray): WebGLBuffer;
  8247. /**
  8248. * Creates a dynamic vertex buffer
  8249. * @param data the data for the dynamic vertex buffer
  8250. * @returns the new WebGL dynamic buffer
  8251. */
  8252. createDynamicVertexBuffer(data: DataArray): WebGLBuffer;
  8253. /**
  8254. * Update a dynamic index buffer
  8255. * @param indexBuffer defines the target index buffer
  8256. * @param indices defines the data to update
  8257. * @param offset defines the offset in the target index buffer where update should start
  8258. */
  8259. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  8260. /**
  8261. * Updates a dynamic vertex buffer.
  8262. * @param vertexBuffer the vertex buffer to update
  8263. * @param data the data used to update the vertex buffer
  8264. * @param byteOffset the byte offset of the data
  8265. * @param byteLength the byte length of the data
  8266. */
  8267. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  8268. private _resetIndexBufferBinding();
  8269. /**
  8270. * Creates a new index buffer
  8271. * @param indices defines the content of the index buffer
  8272. * @param updatable defines if the index buffer must be updatable
  8273. * @returns a new webGL buffer
  8274. */
  8275. createIndexBuffer(indices: IndicesArray, updatable?: boolean): WebGLBuffer;
  8276. /**
  8277. * Bind a webGL buffer to the webGL context
  8278. * @param buffer defines the buffer to bind
  8279. */
  8280. bindArrayBuffer(buffer: Nullable<WebGLBuffer>): void;
  8281. /**
  8282. * Bind an uniform buffer to the current webGL context
  8283. * @param buffer defines the buffer to bind
  8284. */
  8285. bindUniformBuffer(buffer: Nullable<WebGLBuffer>): void;
  8286. /**
  8287. * Bind a buffer to the current webGL context at a given location
  8288. * @param buffer defines the buffer to bind
  8289. * @param location defines the index where to bind the buffer
  8290. */
  8291. bindUniformBufferBase(buffer: WebGLBuffer, location: number): void;
  8292. /**
  8293. * Bind a specific block at a given index in a specific shader program
  8294. * @param shaderProgram defines the shader program
  8295. * @param blockName defines the block name
  8296. * @param index defines the index where to bind the block
  8297. */
  8298. bindUniformBlock(shaderProgram: WebGLProgram, blockName: string, index: number): void;
  8299. private bindIndexBuffer(buffer);
  8300. private bindBuffer(buffer, target);
  8301. /**
  8302. * update the bound buffer with the given data
  8303. * @param data defines the data to update
  8304. */
  8305. updateArrayBuffer(data: Float32Array): void;
  8306. private _vertexAttribPointer(buffer, indx, size, type, normalized, stride, offset);
  8307. private _bindIndexBufferWithCache(indexBuffer);
  8308. private _bindVertexBuffersAttributes(vertexBuffers, effect);
  8309. /**
  8310. * Records a vertex array object
  8311. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  8312. * @param vertexBuffers defines the list of vertex buffers to store
  8313. * @param indexBuffer defines the index buffer to store
  8314. * @param effect defines the effect to store
  8315. * @returns the new vertex array object
  8316. */
  8317. recordVertexArrayObject(vertexBuffers: {
  8318. [key: string]: VertexBuffer;
  8319. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): WebGLVertexArrayObject;
  8320. /**
  8321. * Bind a specific vertex array object
  8322. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  8323. * @param vertexArrayObject defines the vertex array object to bind
  8324. * @param indexBuffer defines the index buffer to bind
  8325. */
  8326. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<WebGLBuffer>): void;
  8327. /**
  8328. * Bind webGl buffers directly to the webGL context
  8329. * @param vertexBuffer defines the vertex buffer to bind
  8330. * @param indexBuffer defines the index buffer to bind
  8331. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  8332. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  8333. * @param effect defines the effect associated with the vertex buffer
  8334. */
  8335. bindBuffersDirectly(vertexBuffer: WebGLBuffer, indexBuffer: WebGLBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  8336. private _unbindVertexArrayObject();
  8337. /**
  8338. * Bind a list of vertex buffers to the webGL context
  8339. * @param vertexBuffers defines the list of vertex buffers to bind
  8340. * @param indexBuffer defines the index buffer to bind
  8341. * @param effect defines the effect associated with the vertex buffers
  8342. */
  8343. bindBuffers(vertexBuffers: {
  8344. [key: string]: Nullable<VertexBuffer>;
  8345. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): void;
  8346. /**
  8347. * Unbind all instance attributes
  8348. */
  8349. unbindInstanceAttributes(): void;
  8350. /**
  8351. * Release and free the memory of a vertex array object
  8352. * @param vao defines the vertex array object to delete
  8353. */
  8354. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  8355. /** @hidden */
  8356. _releaseBuffer(buffer: WebGLBuffer): boolean;
  8357. /**
  8358. * Creates a webGL buffer to use with instanciation
  8359. * @param capacity defines the size of the buffer
  8360. * @returns the webGL buffer
  8361. */
  8362. createInstancesBuffer(capacity: number): WebGLBuffer;
  8363. /**
  8364. * Delete a webGL buffer used with instanciation
  8365. * @param buffer defines the webGL buffer to delete
  8366. */
  8367. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  8368. /**
  8369. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  8370. * @param instancesBuffer defines the webGL buffer to update and bind
  8371. * @param data defines the data to store in the buffer
  8372. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  8373. */
  8374. updateAndBindInstancesBuffer(instancesBuffer: WebGLBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  8375. /**
  8376. * Apply all cached states (depth, culling, stencil and alpha)
  8377. */
  8378. applyStates(): void;
  8379. /**
  8380. * Send a draw order
  8381. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  8382. * @param indexStart defines the starting index
  8383. * @param indexCount defines the number of index to draw
  8384. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  8385. */
  8386. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  8387. /**
  8388. * Draw a list of points
  8389. * @param verticesStart defines the index of first vertex to draw
  8390. * @param verticesCount defines the count of vertices to draw
  8391. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  8392. */
  8393. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  8394. /**
  8395. * Draw a list of unindexed primitives
  8396. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  8397. * @param verticesStart defines the index of first vertex to draw
  8398. * @param verticesCount defines the count of vertices to draw
  8399. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  8400. */
  8401. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  8402. /**
  8403. * Draw a list of indexed primitives
  8404. * @param fillMode defines the primitive to use
  8405. * @param indexStart defines the starting index
  8406. * @param indexCount defines the number of index to draw
  8407. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  8408. */
  8409. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  8410. /**
  8411. * Draw a list of unindexed primitives
  8412. * @param fillMode defines the primitive to use
  8413. * @param verticesStart defines the index of first vertex to draw
  8414. * @param verticesCount defines the count of vertices to draw
  8415. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  8416. */
  8417. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  8418. private _drawMode(fillMode);
  8419. /** @hidden */
  8420. _releaseEffect(effect: Effect): void;
  8421. /** @hidden */
  8422. _deleteProgram(program: WebGLProgram): void;
  8423. /**
  8424. * Create a new effect (used to store vertex/fragment shaders)
  8425. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  8426. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  8427. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  8428. * @param samplers defines an array of string used to represent textures
  8429. * @param defines defines the string containing the defines to use to compile the shaders
  8430. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  8431. * @param onCompiled defines a function to call when the effect creation is successful
  8432. * @param onError defines a function to call when the effect creation has failed
  8433. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  8434. * @returns the new Effect
  8435. */
  8436. 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;
  8437. /**
  8438. * Create an effect to use with particle systems
  8439. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  8440. * @param uniformsNames defines a list of attribute names
  8441. * @param samplers defines an array of string used to represent textures
  8442. * @param defines defines the string containing the defines to use to compile the shaders
  8443. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  8444. * @param onCompiled defines a function to call when the effect creation is successful
  8445. * @param onError defines a function to call when the effect creation has failed
  8446. * @returns the new Effect
  8447. */
  8448. createEffectForParticles(fragmentName: string, uniformsNames?: string[], samplers?: string[], defines?: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  8449. /**
  8450. * Directly creates a webGL program
  8451. * @param vertexCode defines the vertex shader code to use
  8452. * @param fragmentCode defines the fragment shader code to use
  8453. * @param context defines the webGL context to use (if not set, the current one will be used)
  8454. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  8455. * @returns the new webGL program
  8456. */
  8457. createRawShaderProgram(vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  8458. /**
  8459. * Creates a webGL program
  8460. * @param vertexCode defines the vertex shader code to use
  8461. * @param fragmentCode defines the fragment shader code to use
  8462. * @param defines defines the string containing the defines to use to compile the shaders
  8463. * @param context defines the webGL context to use (if not set, the current one will be used)
  8464. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  8465. * @returns the new webGL program
  8466. */
  8467. createShaderProgram(vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  8468. private _createShaderProgram(vertexShader, fragmentShader, context, transformFeedbackVaryings?);
  8469. /**
  8470. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  8471. * @param shaderProgram defines the webGL program to use
  8472. * @param uniformsNames defines the list of uniform names
  8473. * @returns an array of webGL uniform locations
  8474. */
  8475. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  8476. /**
  8477. * Gets the lsit of active attributes for a given webGL program
  8478. * @param shaderProgram defines the webGL program to use
  8479. * @param attributesNames defines the list of attribute names to get
  8480. * @returns an array of indices indicating the offset of each attribute
  8481. */
  8482. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  8483. /**
  8484. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  8485. * @param effect defines the effect to activate
  8486. */
  8487. enableEffect(effect: Nullable<Effect>): void;
  8488. /**
  8489. * Set the value of an uniform to an array of int32
  8490. * @param uniform defines the webGL uniform location where to store the value
  8491. * @param array defines the array of int32 to store
  8492. */
  8493. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  8494. /**
  8495. * Set the value of an uniform to an array of int32 (stored as vec2)
  8496. * @param uniform defines the webGL uniform location where to store the value
  8497. * @param array defines the array of int32 to store
  8498. */
  8499. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  8500. /**
  8501. * Set the value of an uniform to an array of int32 (stored as vec3)
  8502. * @param uniform defines the webGL uniform location where to store the value
  8503. * @param array defines the array of int32 to store
  8504. */
  8505. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  8506. /**
  8507. * Set the value of an uniform to an array of int32 (stored as vec4)
  8508. * @param uniform defines the webGL uniform location where to store the value
  8509. * @param array defines the array of int32 to store
  8510. */
  8511. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  8512. /**
  8513. * Set the value of an uniform to an array of float32
  8514. * @param uniform defines the webGL uniform location where to store the value
  8515. * @param array defines the array of float32 to store
  8516. */
  8517. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  8518. /**
  8519. * Set the value of an uniform to an array of float32 (stored as vec2)
  8520. * @param uniform defines the webGL uniform location where to store the value
  8521. * @param array defines the array of float32 to store
  8522. */
  8523. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  8524. /**
  8525. * Set the value of an uniform to an array of float32 (stored as vec3)
  8526. * @param uniform defines the webGL uniform location where to store the value
  8527. * @param array defines the array of float32 to store
  8528. */
  8529. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  8530. /**
  8531. * Set the value of an uniform to an array of float32 (stored as vec4)
  8532. * @param uniform defines the webGL uniform location where to store the value
  8533. * @param array defines the array of float32 to store
  8534. */
  8535. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  8536. /**
  8537. * Set the value of an uniform to an array of number
  8538. * @param uniform defines the webGL uniform location where to store the value
  8539. * @param array defines the array of number to store
  8540. */
  8541. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  8542. /**
  8543. * Set the value of an uniform to an array of number (stored as vec2)
  8544. * @param uniform defines the webGL uniform location where to store the value
  8545. * @param array defines the array of number to store
  8546. */
  8547. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  8548. /**
  8549. * Set the value of an uniform to an array of number (stored as vec3)
  8550. * @param uniform defines the webGL uniform location where to store the value
  8551. * @param array defines the array of number to store
  8552. */
  8553. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  8554. /**
  8555. * Set the value of an uniform to an array of number (stored as vec4)
  8556. * @param uniform defines the webGL uniform location where to store the value
  8557. * @param array defines the array of number to store
  8558. */
  8559. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  8560. /**
  8561. * Set the value of an uniform to an array of float32 (stored as matrices)
  8562. * @param uniform defines the webGL uniform location where to store the value
  8563. * @param matrices defines the array of float32 to store
  8564. */
  8565. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  8566. /**
  8567. * Set the value of an uniform to a matrix
  8568. * @param uniform defines the webGL uniform location where to store the value
  8569. * @param matrix defines the matrix to store
  8570. */
  8571. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  8572. /**
  8573. * Set the value of an uniform to a matrix (3x3)
  8574. * @param uniform defines the webGL uniform location where to store the value
  8575. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  8576. */
  8577. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  8578. /**
  8579. * Set the value of an uniform to a matrix (2x2)
  8580. * @param uniform defines the webGL uniform location where to store the value
  8581. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  8582. */
  8583. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  8584. /**
  8585. * Set the value of an uniform to a number (int)
  8586. * @param uniform defines the webGL uniform location where to store the value
  8587. * @param value defines the int number to store
  8588. */
  8589. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  8590. /**
  8591. * Set the value of an uniform to a number (float)
  8592. * @param uniform defines the webGL uniform location where to store the value
  8593. * @param value defines the float number to store
  8594. */
  8595. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  8596. /**
  8597. * Set the value of an uniform to a vec2
  8598. * @param uniform defines the webGL uniform location where to store the value
  8599. * @param x defines the 1st component of the value
  8600. * @param y defines the 2nd component of the value
  8601. */
  8602. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  8603. /**
  8604. * Set the value of an uniform to a vec3
  8605. * @param uniform defines the webGL uniform location where to store the value
  8606. * @param x defines the 1st component of the value
  8607. * @param y defines the 2nd component of the value
  8608. * @param z defines the 3rd component of the value
  8609. */
  8610. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  8611. /**
  8612. * Set the value of an uniform to a boolean
  8613. * @param uniform defines the webGL uniform location where to store the value
  8614. * @param bool defines the boolean to store
  8615. */
  8616. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  8617. /**
  8618. * Set the value of an uniform to a vec4
  8619. * @param uniform defines the webGL uniform location where to store the value
  8620. * @param x defines the 1st component of the value
  8621. * @param y defines the 2nd component of the value
  8622. * @param z defines the 3rd component of the value
  8623. * @param w defines the 4th component of the value
  8624. */
  8625. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  8626. /**
  8627. * Set the value of an uniform to a Color3
  8628. * @param uniform defines the webGL uniform location where to store the value
  8629. * @param color3 defines the color to store
  8630. */
  8631. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  8632. /**
  8633. * Set the value of an uniform to a Color3 and an alpha value
  8634. * @param uniform defines the webGL uniform location where to store the value
  8635. * @param color3 defines the color to store
  8636. * @param alpha defines the alpha component to store
  8637. */
  8638. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  8639. /**
  8640. * Sets a Color4 on a uniform variable
  8641. * @param uniform defines the uniform location
  8642. * @param color4 defines the value to be set
  8643. */
  8644. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  8645. /**
  8646. * Set various states to the webGL context
  8647. * @param culling defines backface culling state
  8648. * @param zOffset defines the value to apply to zOffset (0 by default)
  8649. * @param force defines if states must be applied even if cache is up to date
  8650. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  8651. */
  8652. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  8653. /**
  8654. * Set the z offset to apply to current rendering
  8655. * @param value defines the offset to apply
  8656. */
  8657. setZOffset(value: number): void;
  8658. /**
  8659. * Gets the current value of the zOffset
  8660. * @returns the current zOffset state
  8661. */
  8662. getZOffset(): number;
  8663. /**
  8664. * Enable or disable depth buffering
  8665. * @param enable defines the state to set
  8666. */
  8667. setDepthBuffer(enable: boolean): void;
  8668. /**
  8669. * Gets a boolean indicating if depth writing is enabled
  8670. * @returns the current depth writing state
  8671. */
  8672. getDepthWrite(): boolean;
  8673. /**
  8674. * Enable or disable depth writing
  8675. * @param enable defines the state to set
  8676. */
  8677. setDepthWrite(enable: boolean): void;
  8678. /**
  8679. * Enable or disable color writing
  8680. * @param enable defines the state to set
  8681. */
  8682. setColorWrite(enable: boolean): void;
  8683. /**
  8684. * Gets a boolean indicating if color writing is enabled
  8685. * @returns the current color writing state
  8686. */
  8687. getColorWrite(): boolean;
  8688. /**
  8689. * Sets alpha constants used by some alpha blending modes
  8690. * @param r defines the red component
  8691. * @param g defines the green component
  8692. * @param b defines the blue component
  8693. * @param a defines the alpha component
  8694. */
  8695. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  8696. /**
  8697. * Sets the current alpha mode
  8698. * @param mode defines the mode to use (one of the BABYLON.Engine.ALPHA_XXX)
  8699. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  8700. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  8701. */
  8702. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  8703. /**
  8704. * Gets the current alpha mode
  8705. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  8706. * @returns the current alpha mode
  8707. */
  8708. getAlphaMode(): number;
  8709. /**
  8710. * Force the entire cache to be cleared
  8711. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  8712. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  8713. */
  8714. wipeCaches(bruteForce?: boolean): void;
  8715. /**
  8716. * Set the compressed texture format to use, based on the formats you have, and the formats
  8717. * supported by the hardware / browser.
  8718. *
  8719. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  8720. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  8721. * to API arguments needed to compressed textures. This puts the burden on the container
  8722. * generator to house the arcane code for determining these for current & future formats.
  8723. *
  8724. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  8725. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  8726. *
  8727. * Note: The result of this call is not taken into account when a texture is base64.
  8728. *
  8729. * @param formatsAvailable defines the list of those format families you have created
  8730. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  8731. *
  8732. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  8733. * @returns The extension selected.
  8734. */
  8735. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  8736. /** @hidden */
  8737. _createTexture(): WebGLTexture;
  8738. /**
  8739. * Usually called from BABYLON.Texture.ts.
  8740. * Passed information to create a WebGLTexture
  8741. * @param urlArg defines a value which contains one of the following:
  8742. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  8743. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  8744. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  8745. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  8746. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  8747. * @param scene needed for loading to the correct scene
  8748. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  8749. * @param onLoad optional callback to be called upon successful completion
  8750. * @param onError optional callback to be called upon failure
  8751. * @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
  8752. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  8753. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  8754. * @returns a InternalTexture for assignment back into BABYLON.Texture
  8755. */
  8756. 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;
  8757. private _rescaleTexture(source, destination, scene, internalFormat, onComplete);
  8758. /**
  8759. * Update a raw texture
  8760. * @param texture defines the texture to update
  8761. * @param data defines the data to store in the texture
  8762. * @param format defines the format of the data
  8763. * @param invertY defines if data must be stored with Y axis inverted
  8764. * @param compression defines the compression used (null by default)
  8765. * @param type defines the type fo the data (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  8766. */
  8767. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, type?: number): void;
  8768. /**
  8769. * Creates a raw texture
  8770. * @param data defines the data to store in the texture
  8771. * @param width defines the width of the texture
  8772. * @param height defines the height of the texture
  8773. * @param format defines the format of the data
  8774. * @param generateMipMaps defines if the engine should generate the mip levels
  8775. * @param invertY defines if data must be stored with Y axis inverted
  8776. * @param samplingMode defines the required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  8777. * @param compression defines the compression used (null by default)
  8778. * @param type defines the type fo the data (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  8779. * @returns the raw texture inside an InternalTexture
  8780. */
  8781. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  8782. /**
  8783. * Creates a dynamic texture
  8784. * @param width defines the width of the texture
  8785. * @param height defines the height of the texture
  8786. * @param generateMipMaps defines if the engine should generate the mip levels
  8787. * @param samplingMode defines the required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  8788. * @returns the dynamic texture inside an InternalTexture
  8789. */
  8790. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  8791. /**
  8792. * Update the sampling mode of a given texture
  8793. * @param samplingMode defines the required sampling mode
  8794. * @param texture defines the texture to update
  8795. */
  8796. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  8797. /**
  8798. * Update the content of a dynamic texture
  8799. * @param texture defines the texture to update
  8800. * @param canvas defines the canvas containing the source
  8801. * @param invertY defines if data must be stored with Y axis inverted
  8802. * @param premulAlpha defines if alpha is stored as premultiplied
  8803. * @param format defines the format of the data
  8804. */
  8805. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  8806. /**
  8807. * Update a video texture
  8808. * @param texture defines the texture to update
  8809. * @param video defines the video element to use
  8810. * @param invertY defines if data must be stored with Y axis inverted
  8811. */
  8812. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  8813. /**
  8814. * Updates a depth texture Comparison Mode and Function.
  8815. * If the comparison Function is equal to 0, the mode will be set to none.
  8816. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  8817. * @param texture The texture to set the comparison function for
  8818. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  8819. */
  8820. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  8821. private _setupDepthStencilTexture(internalTexture, size, generateStencil, bilinearFiltering, comparisonFunction);
  8822. /**
  8823. * Creates a depth stencil texture.
  8824. * This is only available in WebGL 2 or with the depth texture extension available.
  8825. * @param size The size of face edge in the texture.
  8826. * @param options The options defining the texture.
  8827. * @returns The texture
  8828. */
  8829. createDepthStencilTexture(size: number | {
  8830. width: number;
  8831. height: number;
  8832. }, options: DepthTextureCreationOptions): InternalTexture;
  8833. /**
  8834. * Creates a depth stencil texture.
  8835. * This is only available in WebGL 2 or with the depth texture extension available.
  8836. * @param size The size of face edge in the texture.
  8837. * @param options The options defining the texture.
  8838. * @returns The texture
  8839. */
  8840. private _createDepthStencilTexture(size, options);
  8841. /**
  8842. * Creates a depth stencil cube texture.
  8843. * This is only available in WebGL 2.
  8844. * @param size The size of face edge in the cube texture.
  8845. * @param options The options defining the cube texture.
  8846. * @returns The cube texture
  8847. */
  8848. private _createDepthStencilCubeTexture(size, options);
  8849. /**
  8850. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  8851. * @param renderTarget The render target to set the frame buffer for
  8852. */
  8853. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  8854. /**
  8855. * Creates a new render target texture
  8856. * @param size defines the size of the texture
  8857. * @param options defines the options used to create the texture
  8858. * @returns a new render target texture stored in an InternalTexture
  8859. */
  8860. createRenderTargetTexture(size: number | {
  8861. width: number;
  8862. height: number;
  8863. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8864. /**
  8865. * Create a multi render target texture
  8866. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  8867. * @param size defines the size of the texture
  8868. * @param options defines the creation options
  8869. * @returns the cube texture as an InternalTexture
  8870. */
  8871. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  8872. private _setupFramebufferDepthAttachments(generateStencilBuffer, generateDepthBuffer, width, height, samples?);
  8873. /**
  8874. * Updates the sample count of a render target texture
  8875. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  8876. * @param texture defines the texture to update
  8877. * @param samples defines the sample count to set
  8878. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  8879. */
  8880. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  8881. /**
  8882. * Update the sample count for a given multiple render target texture
  8883. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  8884. * @param textures defines the textures to update
  8885. * @param samples defines the sample count to set
  8886. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  8887. */
  8888. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  8889. /** @hidden */
  8890. _uploadDataToTexture(target: number, lod: number, internalFormat: number, width: number, height: number, format: number, type: number, data: ArrayBufferView): void;
  8891. /** @hidden */
  8892. _uploadCompressedDataToTexture(target: number, lod: number, internalFormat: number, width: number, height: number, data: ArrayBufferView): void;
  8893. /**
  8894. * Creates a new render target cube texture
  8895. * @param size defines the size of the texture
  8896. * @param options defines the options used to create the texture
  8897. * @returns a new render target cube texture stored in an InternalTexture
  8898. */
  8899. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  8900. /**
  8901. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  8902. * @param rootUrl defines the url where the file to load is located
  8903. * @param scene defines the current scene
  8904. * @param scale defines scale to apply to the mip map selection
  8905. * @param offset defines offset to apply to the mip map selection
  8906. * @param onLoad defines an optional callback raised when the texture is loaded
  8907. * @param onError defines an optional callback raised if there is an issue to load the texture
  8908. * @param format defines the format of the data
  8909. * @param forcedExtension defines the extension to use to pick the right loader
  8910. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  8911. * @returns the cube texture as an InternalTexture
  8912. */
  8913. createPrefilteredCubeTexture(rootUrl: string, scene: Nullable<Scene>, scale: number, offset: number, onLoad?: Nullable<(internalTexture: Nullable<InternalTexture>) => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number, forcedExtension?: any, createPolynomials?: boolean): InternalTexture;
  8914. /**
  8915. * Creates a cube texture
  8916. * @param rootUrl defines the url where the files to load is located
  8917. * @param scene defines the current scene
  8918. * @param files defines the list of files to load (1 per face)
  8919. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  8920. * @param onLoad defines an optional callback raised when the texture is loaded
  8921. * @param onError defines an optional callback raised if there is an issue to load the texture
  8922. * @param format defines the format of the data
  8923. * @param forcedExtension defines the extension to use to pick the right loader
  8924. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  8925. * @returns the cube texture as an InternalTexture
  8926. */
  8927. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap?: boolean, onLoad?: Nullable<(data?: any) => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number, forcedExtension?: any, createPolynomials?: boolean): InternalTexture;
  8928. private setCubeMapTextureParams(gl, loadMipmap);
  8929. /**
  8930. * Update a raw cube texture
  8931. * @param texture defines the texture to udpdate
  8932. * @param data defines the data to store
  8933. * @param format defines the data format
  8934. * @param type defines the type fo the data (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  8935. * @param invertY defines if data must be stored with Y axis inverted
  8936. * @param compression defines the compression used (null by default)
  8937. * @param level defines which level of the texture to update
  8938. */
  8939. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>, level?: number): void;
  8940. /**
  8941. * Creates a new raw cube texture
  8942. * @param data defines the array of data to use to create each face
  8943. * @param size defines the size of the textures
  8944. * @param format defines the format of the data
  8945. * @param type defines the type fo the data (like BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT)
  8946. * @param generateMipMaps defines if the engine should generate the mip levels
  8947. * @param invertY defines if data must be stored with Y axis inverted
  8948. * @param samplingMode defines the required sampling mode (like BABYLON.Texture.NEAREST_SAMPLINGMODE)
  8949. * @param compression defines the compression used (null by default)
  8950. * @returns the cube texture as an InternalTexture
  8951. */
  8952. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  8953. /**
  8954. * Creates a new raw cube texture from a specified url
  8955. * @param url defines the url where the data is located
  8956. * @param scene defines the current scene
  8957. * @param size defines the size of the textures
  8958. * @param format defines the format of the data
  8959. * @param type defines the type fo the data (like BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT)
  8960. * @param noMipmap defines if the engine should avoid generating the mip levels
  8961. * @param callback defines a callback used to extract texture data from loaded data
  8962. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  8963. * @param onLoad defines a callback called when texture is loaded
  8964. * @param onError defines a callback called if there is an error
  8965. * @param samplingMode defines the required sampling mode (like BABYLON.Texture.NEAREST_SAMPLINGMODE)
  8966. * @param invertY defines if data must be stored with Y axis inverted
  8967. * @returns the cube texture as an InternalTexture
  8968. */
  8969. 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;
  8970. /**
  8971. * Update a raw 3D texture
  8972. * @param texture defines the texture to update
  8973. * @param data defines the data to store
  8974. * @param format defines the data format
  8975. * @param invertY defines if data must be stored with Y axis inverted
  8976. * @param compression defines the used compression (can be null)
  8977. */
  8978. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>): void;
  8979. /**
  8980. * Creates a new raw 3D texture
  8981. * @param data defines the data used to create the texture
  8982. * @param width defines the width of the texture
  8983. * @param height defines the height of the texture
  8984. * @param depth defines the depth of the texture
  8985. * @param format defines the format of the texture
  8986. * @param generateMipMaps defines if the engine must generate mip levels
  8987. * @param invertY defines if data must be stored with Y axis inverted
  8988. * @param samplingMode defines the required sampling mode (like BABYLON.Texture.NEAREST_SAMPLINGMODE)
  8989. * @param compression defines the compressed used (can be null)
  8990. * @returns a new raw 3D texture (stored in an InternalTexture)
  8991. */
  8992. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  8993. private _prepareWebGLTextureContinuation(texture, scene, noMipmap, isCompressed, samplingMode);
  8994. private _prepareWebGLTexture(texture, scene, width, height, invertY, noMipmap, isCompressed, processFunction, samplingMode?);
  8995. private _convertRGBtoRGBATextureData(rgbData, width, height, textureType);
  8996. /** @hidden */
  8997. _releaseFramebufferObjects(texture: InternalTexture): void;
  8998. /** @hidden */
  8999. _releaseTexture(texture: InternalTexture): void;
  9000. private setProgram(program);
  9001. private _boundUniforms;
  9002. /**
  9003. * Binds an effect to the webGL context
  9004. * @param effect defines the effect to bind
  9005. */
  9006. bindSamplers(effect: Effect): void;
  9007. private _moveBoundTextureOnTop(internalTexture);
  9008. private _getCorrectTextureChannel(channel, internalTexture);
  9009. private _linkTrackers(previous, next);
  9010. private _removeDesignatedSlot(internalTexture);
  9011. private _activateCurrentTexture();
  9012. /** @hidden */
  9013. protected _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): void;
  9014. /** @hidden */
  9015. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  9016. /**
  9017. * Sets a texture to the webGL context from a postprocess
  9018. * @param channel defines the channel to use
  9019. * @param postProcess defines the source postprocess
  9020. */
  9021. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  9022. /**
  9023. * Binds the output of the passed in post process to the texture channel specified
  9024. * @param channel The channel the texture should be bound to
  9025. * @param postProcess The post process which's output should be bound
  9026. */
  9027. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  9028. /**
  9029. * Unbind all textures from the webGL context
  9030. */
  9031. unbindAllTextures(): void;
  9032. /**
  9033. * Sets a texture to the according uniform.
  9034. * @param channel The texture channel
  9035. * @param uniform The uniform to set
  9036. * @param texture The texture to apply
  9037. */
  9038. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  9039. /**
  9040. * Sets a depth stencil texture from a render target to the according uniform.
  9041. * @param channel The texture channel
  9042. * @param uniform The uniform to set
  9043. * @param texture The render target texture containing the depth stencil texture to apply
  9044. */
  9045. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  9046. private _bindSamplerUniformToChannel(sourceSlot, destination);
  9047. private _getTextureWrapMode(mode);
  9048. private _setTexture(channel, texture, isPartOfTextureArray?, depthStencilTexture?);
  9049. /**
  9050. * Sets an array of texture to the webGL context
  9051. * @param channel defines the channel where the texture array must be set
  9052. * @param uniform defines the associated uniform location
  9053. * @param textures defines the array of textures to bind
  9054. */
  9055. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  9056. /** @hidden */
  9057. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  9058. private _setTextureParameterFloat(target, parameter, value, texture);
  9059. private _setTextureParameterInteger(target, parameter, value, texture?);
  9060. /**
  9061. * Reads pixels from the current frame buffer. Please note that this function can be slow
  9062. * @param x defines the x coordinate of the rectangle where pixels must be read
  9063. * @param y defines the y coordinate of the rectangle where pixels must be read
  9064. * @param width defines the width of the rectangle where pixels must be read
  9065. * @param height defines the height of the rectangle where pixels must be read
  9066. * @returns a Uint8Array containing RGBA colors
  9067. */
  9068. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  9069. /**
  9070. * Add an externaly attached data from its key.
  9071. * This method call will fail and return false, if such key already exists.
  9072. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  9073. * @param key the unique key that identifies the data
  9074. * @param data the data object to associate to the key for this Engine instance
  9075. * @return true if no such key were already present and the data was added successfully, false otherwise
  9076. */
  9077. addExternalData<T>(key: string, data: T): boolean;
  9078. /**
  9079. * Get an externaly attached data from its key
  9080. * @param key the unique key that identifies the data
  9081. * @return the associated data, if present (can be null), or undefined if not present
  9082. */
  9083. getExternalData<T>(key: string): T;
  9084. /**
  9085. * Get an externaly attached data from its key, create it using a factory if it's not already present
  9086. * @param key the unique key that identifies the data
  9087. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  9088. * @return the associated data, can be null if the factory returned null.
  9089. */
  9090. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  9091. /**
  9092. * Remove an externaly attached data from the Engine instance
  9093. * @param key the unique key that identifies the data
  9094. * @return true if the data was successfully removed, false if it doesn't exist
  9095. */
  9096. removeExternalData(key: string): boolean;
  9097. /**
  9098. * Unbind all vertex attributes from the webGL context
  9099. */
  9100. unbindAllAttributes(): void;
  9101. /**
  9102. * 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
  9103. */
  9104. releaseEffects(): void;
  9105. /**
  9106. * Dispose and release all associated resources
  9107. */
  9108. dispose(): void;
  9109. /**
  9110. * Display the loading screen
  9111. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  9112. */
  9113. displayLoadingUI(): void;
  9114. /**
  9115. * Hide the loading screen
  9116. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  9117. */
  9118. hideLoadingUI(): void;
  9119. /**
  9120. * Gets the current loading screen object
  9121. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  9122. */
  9123. /**
  9124. * Sets the current loading screen object
  9125. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  9126. */
  9127. loadingScreen: ILoadingScreen;
  9128. /**
  9129. * Sets the current loading screen text
  9130. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  9131. */
  9132. loadingUIText: string;
  9133. /**
  9134. * Sets the current loading screen background color
  9135. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  9136. */
  9137. loadingUIBackgroundColor: string;
  9138. /**
  9139. * Attach a new callback raised when context lost event is fired
  9140. * @param callback defines the callback to call
  9141. */
  9142. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  9143. /**
  9144. * Attach a new callback raised when context restored event is fired
  9145. * @param callback defines the callback to call
  9146. */
  9147. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  9148. /**
  9149. * Gets the source code of the vertex shader associated with a specific webGL program
  9150. * @param program defines the program to use
  9151. * @returns a string containing the source code of the vertex shader associated with the program
  9152. */
  9153. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  9154. /**
  9155. * Gets the source code of the fragment shader associated with a specific webGL program
  9156. * @param program defines the program to use
  9157. * @returns a string containing the source code of the fragment shader associated with the program
  9158. */
  9159. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  9160. /**
  9161. * Get the current error code of the webGL context
  9162. * @returns the error code
  9163. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  9164. */
  9165. getError(): number;
  9166. /**
  9167. * Gets the current framerate
  9168. * @returns a number representing the framerate
  9169. */
  9170. getFps(): number;
  9171. /**
  9172. * Gets the time spent between current and previous frame
  9173. * @returns a number representing the delta time in ms
  9174. */
  9175. getDeltaTime(): number;
  9176. private _measureFps();
  9177. /** @hidden */
  9178. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number): ArrayBufferView;
  9179. private _canRenderToFloatFramebuffer();
  9180. private _canRenderToHalfFloatFramebuffer();
  9181. private _canRenderToFramebuffer(type);
  9182. /** @hidden */
  9183. _getWebGLTextureType(type: number): number;
  9184. private _getInternalFormat(format);
  9185. /** @hidden */
  9186. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  9187. /** @hidden */
  9188. _getRGBAMultiSampleBufferFormat(type: number): number;
  9189. /**
  9190. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  9191. * @return the new query
  9192. */
  9193. createQuery(): WebGLQuery;
  9194. /**
  9195. * Delete and release a webGL query
  9196. * @param query defines the query to delete
  9197. * @return the current engine
  9198. */
  9199. deleteQuery(query: WebGLQuery): Engine;
  9200. /**
  9201. * Check if a given query has resolved and got its value
  9202. * @param query defines the query to check
  9203. * @returns true if the query got its value
  9204. */
  9205. isQueryResultAvailable(query: WebGLQuery): boolean;
  9206. /**
  9207. * Gets the value of a given query
  9208. * @param query defines the query to check
  9209. * @returns the value of the query
  9210. */
  9211. getQueryResult(query: WebGLQuery): number;
  9212. /**
  9213. * Initiates an occlusion query
  9214. * @param algorithmType defines the algorithm to use
  9215. * @param query defines the query to use
  9216. * @returns the current engine
  9217. * @see http://doc.babylonjs.com/features/occlusionquery
  9218. */
  9219. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  9220. /**
  9221. * Ends an occlusion query
  9222. * @see http://doc.babylonjs.com/features/occlusionquery
  9223. * @param algorithmType defines the algorithm to use
  9224. * @returns the current engine
  9225. */
  9226. endOcclusionQuery(algorithmType: number): Engine;
  9227. private _createTimeQuery();
  9228. private _deleteTimeQuery(query);
  9229. private _getTimeQueryResult(query);
  9230. private _getTimeQueryAvailability(query);
  9231. private _currentNonTimestampToken;
  9232. /**
  9233. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  9234. * Please note that only one query can be issued at a time
  9235. * @returns a time token used to track the time span
  9236. */
  9237. startTimeQuery(): Nullable<_TimeToken>;
  9238. /**
  9239. * Ends a time query
  9240. * @param token defines the token used to measure the time span
  9241. * @returns the time spent (in ns)
  9242. */
  9243. endTimeQuery(token: _TimeToken): int;
  9244. private getGlAlgorithmType(algorithmType);
  9245. /**
  9246. * Creates a webGL transform feedback object
  9247. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  9248. * @returns the webGL transform feedback object
  9249. */
  9250. createTransformFeedback(): WebGLTransformFeedback;
  9251. /**
  9252. * Delete a webGL transform feedback object
  9253. * @param value defines the webGL transform feedback object to delete
  9254. */
  9255. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  9256. /**
  9257. * Bind a webGL transform feedback object to the webgl context
  9258. * @param value defines the webGL transform feedback object to bind
  9259. */
  9260. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  9261. /**
  9262. * Begins a transform feedback operation
  9263. * @param usePoints defines if points or triangles must be used
  9264. */
  9265. beginTransformFeedback(usePoints?: boolean): void;
  9266. /**
  9267. * Ends a transform feedback operation
  9268. */
  9269. endTransformFeedback(): void;
  9270. /**
  9271. * Specify the varyings to use with transform feedback
  9272. * @param program defines the associated webGL program
  9273. * @param value defines the list of strings representing the varying names
  9274. */
  9275. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  9276. /**
  9277. * Bind a webGL buffer for a transform feedback operation
  9278. * @param value defines the webGL buffer to bind
  9279. */
  9280. bindTransformFeedbackBuffer(value: Nullable<WebGLBuffer>): void;
  9281. /** @hidden */
  9282. _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;
  9283. /** @hidden */
  9284. _loadFileAsync(url: string, database?: Database, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  9285. private _partialLoadFile(url, index, loadedFiles, scene, onfinish, onErrorCallBack?);
  9286. private _cascadeLoadFiles(scene, onfinish, files, onError?);
  9287. /**
  9288. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  9289. * @returns true if the engine can be created
  9290. * @ignorenaming
  9291. */
  9292. static isSupported(): boolean;
  9293. }
  9294. }
  9295. declare module BABYLON {
  9296. class NullEngineOptions {
  9297. renderWidth: number;
  9298. renderHeight: number;
  9299. textureSize: number;
  9300. deterministicLockstep: boolean;
  9301. lockstepMaxSteps: number;
  9302. }
  9303. /**
  9304. * The null engine class provides support for headless version of babylon.js.
  9305. * This can be used in server side scenario or for testing purposes
  9306. */
  9307. class NullEngine extends Engine {
  9308. private _options;
  9309. isDeterministicLockStep(): boolean;
  9310. getLockstepMaxSteps(): number;
  9311. getHardwareScalingLevel(): number;
  9312. constructor(options?: NullEngineOptions);
  9313. createVertexBuffer(vertices: FloatArray): WebGLBuffer;
  9314. createIndexBuffer(indices: IndicesArray): WebGLBuffer;
  9315. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  9316. getRenderWidth(useScreen?: boolean): number;
  9317. getRenderHeight(useScreen?: boolean): number;
  9318. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  9319. createShaderProgram(vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  9320. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): WebGLUniformLocation[];
  9321. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  9322. bindSamplers(effect: Effect): void;
  9323. enableEffect(effect: Effect): void;
  9324. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  9325. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  9326. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  9327. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  9328. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  9329. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  9330. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  9331. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  9332. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  9333. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  9334. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  9335. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  9336. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  9337. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  9338. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  9339. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  9340. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  9341. setFloat(uniform: WebGLUniformLocation, value: number): void;
  9342. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  9343. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  9344. setBool(uniform: WebGLUniformLocation, bool: number): void;
  9345. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  9346. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  9347. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  9348. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  9349. bindBuffers(vertexBuffers: {
  9350. [key: string]: VertexBuffer;
  9351. }, indexBuffer: WebGLBuffer, effect: Effect): void;
  9352. wipeCaches(bruteForce?: boolean): void;
  9353. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  9354. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  9355. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  9356. _createTexture(): WebGLTexture;
  9357. _releaseTexture(texture: InternalTexture): void;
  9358. createTexture(urlArg: string, noMipmap: boolean, invertY: boolean, scene: Scene, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<ArrayBuffer | HTMLImageElement>, fallBack?: InternalTexture, format?: number): InternalTexture;
  9359. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  9360. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  9361. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  9362. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  9363. createDynamicVertexBuffer(vertices: FloatArray): WebGLBuffer;
  9364. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  9365. /**
  9366. * Updates a dynamic vertex buffer.
  9367. * @param vertexBuffer the vertex buffer to update
  9368. * @param data the data used to update the vertex buffer
  9369. * @param byteOffset the byte offset of the data (optional)
  9370. * @param byteLength the byte length of the data (optional)
  9371. */
  9372. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  9373. protected _bindTextureDirectly(target: number, texture: InternalTexture): void;
  9374. _bindTexture(channel: number, texture: InternalTexture): void;
  9375. _releaseBuffer(buffer: WebGLBuffer): boolean;
  9376. releaseEffects(): void;
  9377. }
  9378. }
  9379. interface WebGLRenderingContext {
  9380. readonly RASTERIZER_DISCARD: number;
  9381. readonly DEPTH_COMPONENT24: number;
  9382. readonly TEXTURE_3D: number;
  9383. readonly TEXTURE_2D_ARRAY: number;
  9384. readonly TEXTURE_COMPARE_FUNC: number;
  9385. readonly TEXTURE_COMPARE_MODE: number;
  9386. readonly COMPARE_REF_TO_TEXTURE: number;
  9387. readonly TEXTURE_WRAP_R: number;
  9388. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  9389. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  9390. 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;
  9391. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  9392. readonly TRANSFORM_FEEDBACK: number;
  9393. readonly INTERLEAVED_ATTRIBS: number;
  9394. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  9395. createTransformFeedback(): WebGLTransformFeedback;
  9396. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  9397. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  9398. beginTransformFeedback(primitiveMode: number): void;
  9399. endTransformFeedback(): void;
  9400. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  9401. }
  9402. interface ImageBitmap {
  9403. readonly width: number;
  9404. readonly height: number;
  9405. close(): void;
  9406. }
  9407. interface WebGLQuery extends WebGLObject {
  9408. }
  9409. declare var WebGLQuery: {
  9410. prototype: WebGLQuery;
  9411. new (): WebGLQuery;
  9412. };
  9413. interface WebGLSampler extends WebGLObject {
  9414. }
  9415. declare var WebGLSampler: {
  9416. prototype: WebGLSampler;
  9417. new (): WebGLSampler;
  9418. };
  9419. interface WebGLSync extends WebGLObject {
  9420. }
  9421. declare var WebGLSync: {
  9422. prototype: WebGLSync;
  9423. new (): WebGLSync;
  9424. };
  9425. interface WebGLTransformFeedback extends WebGLObject {
  9426. }
  9427. declare var WebGLTransformFeedback: {
  9428. prototype: WebGLTransformFeedback;
  9429. new (): WebGLTransformFeedback;
  9430. };
  9431. interface WebGLVertexArrayObject extends WebGLObject {
  9432. }
  9433. declare var WebGLVertexArrayObject: {
  9434. prototype: WebGLVertexArrayObject;
  9435. new (): WebGLVertexArrayObject;
  9436. };
  9437. declare module BABYLON {
  9438. /**
  9439. * Single axis drag gizmo
  9440. */
  9441. class AxisDragGizmo extends Gizmo {
  9442. private _dragBehavior;
  9443. /**
  9444. * Creates an AxisDragGizmo
  9445. * @param gizmoLayer The utility layer the gizmo will be added to
  9446. * @param dragAxis The axis which the gizmo will be able to drag on
  9447. * @param color The color of the gizmo
  9448. */
  9449. constructor(gizmoLayer: UtilityLayerRenderer, dragAxis: Vector3, color: Color3);
  9450. /**
  9451. * Disposes of the gizmo
  9452. */
  9453. dispose(): void;
  9454. }
  9455. }
  9456. declare module BABYLON {
  9457. /**
  9458. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  9459. */
  9460. class Gizmo implements IDisposable {
  9461. /** The utility layer the gizmo will be added to */ gizmoLayer: UtilityLayerRenderer;
  9462. /**
  9463. * The root mesh of the gizmo
  9464. */
  9465. protected _rootMesh: Mesh;
  9466. /**
  9467. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  9468. */
  9469. attachedMesh: Nullable<Mesh>;
  9470. private _beforeRenderObserver;
  9471. /**
  9472. * Creates a gizmo
  9473. * @param gizmoLayer The utility layer the gizmo will be added to
  9474. */
  9475. constructor(/** The utility layer the gizmo will be added to */ gizmoLayer: UtilityLayerRenderer);
  9476. /**
  9477. * Disposes of the gizmo
  9478. */
  9479. dispose(): void;
  9480. }
  9481. }
  9482. declare module BABYLON {
  9483. /**
  9484. * Gizmo that enables dragging a mesh along 3 axis
  9485. */
  9486. class PositionGizmo extends Gizmo {
  9487. private _xDrag;
  9488. private _yDrag;
  9489. private _zDrag;
  9490. attachedMesh: Nullable<Mesh>;
  9491. /**
  9492. * Creates a PositionGizmo
  9493. * @param gizmoLayer The utility layer the gizmo will be added to
  9494. */
  9495. constructor(gizmoLayer: UtilityLayerRenderer);
  9496. /**
  9497. * Disposes of the gizmo
  9498. */
  9499. dispose(): void;
  9500. }
  9501. }
  9502. declare module BABYLON {
  9503. /**
  9504. * Represents the different options available during the creation of
  9505. * a Environment helper.
  9506. *
  9507. * This can control the default ground, skybox and image processing setup of your scene.
  9508. */
  9509. interface IEnvironmentHelperOptions {
  9510. /**
  9511. * Specifies wether or not to create a ground.
  9512. * True by default.
  9513. */
  9514. createGround: boolean;
  9515. /**
  9516. * Specifies the ground size.
  9517. * 15 by default.
  9518. */
  9519. groundSize: number;
  9520. /**
  9521. * The texture used on the ground for the main color.
  9522. * Comes from the BabylonJS CDN by default.
  9523. *
  9524. * Remarks: Can be either a texture or a url.
  9525. */
  9526. groundTexture: string | BaseTexture;
  9527. /**
  9528. * The color mixed in the ground texture by default.
  9529. * BabylonJS clearColor by default.
  9530. */
  9531. groundColor: Color3;
  9532. /**
  9533. * Specifies the ground opacity.
  9534. * 1 by default.
  9535. */
  9536. groundOpacity: number;
  9537. /**
  9538. * Enables the ground to receive shadows.
  9539. * True by default.
  9540. */
  9541. enableGroundShadow: boolean;
  9542. /**
  9543. * Helps preventing the shadow to be fully black on the ground.
  9544. * 0.5 by default.
  9545. */
  9546. groundShadowLevel: number;
  9547. /**
  9548. * Creates a mirror texture attach to the ground.
  9549. * false by default.
  9550. */
  9551. enableGroundMirror: boolean;
  9552. /**
  9553. * Specifies the ground mirror size ratio.
  9554. * 0.3 by default as the default kernel is 64.
  9555. */
  9556. groundMirrorSizeRatio: number;
  9557. /**
  9558. * Specifies the ground mirror blur kernel size.
  9559. * 64 by default.
  9560. */
  9561. groundMirrorBlurKernel: number;
  9562. /**
  9563. * Specifies the ground mirror visibility amount.
  9564. * 1 by default
  9565. */
  9566. groundMirrorAmount: number;
  9567. /**
  9568. * Specifies the ground mirror reflectance weight.
  9569. * This uses the standard weight of the background material to setup the fresnel effect
  9570. * of the mirror.
  9571. * 1 by default.
  9572. */
  9573. groundMirrorFresnelWeight: number;
  9574. /**
  9575. * Specifies the ground mirror Falloff distance.
  9576. * This can helps reducing the size of the reflection.
  9577. * 0 by Default.
  9578. */
  9579. groundMirrorFallOffDistance: number;
  9580. /**
  9581. * Specifies the ground mirror texture type.
  9582. * Unsigned Int by Default.
  9583. */
  9584. groundMirrorTextureType: number;
  9585. /**
  9586. * Specifies a bias applied to the ground vertical position to prevent z-fighyting with
  9587. * the shown objects.
  9588. */
  9589. groundYBias: number;
  9590. /**
  9591. * Specifies wether or not to create a skybox.
  9592. * True by default.
  9593. */
  9594. createSkybox: boolean;
  9595. /**
  9596. * Specifies the skybox size.
  9597. * 20 by default.
  9598. */
  9599. skyboxSize: number;
  9600. /**
  9601. * The texture used on the skybox for the main color.
  9602. * Comes from the BabylonJS CDN by default.
  9603. *
  9604. * Remarks: Can be either a texture or a url.
  9605. */
  9606. skyboxTexture: string | BaseTexture;
  9607. /**
  9608. * The color mixed in the skybox texture by default.
  9609. * BabylonJS clearColor by default.
  9610. */
  9611. skyboxColor: Color3;
  9612. /**
  9613. * The background rotation around the Y axis of the scene.
  9614. * This helps aligning the key lights of your scene with the background.
  9615. * 0 by default.
  9616. */
  9617. backgroundYRotation: number;
  9618. /**
  9619. * Compute automatically the size of the elements to best fit with the scene.
  9620. */
  9621. sizeAuto: boolean;
  9622. /**
  9623. * Default position of the rootMesh if autoSize is not true.
  9624. */
  9625. rootPosition: Vector3;
  9626. /**
  9627. * Sets up the image processing in the scene.
  9628. * true by default.
  9629. */
  9630. setupImageProcessing: boolean;
  9631. /**
  9632. * The texture used as your environment texture in the scene.
  9633. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  9634. *
  9635. * Remarks: Can be either a texture or a url.
  9636. */
  9637. environmentTexture: string | BaseTexture;
  9638. /**
  9639. * The value of the exposure to apply to the scene.
  9640. * 0.6 by default if setupImageProcessing is true.
  9641. */
  9642. cameraExposure: number;
  9643. /**
  9644. * The value of the contrast to apply to the scene.
  9645. * 1.6 by default if setupImageProcessing is true.
  9646. */
  9647. cameraContrast: number;
  9648. /**
  9649. * Specifies wether or not tonemapping should be enabled in the scene.
  9650. * true by default if setupImageProcessing is true.
  9651. */
  9652. toneMappingEnabled: boolean;
  9653. }
  9654. /**
  9655. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  9656. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  9657. * It also helps with the default setup of your imageProcessing configuration.
  9658. */
  9659. class EnvironmentHelper {
  9660. /**
  9661. * Default ground texture URL.
  9662. */
  9663. private static _groundTextureCDNUrl;
  9664. /**
  9665. * Default skybox texture URL.
  9666. */
  9667. private static _skyboxTextureCDNUrl;
  9668. /**
  9669. * Default environment texture URL.
  9670. */
  9671. private static _environmentTextureCDNUrl;
  9672. /**
  9673. * Creates the default options for the helper.
  9674. */
  9675. private static _getDefaultOptions();
  9676. private _rootMesh;
  9677. /**
  9678. * Gets the root mesh created by the helper.
  9679. */
  9680. readonly rootMesh: Mesh;
  9681. private _skybox;
  9682. /**
  9683. * Gets the skybox created by the helper.
  9684. */
  9685. readonly skybox: Nullable<Mesh>;
  9686. private _skyboxTexture;
  9687. /**
  9688. * Gets the skybox texture created by the helper.
  9689. */
  9690. readonly skyboxTexture: Nullable<BaseTexture>;
  9691. private _skyboxMaterial;
  9692. /**
  9693. * Gets the skybox material created by the helper.
  9694. */
  9695. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  9696. private _ground;
  9697. /**
  9698. * Gets the ground mesh created by the helper.
  9699. */
  9700. readonly ground: Nullable<Mesh>;
  9701. private _groundTexture;
  9702. /**
  9703. * Gets the ground texture created by the helper.
  9704. */
  9705. readonly groundTexture: Nullable<BaseTexture>;
  9706. private _groundMirror;
  9707. /**
  9708. * Gets the ground mirror created by the helper.
  9709. */
  9710. readonly groundMirror: Nullable<MirrorTexture>;
  9711. /**
  9712. * Gets the ground mirror render list to helps pushing the meshes
  9713. * you wish in the ground reflection.
  9714. */
  9715. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  9716. private _groundMaterial;
  9717. /**
  9718. * Gets the ground material created by the helper.
  9719. */
  9720. readonly groundMaterial: Nullable<BackgroundMaterial>;
  9721. /**
  9722. * Stores the creation options.
  9723. */
  9724. private readonly _scene;
  9725. private _options;
  9726. /**
  9727. * This observable will be notified with any error during the creation of the environment,
  9728. * mainly texture creation errors.
  9729. */
  9730. onErrorObservable: Observable<{
  9731. message?: string;
  9732. exception?: any;
  9733. }>;
  9734. /**
  9735. * constructor
  9736. * @param options
  9737. * @param scene The scene to add the material to
  9738. */
  9739. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  9740. /**
  9741. * Updates the background according to the new options
  9742. * @param options
  9743. */
  9744. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  9745. /**
  9746. * Sets the primary color of all the available elements.
  9747. * @param color the main color to affect to the ground and the background
  9748. */
  9749. setMainColor(color: Color3): void;
  9750. /**
  9751. * Setup the image processing according to the specified options.
  9752. */
  9753. private _setupImageProcessing();
  9754. /**
  9755. * Setup the environment texture according to the specified options.
  9756. */
  9757. private _setupEnvironmentTexture();
  9758. /**
  9759. * Setup the background according to the specified options.
  9760. */
  9761. private _setupBackground();
  9762. /**
  9763. * Get the scene sizes according to the setup.
  9764. */
  9765. private _getSceneSize();
  9766. /**
  9767. * Setup the ground according to the specified options.
  9768. */
  9769. private _setupGround(sceneSize);
  9770. /**
  9771. * Setup the ground material according to the specified options.
  9772. */
  9773. private _setupGroundMaterial();
  9774. /**
  9775. * Setup the ground diffuse texture according to the specified options.
  9776. */
  9777. private _setupGroundDiffuseTexture();
  9778. /**
  9779. * Setup the ground mirror texture according to the specified options.
  9780. */
  9781. private _setupGroundMirrorTexture(sceneSize);
  9782. /**
  9783. * Setup the ground to receive the mirror texture.
  9784. */
  9785. private _setupMirrorInGroundMaterial();
  9786. /**
  9787. * Setup the skybox according to the specified options.
  9788. */
  9789. private _setupSkybox(sceneSize);
  9790. /**
  9791. * Setup the skybox material according to the specified options.
  9792. */
  9793. private _setupSkyboxMaterial();
  9794. /**
  9795. * Setup the skybox reflection texture according to the specified options.
  9796. */
  9797. private _setupSkyboxReflectionTexture();
  9798. private _errorHandler;
  9799. /**
  9800. * Dispose all the elements created by the Helper.
  9801. */
  9802. dispose(): void;
  9803. }
  9804. }
  9805. declare module BABYLON {
  9806. /**
  9807. * Represents all the data needed to create a ParticleSystem.
  9808. */
  9809. interface IParticleSystemData {
  9810. /**
  9811. * ParticleSystem type
  9812. */
  9813. type: string;
  9814. /**
  9815. * Shape of the emitter
  9816. */
  9817. emitterType: string;
  9818. /**
  9819. * Maximum number of particles in the system
  9820. */
  9821. capacity: number;
  9822. /**
  9823. * Link for the texture file
  9824. */
  9825. textureFile: string;
  9826. /**
  9827. * minEmitBox Vector3
  9828. */
  9829. minEmitBox?: {
  9830. x: number;
  9831. y: number;
  9832. z: number;
  9833. };
  9834. /**
  9835. * maxEmitBox Vector3
  9836. */
  9837. maxEmitBox?: {
  9838. x: number;
  9839. y: number;
  9840. z: number;
  9841. };
  9842. /**
  9843. * color1 Color4
  9844. */
  9845. color1: {
  9846. r: number;
  9847. g: number;
  9848. b: number;
  9849. a: number;
  9850. };
  9851. /**
  9852. * color2 Color4
  9853. */
  9854. color2: {
  9855. r: number;
  9856. g: number;
  9857. b: number;
  9858. a: number;
  9859. };
  9860. /**
  9861. * colorDead Color4
  9862. */
  9863. colorDead: {
  9864. r: number;
  9865. g: number;
  9866. b: number;
  9867. a: number;
  9868. };
  9869. /**
  9870. * Minimum size of each particle
  9871. */
  9872. minSize: number;
  9873. /**
  9874. * Maximum size of each particle
  9875. */
  9876. maxSize: number;
  9877. /**
  9878. * Minimum lifetime for each particle
  9879. */
  9880. minLifeTime: number;
  9881. /**
  9882. * Maximum lifetime for each particle
  9883. */
  9884. maxLifeTime: number;
  9885. /**
  9886. * Emit rate
  9887. */
  9888. emitRate: number;
  9889. /**
  9890. * Blend Mode
  9891. */
  9892. blendMode: number;
  9893. /**
  9894. * gravity Vector3
  9895. */
  9896. gravity: {
  9897. x: number;
  9898. y: number;
  9899. z: number;
  9900. };
  9901. /**
  9902. * direction1 Vector3
  9903. */
  9904. direction1?: {
  9905. x: number;
  9906. y: number;
  9907. z: number;
  9908. };
  9909. /**
  9910. * direction2 Vector3
  9911. */
  9912. direction2?: {
  9913. x: number;
  9914. y: number;
  9915. z: number;
  9916. };
  9917. /**
  9918. * Minimum Angular Speed
  9919. */
  9920. minAngularSpeed: number;
  9921. /**
  9922. * Maximum Angular Speed
  9923. */
  9924. maxAngularSpeed: number;
  9925. /**
  9926. * Minimum Emit Power
  9927. */
  9928. minEmitPower: number;
  9929. /**
  9930. * Maximum Emit Power
  9931. */
  9932. maxEmitPower: number;
  9933. /**
  9934. * Update Speed
  9935. */
  9936. updateSpeed: number;
  9937. /**
  9938. * Radius
  9939. */
  9940. radius?: number;
  9941. /**
  9942. * Angle
  9943. */
  9944. angle?: number;
  9945. }
  9946. /**
  9947. * This class is made for on one-liner static method to help creating particle systems.
  9948. */
  9949. class ParticleHelper {
  9950. /**
  9951. * Base Assets URL.
  9952. */
  9953. private static _baseAssetsUrl;
  9954. private static _scene;
  9955. private static _emitter;
  9956. /**
  9957. * This is the main static method (one-liner) of this helper to create different particle systems.
  9958. * @param type This string represents the type to the particle system to create
  9959. * @param emitter The object where the particle system will start to emit from.
  9960. * @param scene The scene where the particle system should live.
  9961. * @param gpu If the system will use gpu.
  9962. * @returns the ParticleSystem created.
  9963. */
  9964. static CreateAsync(type: string, emitter: AbstractMesh, scene?: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystem>;
  9965. private static _createSystem(data);
  9966. }
  9967. }
  9968. declare module BABYLON {
  9969. /**
  9970. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  9971. * As a subclass of Node, this allow parenting to the camera or multiple videos with different locations in the scene.
  9972. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  9973. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  9974. */
  9975. class VideoDome extends Node {
  9976. /**
  9977. * The video texture being displayed on the sphere
  9978. */
  9979. protected _videoTexture: VideoTexture;
  9980. /**
  9981. * The skybox material
  9982. */
  9983. protected _material: BackgroundMaterial;
  9984. /**
  9985. * The surface used for the skybox
  9986. */
  9987. protected _mesh: Mesh;
  9988. /**
  9989. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  9990. * Also see the options.resolution property.
  9991. */
  9992. fovMultiplier: number;
  9993. /**
  9994. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  9995. * @param name Element's name, child elements will append suffixes for their own names.
  9996. * @param urlsOrVideo
  9997. * @param options An object containing optional or exposed sub element properties:
  9998. * @param options **resolution=12** Integer, lower resolutions have more artifacts at extreme fovs
  9999. * @param options **clickToPlay=false** Add a click to play listener to the video, does not prevent autoplay.
  10000. * @param options **autoPlay=true** Automatically attempt to being playing the video.
  10001. * @param options **loop=true** Automatically loop video on end.
  10002. * @param options **size=1000** Physical radius to create the dome at, defaults to approximately half the far clip plane.
  10003. */
  10004. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  10005. resolution?: number;
  10006. clickToPlay?: boolean;
  10007. autoPlay?: boolean;
  10008. loop?: boolean;
  10009. size?: number;
  10010. }, scene: Scene);
  10011. /**
  10012. * Releases resources associated with this node.
  10013. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  10014. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  10015. */
  10016. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  10017. }
  10018. }
  10019. declare module BABYLON {
  10020. /**
  10021. * This class can be used to get instrumentation data from a Babylon engine
  10022. */
  10023. class EngineInstrumentation implements IDisposable {
  10024. engine: Engine;
  10025. private _captureGPUFrameTime;
  10026. private _gpuFrameTimeToken;
  10027. private _gpuFrameTime;
  10028. private _captureShaderCompilationTime;
  10029. private _shaderCompilationTime;
  10030. private _onBeginFrameObserver;
  10031. private _onEndFrameObserver;
  10032. private _onBeforeShaderCompilationObserver;
  10033. private _onAfterShaderCompilationObserver;
  10034. /**
  10035. * Gets the perf counter used for GPU frame time
  10036. */
  10037. readonly gpuFrameTimeCounter: PerfCounter;
  10038. /**
  10039. * Gets the GPU frame time capture status
  10040. */
  10041. /**
  10042. * Enable or disable the GPU frame time capture
  10043. */
  10044. captureGPUFrameTime: boolean;
  10045. /**
  10046. * Gets the perf counter used for shader compilation time
  10047. */
  10048. readonly shaderCompilationTimeCounter: PerfCounter;
  10049. /**
  10050. * Gets the shader compilation time capture status
  10051. */
  10052. /**
  10053. * Enable or disable the shader compilation time capture
  10054. */
  10055. captureShaderCompilationTime: boolean;
  10056. constructor(engine: Engine);
  10057. dispose(): void;
  10058. }
  10059. }
  10060. declare module BABYLON {
  10061. /**
  10062. * This class can be used to get instrumentation data from a Babylon engine
  10063. */
  10064. class SceneInstrumentation implements IDisposable {
  10065. scene: Scene;
  10066. private _captureActiveMeshesEvaluationTime;
  10067. private _activeMeshesEvaluationTime;
  10068. private _captureRenderTargetsRenderTime;
  10069. private _renderTargetsRenderTime;
  10070. private _captureFrameTime;
  10071. private _frameTime;
  10072. private _captureRenderTime;
  10073. private _renderTime;
  10074. private _captureInterFrameTime;
  10075. private _interFrameTime;
  10076. private _captureParticlesRenderTime;
  10077. private _particlesRenderTime;
  10078. private _captureSpritesRenderTime;
  10079. private _spritesRenderTime;
  10080. private _capturePhysicsTime;
  10081. private _physicsTime;
  10082. private _captureAnimationsTime;
  10083. private _animationsTime;
  10084. private _onBeforeActiveMeshesEvaluationObserver;
  10085. private _onAfterActiveMeshesEvaluationObserver;
  10086. private _onBeforeRenderTargetsRenderObserver;
  10087. private _onAfterRenderTargetsRenderObserver;
  10088. private _onAfterRenderObserver;
  10089. private _onBeforeDrawPhaseObserver;
  10090. private _onAfterDrawPhaseObserver;
  10091. private _onBeforeAnimationsObserver;
  10092. private _onBeforeParticlesRenderingObserver;
  10093. private _onAfterParticlesRenderingObserver;
  10094. private _onBeforeSpritesRenderingObserver;
  10095. private _onAfterSpritesRenderingObserver;
  10096. private _onBeforePhysicsObserver;
  10097. private _onAfterPhysicsObserver;
  10098. private _onAfterAnimationsObserver;
  10099. /**
  10100. * Gets the perf counter used for active meshes evaluation time
  10101. */
  10102. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  10103. /**
  10104. * Gets the active meshes evaluation time capture status
  10105. */
  10106. /**
  10107. * Enable or disable the active meshes evaluation time capture
  10108. */
  10109. captureActiveMeshesEvaluationTime: boolean;
  10110. /**
  10111. * Gets the perf counter used for render targets render time
  10112. */
  10113. readonly renderTargetsRenderTimeCounter: PerfCounter;
  10114. /**
  10115. * Gets the render targets render time capture status
  10116. */
  10117. /**
  10118. * Enable or disable the render targets render time capture
  10119. */
  10120. captureRenderTargetsRenderTime: boolean;
  10121. /**
  10122. * Gets the perf counter used for particles render time
  10123. */
  10124. readonly particlesRenderTimeCounter: PerfCounter;
  10125. /**
  10126. * Gets the particles render time capture status
  10127. */
  10128. /**
  10129. * Enable or disable the particles render time capture
  10130. */
  10131. captureParticlesRenderTime: boolean;
  10132. /**
  10133. * Gets the perf counter used for sprites render time
  10134. */
  10135. readonly spritesRenderTimeCounter: PerfCounter;
  10136. /**
  10137. * Gets the sprites render time capture status
  10138. */
  10139. /**
  10140. * Enable or disable the sprites render time capture
  10141. */
  10142. captureSpritesRenderTime: boolean;
  10143. /**
  10144. * Gets the perf counter used for physics time
  10145. */
  10146. readonly physicsTimeCounter: PerfCounter;
  10147. /**
  10148. * Gets the physics time capture status
  10149. */
  10150. /**
  10151. * Enable or disable the physics time capture
  10152. */
  10153. capturePhysicsTime: boolean;
  10154. /**
  10155. * Gets the perf counter used for animations time
  10156. */
  10157. readonly animationsTimeCounter: PerfCounter;
  10158. /**
  10159. * Gets the animations time capture status
  10160. */
  10161. /**
  10162. * Enable or disable the animations time capture
  10163. */
  10164. captureAnimationsTime: boolean;
  10165. /**
  10166. * Gets the perf counter used for frame time capture
  10167. */
  10168. readonly frameTimeCounter: PerfCounter;
  10169. /**
  10170. * Gets the frame time capture status
  10171. */
  10172. /**
  10173. * Enable or disable the frame time capture
  10174. */
  10175. captureFrameTime: boolean;
  10176. /**
  10177. * Gets the perf counter used for inter-frames time capture
  10178. */
  10179. readonly interFrameTimeCounter: PerfCounter;
  10180. /**
  10181. * Gets the inter-frames time capture status
  10182. */
  10183. /**
  10184. * Enable or disable the inter-frames time capture
  10185. */
  10186. captureInterFrameTime: boolean;
  10187. /**
  10188. * Gets the perf counter used for render time capture
  10189. */
  10190. readonly renderTimeCounter: PerfCounter;
  10191. /**
  10192. * Gets the render time capture status
  10193. */
  10194. /**
  10195. * Enable or disable the render time capture
  10196. */
  10197. captureRenderTime: boolean;
  10198. /**
  10199. * Gets the perf counter used for draw calls
  10200. */
  10201. readonly drawCallsCounter: PerfCounter;
  10202. /**
  10203. * Gets the perf counter used for texture collisions
  10204. */
  10205. readonly textureCollisionsCounter: PerfCounter;
  10206. constructor(scene: Scene);
  10207. dispose(): void;
  10208. }
  10209. }
  10210. declare module BABYLON {
  10211. /**
  10212. * @hidden
  10213. **/
  10214. class _TimeToken {
  10215. _startTimeQuery: Nullable<WebGLQuery>;
  10216. _endTimeQuery: Nullable<WebGLQuery>;
  10217. _timeElapsedQuery: Nullable<WebGLQuery>;
  10218. _timeElapsedQueryEnded: boolean;
  10219. }
  10220. }
  10221. declare module BABYLON {
  10222. /**
  10223. * Effect layer options. This helps customizing the behaviour
  10224. * of the effect layer.
  10225. */
  10226. interface IEffectLayerOptions {
  10227. /**
  10228. * Multiplication factor apply to the canvas size to compute the render target size
  10229. * used to generated the objects (the smaller the faster).
  10230. */
  10231. mainTextureRatio: number;
  10232. /**
  10233. * Enforces a fixed size texture to ensure effect stability across devices.
  10234. */
  10235. mainTextureFixedSize?: number;
  10236. /**
  10237. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  10238. */
  10239. alphaBlendingMode: number;
  10240. /**
  10241. * The camera attached to the layer.
  10242. */
  10243. camera: Nullable<Camera>;
  10244. }
  10245. /**
  10246. * The effect layer Helps adding post process effect blended with the main pass.
  10247. *
  10248. * This can be for instance use to generate glow or higlight effects on the scene.
  10249. *
  10250. * The effect layer class can not be used directly and is intented to inherited from to be
  10251. * customized per effects.
  10252. */
  10253. abstract class EffectLayer {
  10254. private _vertexBuffers;
  10255. private _indexBuffer;
  10256. private _cachedDefines;
  10257. private _effectLayerMapGenerationEffect;
  10258. private _effectLayerOptions;
  10259. private _mergeEffect;
  10260. protected _scene: Scene;
  10261. protected _engine: Engine;
  10262. protected _maxSize: number;
  10263. protected _mainTextureDesiredSize: ISize;
  10264. protected _mainTexture: RenderTargetTexture;
  10265. protected _shouldRender: boolean;
  10266. protected _postProcesses: PostProcess[];
  10267. protected _textures: BaseTexture[];
  10268. protected _emissiveTextureAndColor: {
  10269. texture: Nullable<BaseTexture>;
  10270. color: Color4;
  10271. };
  10272. /**
  10273. * The name of the layer
  10274. */
  10275. name: string;
  10276. /**
  10277. * The clear color of the texture used to generate the glow map.
  10278. */
  10279. neutralColor: Color4;
  10280. /**
  10281. * Specifies wether the highlight layer is enabled or not.
  10282. */
  10283. isEnabled: boolean;
  10284. /**
  10285. * Gets the camera attached to the layer.
  10286. */
  10287. readonly camera: Nullable<Camera>;
  10288. /**
  10289. * An event triggered when the effect layer has been disposed.
  10290. */
  10291. onDisposeObservable: Observable<EffectLayer>;
  10292. /**
  10293. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  10294. */
  10295. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  10296. /**
  10297. * An event triggered when the generated texture is being merged in the scene.
  10298. */
  10299. onBeforeComposeObservable: Observable<EffectLayer>;
  10300. /**
  10301. * An event triggered when the generated texture has been merged in the scene.
  10302. */
  10303. onAfterComposeObservable: Observable<EffectLayer>;
  10304. /**
  10305. * An event triggered when the efffect layer changes its size.
  10306. */
  10307. onSizeChangedObservable: Observable<EffectLayer>;
  10308. /**
  10309. * Instantiates a new effect Layer and references it in the scene.
  10310. * @param name The name of the layer
  10311. * @param scene The scene to use the layer in
  10312. */
  10313. constructor(
  10314. /** The Friendly of the effect in the scene */
  10315. name: string, scene: Scene);
  10316. /**
  10317. * Get the effect name of the layer.
  10318. * @return The effect name
  10319. */
  10320. abstract getEffectName(): string;
  10321. /**
  10322. * Checks for the readiness of the element composing the layer.
  10323. * @param subMesh the mesh to check for
  10324. * @param useInstances specify wether or not to use instances to render the mesh
  10325. * @return true if ready otherwise, false
  10326. */
  10327. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  10328. /**
  10329. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  10330. * @returns true if the effect requires stencil during the main canvas render pass.
  10331. */
  10332. abstract needStencil(): boolean;
  10333. /**
  10334. * Create the merge effect. This is the shader use to blit the information back
  10335. * to the main canvas at the end of the scene rendering.
  10336. * @returns The effect containing the shader used to merge the effect on the main canvas
  10337. */
  10338. protected abstract _createMergeEffect(): Effect;
  10339. /**
  10340. * Creates the render target textures and post processes used in the effect layer.
  10341. */
  10342. protected abstract _createTextureAndPostProcesses(): void;
  10343. /**
  10344. * Implementation specific of rendering the generating effect on the main canvas.
  10345. * @param effect The effect used to render through
  10346. */
  10347. protected abstract _internalRender(effect: Effect): void;
  10348. /**
  10349. * Sets the required values for both the emissive texture and and the main color.
  10350. */
  10351. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  10352. /**
  10353. * Free any resources and references associated to a mesh.
  10354. * Internal use
  10355. * @param mesh The mesh to free.
  10356. */
  10357. abstract _disposeMesh(mesh: Mesh): void;
  10358. /**
  10359. * Serializes this layer (Glow or Highlight for example)
  10360. * @returns a serialized layer object
  10361. */
  10362. abstract serialize?(): any;
  10363. /**
  10364. * Initializes the effect layer with the required options.
  10365. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  10366. */
  10367. protected _init(options: Partial<IEffectLayerOptions>): void;
  10368. /**
  10369. * Generates the index buffer of the full screen quad blending to the main canvas.
  10370. */
  10371. private _generateIndexBuffer();
  10372. /**
  10373. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  10374. */
  10375. private _genrateVertexBuffer();
  10376. /**
  10377. * Sets the main texture desired size which is the closest power of two
  10378. * of the engine canvas size.
  10379. */
  10380. private _setMainTextureSize();
  10381. /**
  10382. * Creates the main texture for the effect layer.
  10383. */
  10384. protected _createMainTexture(): void;
  10385. /**
  10386. * Checks for the readiness of the element composing the layer.
  10387. * @param subMesh the mesh to check for
  10388. * @param useInstances specify wether or not to use instances to render the mesh
  10389. * @param emissiveTexture the associated emissive texture used to generate the glow
  10390. * @return true if ready otherwise, false
  10391. */
  10392. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  10393. /**
  10394. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  10395. */
  10396. render(): void;
  10397. /**
  10398. * Determine if a given mesh will be used in the current effect.
  10399. * @param mesh mesh to test
  10400. * @returns true if the mesh will be used
  10401. */
  10402. hasMesh(mesh: AbstractMesh): boolean;
  10403. /**
  10404. * Returns true if the layer contains information to display, otherwise false.
  10405. * @returns true if the glow layer should be rendered
  10406. */
  10407. shouldRender(): boolean;
  10408. /**
  10409. * Returns true if the mesh should render, otherwise false.
  10410. * @param mesh The mesh to render
  10411. * @returns true if it should render otherwise false
  10412. */
  10413. protected _shouldRenderMesh(mesh: Mesh): boolean;
  10414. /**
  10415. * Returns true if the mesh should render, otherwise false.
  10416. * @param mesh The mesh to render
  10417. * @returns true if it should render otherwise false
  10418. */
  10419. protected _shouldRenderEmissiveTextureForMesh(mesh: Mesh): boolean;
  10420. /**
  10421. * Renders the submesh passed in parameter to the generation map.
  10422. */
  10423. protected _renderSubMesh(subMesh: SubMesh): void;
  10424. /**
  10425. * Rebuild the required buffers.
  10426. * @hidden Internal use only.
  10427. */
  10428. _rebuild(): void;
  10429. /**
  10430. * Dispose only the render target textures and post process.
  10431. */
  10432. private _disposeTextureAndPostProcesses();
  10433. /**
  10434. * Dispose the highlight layer and free resources.
  10435. */
  10436. dispose(): void;
  10437. /**
  10438. * Gets the class name of the effect layer
  10439. * @returns the string with the class name of the effect layer
  10440. */
  10441. getClassName(): string;
  10442. /**
  10443. * Creates an effect layer from parsed effect layer data
  10444. * @param parsedEffectLayer defines effect layer data
  10445. * @param scene defines the current scene
  10446. * @param rootUrl defines the root URL containing the effect layer information
  10447. * @returns a parsed effect Layer
  10448. */
  10449. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  10450. }
  10451. }
  10452. declare module BABYLON {
  10453. /**
  10454. * Glow layer options. This helps customizing the behaviour
  10455. * of the glow layer.
  10456. */
  10457. interface IGlowLayerOptions {
  10458. /**
  10459. * Multiplication factor apply to the canvas size to compute the render target size
  10460. * used to generated the glowing objects (the smaller the faster).
  10461. */
  10462. mainTextureRatio: number;
  10463. /**
  10464. * Enforces a fixed size texture to ensure resize independant blur.
  10465. */
  10466. mainTextureFixedSize?: number;
  10467. /**
  10468. * How big is the kernel of the blur texture.
  10469. */
  10470. blurKernelSize: number;
  10471. /**
  10472. * The camera attached to the layer.
  10473. */
  10474. camera: Nullable<Camera>;
  10475. /**
  10476. * Enable MSAA by chosing the number of samples.
  10477. */
  10478. mainTextureSamples?: number;
  10479. }
  10480. /**
  10481. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  10482. *
  10483. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  10484. * glowy meshes to your scene.
  10485. *
  10486. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  10487. */
  10488. class GlowLayer extends EffectLayer {
  10489. /**
  10490. * Effect Name of the layer.
  10491. */
  10492. static readonly EffectName: string;
  10493. /**
  10494. * The default blur kernel size used for the glow.
  10495. */
  10496. static DefaultBlurKernelSize: number;
  10497. /**
  10498. * The default texture size ratio used for the glow.
  10499. */
  10500. static DefaultTextureRatio: number;
  10501. /**
  10502. * Gets the kernel size of the blur.
  10503. */
  10504. /**
  10505. * Sets the kernel size of the blur.
  10506. */
  10507. blurKernelSize: number;
  10508. /**
  10509. * Gets the glow intensity.
  10510. */
  10511. /**
  10512. * Sets the glow intensity.
  10513. */
  10514. intensity: number;
  10515. private _options;
  10516. private _intensity;
  10517. private _horizontalBlurPostprocess1;
  10518. private _verticalBlurPostprocess1;
  10519. private _horizontalBlurPostprocess2;
  10520. private _verticalBlurPostprocess2;
  10521. private _blurTexture1;
  10522. private _blurTexture2;
  10523. private _postProcesses1;
  10524. private _postProcesses2;
  10525. private _includedOnlyMeshes;
  10526. private _excludedMeshes;
  10527. /**
  10528. * Callback used to let the user override the color selection on a per mesh basis
  10529. */
  10530. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  10531. /**
  10532. * Callback used to let the user override the texture selection on a per mesh basis
  10533. */
  10534. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  10535. /**
  10536. * Instantiates a new glow Layer and references it to the scene.
  10537. * @param name The name of the layer
  10538. * @param scene The scene to use the layer in
  10539. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  10540. */
  10541. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  10542. /**
  10543. * Get the effect name of the layer.
  10544. * @return The effect name
  10545. */
  10546. getEffectName(): string;
  10547. /**
  10548. * Create the merge effect. This is the shader use to blit the information back
  10549. * to the main canvas at the end of the scene rendering.
  10550. */
  10551. protected _createMergeEffect(): Effect;
  10552. /**
  10553. * Creates the render target textures and post processes used in the glow layer.
  10554. */
  10555. protected _createTextureAndPostProcesses(): void;
  10556. /**
  10557. * Checks for the readiness of the element composing the layer.
  10558. * @param subMesh the mesh to check for
  10559. * @param useInstances specify wether or not to use instances to render the mesh
  10560. * @param emissiveTexture the associated emissive texture used to generate the glow
  10561. * @return true if ready otherwise, false
  10562. */
  10563. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  10564. /**
  10565. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  10566. */
  10567. needStencil(): boolean;
  10568. /**
  10569. * Implementation specific of rendering the generating effect on the main canvas.
  10570. * @param effect The effect used to render through
  10571. */
  10572. protected _internalRender(effect: Effect): void;
  10573. /**
  10574. * Sets the required values for both the emissive texture and and the main color.
  10575. */
  10576. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  10577. /**
  10578. * Returns true if the mesh should render, otherwise false.
  10579. * @param mesh The mesh to render
  10580. * @returns true if it should render otherwise false
  10581. */
  10582. protected _shouldRenderMesh(mesh: Mesh): boolean;
  10583. /**
  10584. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  10585. * @param mesh The mesh to exclude from the glow layer
  10586. */
  10587. addExcludedMesh(mesh: Mesh): void;
  10588. /**
  10589. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  10590. * @param mesh The mesh to remove
  10591. */
  10592. removeExcludedMesh(mesh: Mesh): void;
  10593. /**
  10594. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  10595. * @param mesh The mesh to include in the glow layer
  10596. */
  10597. addIncludedOnlyMesh(mesh: Mesh): void;
  10598. /**
  10599. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  10600. * @param mesh The mesh to remove
  10601. */
  10602. removeIncludedOnlyMesh(mesh: Mesh): void;
  10603. /**
  10604. * Determine if a given mesh will be used in the glow layer
  10605. * @param mesh The mesh to test
  10606. * @returns true if the mesh will be highlighted by the current glow layer
  10607. */
  10608. hasMesh(mesh: AbstractMesh): boolean;
  10609. /**
  10610. * Free any resources and references associated to a mesh.
  10611. * Internal use
  10612. * @param mesh The mesh to free.
  10613. */
  10614. _disposeMesh(mesh: Mesh): void;
  10615. /**
  10616. * Gets the class name of the effect layer
  10617. * @returns the string with the class name of the effect layer
  10618. */
  10619. getClassName(): string;
  10620. /**
  10621. * Serializes this glow layer
  10622. * @returns a serialized glow layer object
  10623. */
  10624. serialize(): any;
  10625. /**
  10626. * Creates a Glow Layer from parsed glow layer data
  10627. * @param parsedGlowLayer defines glow layer data
  10628. * @param scene defines the current scene
  10629. * @param rootUrl defines the root URL containing the glow layer information
  10630. * @returns a parsed Glow Layer
  10631. */
  10632. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  10633. }
  10634. }
  10635. declare module BABYLON {
  10636. /**
  10637. * Highlight layer options. This helps customizing the behaviour
  10638. * of the highlight layer.
  10639. */
  10640. interface IHighlightLayerOptions {
  10641. /**
  10642. * Multiplication factor apply to the canvas size to compute the render target size
  10643. * used to generated the glowing objects (the smaller the faster).
  10644. */
  10645. mainTextureRatio: number;
  10646. /**
  10647. * Enforces a fixed size texture to ensure resize independant blur.
  10648. */
  10649. mainTextureFixedSize?: number;
  10650. /**
  10651. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  10652. * of the picture to blur (the smaller the faster).
  10653. */
  10654. blurTextureSizeRatio: number;
  10655. /**
  10656. * How big in texel of the blur texture is the vertical blur.
  10657. */
  10658. blurVerticalSize: number;
  10659. /**
  10660. * How big in texel of the blur texture is the horizontal blur.
  10661. */
  10662. blurHorizontalSize: number;
  10663. /**
  10664. * Alpha blending mode used to apply the blur. Default is combine.
  10665. */
  10666. alphaBlendingMode: number;
  10667. /**
  10668. * The camera attached to the layer.
  10669. */
  10670. camera: Nullable<Camera>;
  10671. /**
  10672. * Should we display highlight as a solid stroke?
  10673. */
  10674. isStroke?: boolean;
  10675. }
  10676. /**
  10677. * The highlight layer Helps adding a glow effect around a mesh.
  10678. *
  10679. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  10680. * glowy meshes to your scene.
  10681. *
  10682. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  10683. */
  10684. class HighlightLayer extends EffectLayer {
  10685. name: string;
  10686. /**
  10687. * Effect Name of the highlight layer.
  10688. */
  10689. static readonly EffectName: string;
  10690. /**
  10691. * The neutral color used during the preparation of the glow effect.
  10692. * This is black by default as the blend operation is a blend operation.
  10693. */
  10694. static NeutralColor: Color4;
  10695. /**
  10696. * Stencil value used for glowing meshes.
  10697. */
  10698. static GlowingMeshStencilReference: number;
  10699. /**
  10700. * Stencil value used for the other meshes in the scene.
  10701. */
  10702. static NormalMeshStencilReference: number;
  10703. /**
  10704. * Specifies whether or not the inner glow is ACTIVE in the layer.
  10705. */
  10706. innerGlow: boolean;
  10707. /**
  10708. * Specifies whether or not the outer glow is ACTIVE in the layer.
  10709. */
  10710. outerGlow: boolean;
  10711. /**
  10712. * Gets the horizontal size of the blur.
  10713. */
  10714. /**
  10715. * Specifies the horizontal size of the blur.
  10716. */
  10717. blurHorizontalSize: number;
  10718. /**
  10719. * Gets the vertical size of the blur.
  10720. */
  10721. /**
  10722. * Specifies the vertical size of the blur.
  10723. */
  10724. blurVerticalSize: number;
  10725. /**
  10726. * An event triggered when the highlight layer is being blurred.
  10727. */
  10728. onBeforeBlurObservable: Observable<HighlightLayer>;
  10729. /**
  10730. * An event triggered when the highlight layer has been blurred.
  10731. */
  10732. onAfterBlurObservable: Observable<HighlightLayer>;
  10733. private _instanceGlowingMeshStencilReference;
  10734. private _options;
  10735. private _downSamplePostprocess;
  10736. private _horizontalBlurPostprocess;
  10737. private _verticalBlurPostprocess;
  10738. private _blurTexture;
  10739. private _meshes;
  10740. private _excludedMeshes;
  10741. /**
  10742. * Instantiates a new highlight Layer and references it to the scene..
  10743. * @param name The name of the layer
  10744. * @param scene The scene to use the layer in
  10745. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  10746. */
  10747. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  10748. /**
  10749. * Get the effect name of the layer.
  10750. * @return The effect name
  10751. */
  10752. getEffectName(): string;
  10753. /**
  10754. * Create the merge effect. This is the shader use to blit the information back
  10755. * to the main canvas at the end of the scene rendering.
  10756. */
  10757. protected _createMergeEffect(): Effect;
  10758. /**
  10759. * Creates the render target textures and post processes used in the highlight layer.
  10760. */
  10761. protected _createTextureAndPostProcesses(): void;
  10762. /**
  10763. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  10764. */
  10765. needStencil(): boolean;
  10766. /**
  10767. * Checks for the readiness of the element composing the layer.
  10768. * @param subMesh the mesh to check for
  10769. * @param useInstances specify wether or not to use instances to render the mesh
  10770. * @param emissiveTexture the associated emissive texture used to generate the glow
  10771. * @return true if ready otherwise, false
  10772. */
  10773. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  10774. /**
  10775. * Implementation specific of rendering the generating effect on the main canvas.
  10776. * @param effect The effect used to render through
  10777. */
  10778. protected _internalRender(effect: Effect): void;
  10779. /**
  10780. * Returns true if the layer contains information to display, otherwise false.
  10781. */
  10782. shouldRender(): boolean;
  10783. /**
  10784. * Returns true if the mesh should render, otherwise false.
  10785. * @param mesh The mesh to render
  10786. * @returns true if it should render otherwise false
  10787. */
  10788. protected _shouldRenderMesh(mesh: Mesh): boolean;
  10789. /**
  10790. * Sets the required values for both the emissive texture and and the main color.
  10791. */
  10792. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  10793. /**
  10794. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  10795. * @param mesh The mesh to exclude from the highlight layer
  10796. */
  10797. addExcludedMesh(mesh: Mesh): void;
  10798. /**
  10799. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  10800. * @param mesh The mesh to highlight
  10801. */
  10802. removeExcludedMesh(mesh: Mesh): void;
  10803. /**
  10804. * Determine if a given mesh will be highlighted by the current HighlightLayer
  10805. * @param mesh mesh to test
  10806. * @returns true if the mesh will be highlighted by the current HighlightLayer
  10807. */
  10808. hasMesh(mesh: AbstractMesh): boolean;
  10809. /**
  10810. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  10811. * @param mesh The mesh to highlight
  10812. * @param color The color of the highlight
  10813. * @param glowEmissiveOnly Extract the glow from the emissive texture
  10814. */
  10815. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  10816. /**
  10817. * Remove a mesh from the highlight layer in order to make it stop glowing.
  10818. * @param mesh The mesh to highlight
  10819. */
  10820. removeMesh(mesh: Mesh): void;
  10821. /**
  10822. * Force the stencil to the normal expected value for none glowing parts
  10823. */
  10824. private _defaultStencilReference(mesh);
  10825. /**
  10826. * Free any resources and references associated to a mesh.
  10827. * Internal use
  10828. * @param mesh The mesh to free.
  10829. */
  10830. _disposeMesh(mesh: Mesh): void;
  10831. /**
  10832. * Dispose the highlight layer and free resources.
  10833. */
  10834. dispose(): void;
  10835. /**
  10836. * Gets the class name of the effect layer
  10837. * @returns the string with the class name of the effect layer
  10838. */
  10839. getClassName(): string;
  10840. /**
  10841. * Serializes this Highlight layer
  10842. * @returns a serialized Highlight layer object
  10843. */
  10844. serialize(): any;
  10845. /**
  10846. * Creates a Highlight layer from parsed Highlight layer data
  10847. * @param parsedHightlightLayer defines the Highlight layer data
  10848. * @param scene defines the current scene
  10849. * @param rootUrl defines the root URL containing the Highlight layer information
  10850. * @returns a parsed Highlight layer
  10851. */
  10852. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  10853. }
  10854. }
  10855. declare module BABYLON {
  10856. class Layer {
  10857. name: string;
  10858. texture: Nullable<Texture>;
  10859. isBackground: boolean;
  10860. color: Color4;
  10861. scale: Vector2;
  10862. offset: Vector2;
  10863. alphaBlendingMode: number;
  10864. alphaTest: boolean;
  10865. layerMask: number;
  10866. private _scene;
  10867. private _vertexBuffers;
  10868. private _indexBuffer;
  10869. private _effect;
  10870. private _alphaTestEffect;
  10871. /**
  10872. * An event triggered when the layer is disposed.
  10873. */
  10874. onDisposeObservable: Observable<Layer>;
  10875. private _onDisposeObserver;
  10876. onDispose: () => void;
  10877. /**
  10878. * An event triggered before rendering the scene
  10879. */
  10880. onBeforeRenderObservable: Observable<Layer>;
  10881. private _onBeforeRenderObserver;
  10882. onBeforeRender: () => void;
  10883. /**
  10884. * An event triggered after rendering the scene
  10885. */
  10886. onAfterRenderObservable: Observable<Layer>;
  10887. private _onAfterRenderObserver;
  10888. onAfterRender: () => void;
  10889. constructor(name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  10890. private _createIndexBuffer();
  10891. _rebuild(): void;
  10892. render(): void;
  10893. dispose(): void;
  10894. }
  10895. }
  10896. declare module BABYLON {
  10897. class LensFlare {
  10898. size: number;
  10899. position: number;
  10900. color: Color3;
  10901. texture: Nullable<Texture>;
  10902. alphaMode: number;
  10903. private _system;
  10904. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  10905. constructor(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  10906. dispose(): void;
  10907. }
  10908. }
  10909. declare module BABYLON {
  10910. class LensFlareSystem {
  10911. name: string;
  10912. lensFlares: LensFlare[];
  10913. borderLimit: number;
  10914. viewportBorder: number;
  10915. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  10916. layerMask: number;
  10917. id: string;
  10918. private _scene;
  10919. private _emitter;
  10920. private _vertexBuffers;
  10921. private _indexBuffer;
  10922. private _effect;
  10923. private _positionX;
  10924. private _positionY;
  10925. private _isEnabled;
  10926. constructor(name: string, emitter: any, scene: Scene);
  10927. isEnabled: boolean;
  10928. getScene(): Scene;
  10929. getEmitter(): any;
  10930. setEmitter(newEmitter: any): void;
  10931. getEmitterPosition(): Vector3;
  10932. computeEffectivePosition(globalViewport: Viewport): boolean;
  10933. _isVisible(): boolean;
  10934. render(): boolean;
  10935. dispose(): void;
  10936. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  10937. serialize(): any;
  10938. }
  10939. }
  10940. declare module BABYLON {
  10941. /**
  10942. * A directional light is defined by a direction (what a surprise!).
  10943. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  10944. * 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.
  10945. * Documentation: https://doc.babylonjs.com/babylon101/lights
  10946. */
  10947. class DirectionalLight extends ShadowLight {
  10948. private _shadowFrustumSize;
  10949. /**
  10950. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  10951. */
  10952. /**
  10953. * Specifies a fix frustum size for the shadow generation.
  10954. */
  10955. shadowFrustumSize: number;
  10956. private _shadowOrthoScale;
  10957. /**
  10958. * Gets the shadow projection scale against the optimal computed one.
  10959. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  10960. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  10961. */
  10962. /**
  10963. * Sets the shadow projection scale against the optimal computed one.
  10964. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  10965. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  10966. */
  10967. shadowOrthoScale: number;
  10968. /**
  10969. * Automatically compute the projection matrix to best fit (including all the casters)
  10970. * on each frame.
  10971. */
  10972. autoUpdateExtends: boolean;
  10973. private _orthoLeft;
  10974. private _orthoRight;
  10975. private _orthoTop;
  10976. private _orthoBottom;
  10977. /**
  10978. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  10979. * The directional light is emitted from everywhere in the given direction.
  10980. * It can cast shawdows.
  10981. * Documentation : http://doc.babylonjs.com/tutorials/lights
  10982. * @param name The friendly name of the light
  10983. * @param direction The direction of the light
  10984. * @param scene The scene the light belongs to
  10985. */
  10986. constructor(name: string, direction: Vector3, scene: Scene);
  10987. /**
  10988. * Returns the string "DirectionalLight".
  10989. * @return The class name
  10990. */
  10991. getClassName(): string;
  10992. /**
  10993. * Returns the integer 1.
  10994. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  10995. */
  10996. getTypeID(): number;
  10997. /**
  10998. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  10999. * Returns the DirectionalLight Shadow projection matrix.
  11000. */
  11001. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  11002. /**
  11003. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  11004. * Returns the DirectionalLight Shadow projection matrix.
  11005. */
  11006. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix): void;
  11007. /**
  11008. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  11009. * Returns the DirectionalLight Shadow projection matrix.
  11010. */
  11011. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  11012. protected _buildUniformLayout(): void;
  11013. /**
  11014. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  11015. * @param effect The effect to update
  11016. * @param lightIndex The index of the light in the effect to update
  11017. * @returns The directional light
  11018. */
  11019. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  11020. /**
  11021. * Gets the minZ used for shadow according to both the scene and the light.
  11022. *
  11023. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  11024. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  11025. * @param activeCamera The camera we are returning the min for
  11026. * @returns the depth min z
  11027. */
  11028. getDepthMinZ(activeCamera: Camera): number;
  11029. /**
  11030. * Gets the maxZ used for shadow according to both the scene and the light.
  11031. *
  11032. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  11033. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  11034. * @param activeCamera The camera we are returning the max for
  11035. * @returns the depth max z
  11036. */
  11037. getDepthMaxZ(activeCamera: Camera): number;
  11038. }
  11039. }
  11040. declare module BABYLON {
  11041. /**
  11042. * The HemisphericLight simulates the ambient environment light,
  11043. * so the passed direction is the light reflection direction, not the incoming direction.
  11044. */
  11045. class HemisphericLight extends Light {
  11046. /**
  11047. * The groundColor is the light in the opposite direction to the one specified during creation.
  11048. * 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.
  11049. */
  11050. groundColor: Color3;
  11051. /**
  11052. * The light reflection direction, not the incoming direction.
  11053. */
  11054. direction: Vector3;
  11055. private _worldMatrix;
  11056. /**
  11057. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  11058. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  11059. * The HemisphericLight can't cast shadows.
  11060. * Documentation : http://doc.babylonjs.com/tutorials/lights
  11061. * @param name The friendly name of the light
  11062. * @param direction The direction of the light reflection
  11063. * @param scene The scene the light belongs to
  11064. */
  11065. constructor(name: string, direction: Vector3, scene: Scene);
  11066. protected _buildUniformLayout(): void;
  11067. /**
  11068. * Returns the string "HemisphericLight".
  11069. * @return The class name
  11070. */
  11071. getClassName(): string;
  11072. /**
  11073. * Sets the HemisphericLight direction towards the passed target (Vector3).
  11074. * Returns the updated direction.
  11075. * @param target The target the direction should point to
  11076. * @return The computed direction
  11077. */
  11078. setDirectionToTarget(target: Vector3): Vector3;
  11079. /**
  11080. * Returns the shadow generator associated to the light.
  11081. * @returns Always null for hemispheric lights because it does not support shadows.
  11082. */
  11083. getShadowGenerator(): Nullable<ShadowGenerator>;
  11084. /**
  11085. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  11086. * @param effect The effect to update
  11087. * @param lightIndex The index of the light in the effect to update
  11088. * @returns The hemispheric light
  11089. */
  11090. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  11091. /**
  11092. * @hidden internal use only.
  11093. */
  11094. _getWorldMatrix(): Matrix;
  11095. /**
  11096. * Returns the integer 3.
  11097. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  11098. */
  11099. getTypeID(): number;
  11100. }
  11101. }
  11102. declare module BABYLON {
  11103. /**
  11104. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  11105. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  11106. * 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.
  11107. */
  11108. abstract class Light extends Node {
  11109. private static _LIGHTMAP_DEFAULT;
  11110. private static _LIGHTMAP_SPECULAR;
  11111. private static _LIGHTMAP_SHADOWSONLY;
  11112. /**
  11113. * If every light affecting the material is in this lightmapMode,
  11114. * material.lightmapTexture adds or multiplies
  11115. * (depends on material.useLightmapAsShadowmap)
  11116. * after every other light calculations.
  11117. */
  11118. static readonly LIGHTMAP_DEFAULT: number;
  11119. /**
  11120. * material.lightmapTexture as only diffuse lighting from this light
  11121. * adds only specular lighting from this light
  11122. * adds dynamic shadows
  11123. */
  11124. static readonly LIGHTMAP_SPECULAR: number;
  11125. /**
  11126. * material.lightmapTexture as only lighting
  11127. * no light calculation from this light
  11128. * only adds dynamic shadows from this light
  11129. */
  11130. static readonly LIGHTMAP_SHADOWSONLY: number;
  11131. private static _INTENSITYMODE_AUTOMATIC;
  11132. private static _INTENSITYMODE_LUMINOUSPOWER;
  11133. private static _INTENSITYMODE_LUMINOUSINTENSITY;
  11134. private static _INTENSITYMODE_ILLUMINANCE;
  11135. private static _INTENSITYMODE_LUMINANCE;
  11136. /**
  11137. * Each light type uses the default quantity according to its type:
  11138. * point/spot lights use luminous intensity
  11139. * directional lights use illuminance
  11140. */
  11141. static readonly INTENSITYMODE_AUTOMATIC: number;
  11142. /**
  11143. * lumen (lm)
  11144. */
  11145. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  11146. /**
  11147. * candela (lm/sr)
  11148. */
  11149. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  11150. /**
  11151. * lux (lm/m^2)
  11152. */
  11153. static readonly INTENSITYMODE_ILLUMINANCE: number;
  11154. /**
  11155. * nit (cd/m^2)
  11156. */
  11157. static readonly INTENSITYMODE_LUMINANCE: number;
  11158. private static _LIGHTTYPEID_POINTLIGHT;
  11159. private static _LIGHTTYPEID_DIRECTIONALLIGHT;
  11160. private static _LIGHTTYPEID_SPOTLIGHT;
  11161. private static _LIGHTTYPEID_HEMISPHERICLIGHT;
  11162. /**
  11163. * Light type const id of the point light.
  11164. */
  11165. static readonly LIGHTTYPEID_POINTLIGHT: number;
  11166. /**
  11167. * Light type const id of the directional light.
  11168. */
  11169. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  11170. /**
  11171. * Light type const id of the spot light.
  11172. */
  11173. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  11174. /**
  11175. * Light type const id of the hemispheric light.
  11176. */
  11177. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  11178. /**
  11179. * Diffuse gives the basic color to an object.
  11180. */
  11181. diffuse: Color3;
  11182. /**
  11183. * Specular produces a highlight color on an object.
  11184. * Note: This is note affecting PBR materials.
  11185. */
  11186. specular: Color3;
  11187. /**
  11188. * Strength of the light.
  11189. * Note: By default it is define in the framework own unit.
  11190. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  11191. */
  11192. intensity: number;
  11193. /**
  11194. * Defines how far from the source the light is impacting in scene units.
  11195. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  11196. */
  11197. range: number;
  11198. /**
  11199. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  11200. * of light.
  11201. */
  11202. private _photometricScale;
  11203. private _intensityMode;
  11204. /**
  11205. * Gets the photometric scale used to interpret the intensity.
  11206. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  11207. */
  11208. /**
  11209. * Sets the photometric scale used to interpret the intensity.
  11210. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  11211. */
  11212. intensityMode: number;
  11213. private _radius;
  11214. /**
  11215. * Gets the light radius used by PBR Materials to simulate soft area lights.
  11216. */
  11217. /**
  11218. * sets the light radius used by PBR Materials to simulate soft area lights.
  11219. */
  11220. radius: number;
  11221. private _renderPriority;
  11222. /**
  11223. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  11224. * exceeding the number allowed of the materials.
  11225. */
  11226. renderPriority: number;
  11227. private _shadowEnabled;
  11228. /**
  11229. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  11230. * the current shadow generator.
  11231. */
  11232. /**
  11233. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  11234. * the current shadow generator.
  11235. */
  11236. shadowEnabled: boolean;
  11237. private _includedOnlyMeshes;
  11238. /**
  11239. * Gets the only meshes impacted by this light.
  11240. */
  11241. /**
  11242. * Sets the only meshes impacted by this light.
  11243. */
  11244. includedOnlyMeshes: AbstractMesh[];
  11245. private _excludedMeshes;
  11246. /**
  11247. * Gets the meshes not impacted by this light.
  11248. */
  11249. /**
  11250. * Sets the meshes not impacted by this light.
  11251. */
  11252. excludedMeshes: AbstractMesh[];
  11253. private _excludeWithLayerMask;
  11254. /**
  11255. * Gets the layer id use to find what meshes are not impacted by the light.
  11256. * Inactive if 0
  11257. */
  11258. /**
  11259. * Sets the layer id use to find what meshes are not impacted by the light.
  11260. * Inactive if 0
  11261. */
  11262. excludeWithLayerMask: number;
  11263. private _includeOnlyWithLayerMask;
  11264. /**
  11265. * Gets the layer id use to find what meshes are impacted by the light.
  11266. * Inactive if 0
  11267. */
  11268. /**
  11269. * Sets the layer id use to find what meshes are impacted by the light.
  11270. * Inactive if 0
  11271. */
  11272. includeOnlyWithLayerMask: number;
  11273. private _lightmapMode;
  11274. /**
  11275. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  11276. */
  11277. /**
  11278. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  11279. */
  11280. lightmapMode: number;
  11281. private _parentedWorldMatrix;
  11282. /**
  11283. * Shadow generator associted to the light.
  11284. * Internal use only.
  11285. */
  11286. _shadowGenerator: Nullable<IShadowGenerator>;
  11287. /**
  11288. * @hidden Internal use only.
  11289. */
  11290. _excludedMeshesIds: string[];
  11291. /**
  11292. * @hidden Internal use only.
  11293. */
  11294. _includedOnlyMeshesIds: string[];
  11295. /**
  11296. * The current light unifom buffer.
  11297. * @hidden Internal use only.
  11298. */
  11299. _uniformBuffer: UniformBuffer;
  11300. /**
  11301. * Creates a Light object in the scene.
  11302. * Documentation : http://doc.babylonjs.com/tutorials/lights
  11303. * @param name The firendly name of the light
  11304. * @param scene The scene the light belongs too
  11305. */
  11306. constructor(name: string, scene: Scene);
  11307. protected abstract _buildUniformLayout(): void;
  11308. /**
  11309. * Sets the passed Effect "effect" with the Light information.
  11310. * @param effect The effect to update
  11311. * @param lightIndex The index of the light in the effect to update
  11312. * @returns The light
  11313. */
  11314. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  11315. /**
  11316. * @hidden internal use only.
  11317. */
  11318. abstract _getWorldMatrix(): Matrix;
  11319. /**
  11320. * Returns the string "Light".
  11321. * @returns the class name
  11322. */
  11323. getClassName(): string;
  11324. /**
  11325. * Converts the light information to a readable string for debug purpose.
  11326. * @param fullDetails Supports for multiple levels of logging within scene loading
  11327. * @returns the human readable light info
  11328. */
  11329. toString(fullDetails?: boolean): string;
  11330. /**
  11331. * Set the enabled state of this node.
  11332. * @param value - the new enabled state
  11333. */
  11334. setEnabled(value: boolean): void;
  11335. /**
  11336. * Returns the Light associated shadow generator if any.
  11337. * @return the associated shadow generator.
  11338. */
  11339. getShadowGenerator(): Nullable<IShadowGenerator>;
  11340. /**
  11341. * Returns a Vector3, the absolute light position in the World.
  11342. * @returns the world space position of the light
  11343. */
  11344. getAbsolutePosition(): Vector3;
  11345. /**
  11346. * Specifies if the light will affect the passed mesh.
  11347. * @param mesh The mesh to test against the light
  11348. * @return true the mesh is affected otherwise, false.
  11349. */
  11350. canAffectMesh(mesh: AbstractMesh): boolean;
  11351. /**
  11352. * Computes and Returns the light World matrix.
  11353. * @returns the world matrix
  11354. */
  11355. getWorldMatrix(): Matrix;
  11356. /**
  11357. * Sort function to order lights for rendering.
  11358. * @param a First Light object to compare to second.
  11359. * @param b Second Light object to compare first.
  11360. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  11361. */
  11362. static CompareLightsPriority(a: Light, b: Light): number;
  11363. /**
  11364. * Releases resources associated with this node.
  11365. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  11366. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  11367. */
  11368. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  11369. /**
  11370. * Returns the light type ID (integer).
  11371. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  11372. */
  11373. getTypeID(): number;
  11374. /**
  11375. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  11376. * @returns the scaled intensity in intensity mode unit
  11377. */
  11378. getScaledIntensity(): number;
  11379. /**
  11380. * Returns a new Light object, named "name", from the current one.
  11381. * @param name The name of the cloned light
  11382. * @returns the new created light
  11383. */
  11384. clone(name: string): Nullable<Light>;
  11385. /**
  11386. * Serializes the current light into a Serialization object.
  11387. * @returns the serialized object.
  11388. */
  11389. serialize(): any;
  11390. /**
  11391. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  11392. * This new light is named "name" and added to the passed scene.
  11393. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  11394. * @param name The friendly name of the light
  11395. * @param scene The scene the new light will belong to
  11396. * @returns the constructor function
  11397. */
  11398. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  11399. /**
  11400. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  11401. * @param parsedLight The JSON representation of the light
  11402. * @param scene The scene to create the parsed light in
  11403. * @returns the created light after parsing
  11404. */
  11405. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  11406. private _hookArrayForExcluded(array);
  11407. private _hookArrayForIncludedOnly(array);
  11408. private _resyncMeshes();
  11409. /**
  11410. * Forces the meshes to update their light related information in their rendering used effects
  11411. * @hidden Internal Use Only
  11412. */
  11413. _markMeshesAsLightDirty(): void;
  11414. /**
  11415. * Recomputes the cached photometric scale if needed.
  11416. */
  11417. private _computePhotometricScale();
  11418. /**
  11419. * Returns the Photometric Scale according to the light type and intensity mode.
  11420. */
  11421. private _getPhotometricScale();
  11422. /**
  11423. * Reorder the light in the scene according to their defined priority.
  11424. * @hidden Internal Use Only
  11425. */
  11426. _reorderLightsInScene(): void;
  11427. }
  11428. }
  11429. declare module BABYLON {
  11430. /**
  11431. * A point light is a light defined by an unique point in world space.
  11432. * The light is emitted in every direction from this point.
  11433. * A good example of a point light is a standard light bulb.
  11434. * Documentation: https://doc.babylonjs.com/babylon101/lights
  11435. */
  11436. class PointLight extends ShadowLight {
  11437. private _shadowAngle;
  11438. /**
  11439. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  11440. * This specifies what angle the shadow will use to be created.
  11441. *
  11442. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  11443. */
  11444. /**
  11445. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  11446. * This specifies what angle the shadow will use to be created.
  11447. *
  11448. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  11449. */
  11450. shadowAngle: number;
  11451. /**
  11452. * Gets the direction if it has been set.
  11453. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  11454. */
  11455. /**
  11456. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  11457. */
  11458. direction: Vector3;
  11459. /**
  11460. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  11461. * A PointLight emits the light in every direction.
  11462. * It can cast shadows.
  11463. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  11464. * ```javascript
  11465. * var pointLight = new BABYLON.PointLight("pl", camera.position, scene);
  11466. * ```
  11467. * Documentation : http://doc.babylonjs.com/tutorials/lights
  11468. * @param name The light friendly name
  11469. * @param position The position of the point light in the scene
  11470. * @param scene The scene the lights belongs to
  11471. */
  11472. constructor(name: string, position: Vector3, scene: Scene);
  11473. /**
  11474. * Returns the string "PointLight"
  11475. * @returns the class name
  11476. */
  11477. getClassName(): string;
  11478. /**
  11479. * Returns the integer 0.
  11480. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  11481. */
  11482. getTypeID(): number;
  11483. /**
  11484. * Specifies wether or not the shadowmap should be a cube texture.
  11485. * @returns true if the shadowmap needs to be a cube texture.
  11486. */
  11487. needCube(): boolean;
  11488. /**
  11489. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  11490. * @param faceIndex The index of the face we are computed the direction to generate shadow
  11491. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  11492. */
  11493. getShadowDirection(faceIndex?: number): Vector3;
  11494. /**
  11495. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  11496. * - fov = PI / 2
  11497. * - aspect ratio : 1.0
  11498. * - z-near and far equal to the active camera minZ and maxZ.
  11499. * Returns the PointLight.
  11500. */
  11501. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  11502. protected _buildUniformLayout(): void;
  11503. /**
  11504. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  11505. * @param effect The effect to update
  11506. * @param lightIndex The index of the light in the effect to update
  11507. * @returns The point light
  11508. */
  11509. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  11510. }
  11511. }
  11512. declare module BABYLON {
  11513. /**
  11514. * Interface describing all the common properties and methods a shadow light needs to implement.
  11515. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  11516. * as well as binding the different shadow properties to the effects.
  11517. */
  11518. interface IShadowLight extends Light {
  11519. /**
  11520. * The light id in the scene (used in scene.findLighById for instance)
  11521. */
  11522. id: string;
  11523. /**
  11524. * The position the shdow will be casted from.
  11525. */
  11526. position: Vector3;
  11527. /**
  11528. * In 2d mode (needCube being false), the direction used to cast the shadow.
  11529. */
  11530. direction: Vector3;
  11531. /**
  11532. * The transformed position. Position of the light in world space taking parenting in account.
  11533. */
  11534. transformedPosition: Vector3;
  11535. /**
  11536. * The transformed direction. Direction of the light in world space taking parenting in account.
  11537. */
  11538. transformedDirection: Vector3;
  11539. /**
  11540. * The friendly name of the light in the scene.
  11541. */
  11542. name: string;
  11543. /**
  11544. * Defines the shadow projection clipping minimum z value.
  11545. */
  11546. shadowMinZ: number;
  11547. /**
  11548. * Defines the shadow projection clipping maximum z value.
  11549. */
  11550. shadowMaxZ: number;
  11551. /**
  11552. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  11553. * @returns true if the information has been computed, false if it does not need to (no parenting)
  11554. */
  11555. computeTransformedInformation(): boolean;
  11556. /**
  11557. * Gets the scene the light belongs to.
  11558. * @returns The scene
  11559. */
  11560. getScene(): Scene;
  11561. /**
  11562. * Callback defining a custom Projection Matrix Builder.
  11563. * This can be used to override the default projection matrix computation.
  11564. */
  11565. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  11566. /**
  11567. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  11568. * @param matrix The materix to updated with the projection information
  11569. * @param viewMatrix The transform matrix of the light
  11570. * @param renderList The list of mesh to render in the map
  11571. * @returns The current light
  11572. */
  11573. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  11574. /**
  11575. * Gets the current depth scale used in ESM.
  11576. * @returns The scale
  11577. */
  11578. getDepthScale(): number;
  11579. /**
  11580. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  11581. * @returns true if a cube texture needs to be use
  11582. */
  11583. needCube(): boolean;
  11584. /**
  11585. * Detects if the projection matrix requires to be recomputed this frame.
  11586. * @returns true if it requires to be recomputed otherwise, false.
  11587. */
  11588. needProjectionMatrixCompute(): boolean;
  11589. /**
  11590. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  11591. */
  11592. forceProjectionMatrixCompute(): void;
  11593. /**
  11594. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  11595. * @param faceIndex The index of the face we are computed the direction to generate shadow
  11596. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  11597. */
  11598. getShadowDirection(faceIndex?: number): Vector3;
  11599. /**
  11600. * Gets the minZ used for shadow according to both the scene and the light.
  11601. * @param activeCamera The camera we are returning the min for
  11602. * @returns the depth min z
  11603. */
  11604. getDepthMinZ(activeCamera: Camera): number;
  11605. /**
  11606. * Gets the maxZ used for shadow according to both the scene and the light.
  11607. * @param activeCamera The camera we are returning the max for
  11608. * @returns the depth max z
  11609. */
  11610. getDepthMaxZ(activeCamera: Camera): number;
  11611. }
  11612. /**
  11613. * Base implementation IShadowLight
  11614. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  11615. */
  11616. abstract class ShadowLight extends Light implements IShadowLight {
  11617. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  11618. protected _position: Vector3;
  11619. protected _setPosition(value: Vector3): void;
  11620. /**
  11621. * Sets the position the shadow will be casted from. Also use as the light position for both
  11622. * point and spot lights.
  11623. */
  11624. /**
  11625. * Sets the position the shadow will be casted from. Also use as the light position for both
  11626. * point and spot lights.
  11627. */
  11628. position: Vector3;
  11629. protected _direction: Vector3;
  11630. protected _setDirection(value: Vector3): void;
  11631. /**
  11632. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  11633. * Also use as the light direction on spot and directional lights.
  11634. */
  11635. /**
  11636. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  11637. * Also use as the light direction on spot and directional lights.
  11638. */
  11639. direction: Vector3;
  11640. private _shadowMinZ;
  11641. /**
  11642. * Gets the shadow projection clipping minimum z value.
  11643. */
  11644. /**
  11645. * Sets the shadow projection clipping minimum z value.
  11646. */
  11647. shadowMinZ: number;
  11648. private _shadowMaxZ;
  11649. /**
  11650. * Sets the shadow projection clipping maximum z value.
  11651. */
  11652. /**
  11653. * Gets the shadow projection clipping maximum z value.
  11654. */
  11655. shadowMaxZ: number;
  11656. /**
  11657. * Callback defining a custom Projection Matrix Builder.
  11658. * This can be used to override the default projection matrix computation.
  11659. */
  11660. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  11661. /**
  11662. * The transformed position. Position of the light in world space taking parenting in account.
  11663. */
  11664. transformedPosition: Vector3;
  11665. /**
  11666. * The transformed direction. Direction of the light in world space taking parenting in account.
  11667. */
  11668. transformedDirection: Vector3;
  11669. private _worldMatrix;
  11670. private _needProjectionMatrixCompute;
  11671. /**
  11672. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  11673. * @returns true if the information has been computed, false if it does not need to (no parenting)
  11674. */
  11675. computeTransformedInformation(): boolean;
  11676. /**
  11677. * Return the depth scale used for the shadow map.
  11678. * @returns the depth scale.
  11679. */
  11680. getDepthScale(): number;
  11681. /**
  11682. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  11683. * @param faceIndex The index of the face we are computed the direction to generate shadow
  11684. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  11685. */
  11686. getShadowDirection(faceIndex?: number): Vector3;
  11687. /**
  11688. * Returns the ShadowLight absolute position in the World.
  11689. * @returns the position vector in world space
  11690. */
  11691. getAbsolutePosition(): Vector3;
  11692. /**
  11693. * Sets the ShadowLight direction toward the passed target.
  11694. * @param target The point tot target in local space
  11695. * @returns the updated ShadowLight direction
  11696. */
  11697. setDirectionToTarget(target: Vector3): Vector3;
  11698. /**
  11699. * Returns the light rotation in euler definition.
  11700. * @returns the x y z rotation in local space.
  11701. */
  11702. getRotation(): Vector3;
  11703. /**
  11704. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  11705. * @returns true if a cube texture needs to be use
  11706. */
  11707. needCube(): boolean;
  11708. /**
  11709. * Detects if the projection matrix requires to be recomputed this frame.
  11710. * @returns true if it requires to be recomputed otherwise, false.
  11711. */
  11712. needProjectionMatrixCompute(): boolean;
  11713. /**
  11714. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  11715. */
  11716. forceProjectionMatrixCompute(): void;
  11717. /**
  11718. * Get the world matrix of the sahdow lights.
  11719. * @hidden Internal Use Only
  11720. */
  11721. _getWorldMatrix(): Matrix;
  11722. /**
  11723. * Gets the minZ used for shadow according to both the scene and the light.
  11724. * @param activeCamera The camera we are returning the min for
  11725. * @returns the depth min z
  11726. */
  11727. getDepthMinZ(activeCamera: Camera): number;
  11728. /**
  11729. * Gets the maxZ used for shadow according to both the scene and the light.
  11730. * @param activeCamera The camera we are returning the max for
  11731. * @returns the depth max z
  11732. */
  11733. getDepthMaxZ(activeCamera: Camera): number;
  11734. /**
  11735. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  11736. * @param matrix The materix to updated with the projection information
  11737. * @param viewMatrix The transform matrix of the light
  11738. * @param renderList The list of mesh to render in the map
  11739. * @returns The current light
  11740. */
  11741. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  11742. }
  11743. }
  11744. declare module BABYLON {
  11745. /**
  11746. * A spot light is defined by a position, a direction, an angle, and an exponent.
  11747. * These values define a cone of light starting from the position, emitting toward the direction.
  11748. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  11749. * and the exponent defines the speed of the decay of the light with distance (reach).
  11750. * Documentation: https://doc.babylonjs.com/babylon101/lights
  11751. */
  11752. class SpotLight extends ShadowLight {
  11753. private _angle;
  11754. /**
  11755. * Gets the cone angle of the spot light in Radians.
  11756. */
  11757. /**
  11758. * Sets the cone angle of the spot light in Radians.
  11759. */
  11760. angle: number;
  11761. private _shadowAngleScale;
  11762. /**
  11763. * Allows scaling the angle of the light for shadow generation only.
  11764. */
  11765. /**
  11766. * Allows scaling the angle of the light for shadow generation only.
  11767. */
  11768. shadowAngleScale: number;
  11769. /**
  11770. * The light decay speed with the distance from the emission spot.
  11771. */
  11772. exponent: number;
  11773. private _projectionTextureMatrix;
  11774. /**
  11775. * Allows reading the projecton texture
  11776. */
  11777. readonly projectionTextureMatrix: Matrix;
  11778. protected _projectionTextureLightNear: number;
  11779. /**
  11780. * Gets the near clip of the Spotlight for texture projection.
  11781. */
  11782. /**
  11783. * Sets the near clip of the Spotlight for texture projection.
  11784. */
  11785. projectionTextureLightNear: number;
  11786. protected _projectionTextureLightFar: number;
  11787. /**
  11788. * Gets the far clip of the Spotlight for texture projection.
  11789. */
  11790. /**
  11791. * Sets the far clip of the Spotlight for texture projection.
  11792. */
  11793. projectionTextureLightFar: number;
  11794. protected _projectionTextureUpDirection: Vector3;
  11795. /**
  11796. * Gets the Up vector of the Spotlight for texture projection.
  11797. */
  11798. /**
  11799. * Sets the Up vector of the Spotlight for texture projection.
  11800. */
  11801. projectionTextureUpDirection: Vector3;
  11802. private _projectionTexture;
  11803. /**
  11804. * Gets the projection texture of the light.
  11805. */
  11806. /**
  11807. * Sets the projection texture of the light.
  11808. */
  11809. projectionTexture: Nullable<BaseTexture>;
  11810. private _projectionTextureViewLightDirty;
  11811. private _projectionTextureProjectionLightDirty;
  11812. private _projectionTextureDirty;
  11813. private _projectionTextureViewTargetVector;
  11814. private _projectionTextureViewLightMatrix;
  11815. private _projectionTextureProjectionLightMatrix;
  11816. private _projectionTextureScalingMatrix;
  11817. /**
  11818. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  11819. * It can cast shadows.
  11820. * Documentation : http://doc.babylonjs.com/tutorials/lights
  11821. * @param name The light friendly name
  11822. * @param position The position of the spot light in the scene
  11823. * @param direction The direction of the light in the scene
  11824. * @param angle The cone angle of the light in Radians
  11825. * @param exponent The light decay speed with the distance from the emission spot
  11826. * @param scene The scene the lights belongs to
  11827. */
  11828. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  11829. /**
  11830. * Returns the string "SpotLight".
  11831. * @returns the class name
  11832. */
  11833. getClassName(): string;
  11834. /**
  11835. * Returns the integer 2.
  11836. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  11837. */
  11838. getTypeID(): number;
  11839. /**
  11840. * Overrides the direction setter to recompute the projection texture view light Matrix.
  11841. */
  11842. protected _setDirection(value: Vector3): void;
  11843. /**
  11844. * Overrides the position setter to recompute the projection texture view light Matrix.
  11845. */
  11846. protected _setPosition(value: Vector3): void;
  11847. /**
  11848. * 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.
  11849. * Returns the SpotLight.
  11850. */
  11851. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  11852. protected _computeProjectionTextureViewLightMatrix(): void;
  11853. protected _computeProjectionTextureProjectionLightMatrix(): void;
  11854. /**
  11855. * Main function for light texture projection matrix computing.
  11856. */
  11857. protected _computeProjectionTextureMatrix(): void;
  11858. protected _buildUniformLayout(): void;
  11859. /**
  11860. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  11861. * @param effect The effect to update
  11862. * @param lightIndex The index of the light in the effect to update
  11863. * @returns The spot light
  11864. */
  11865. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  11866. /**
  11867. * Disposes the light and the associated resources.
  11868. */
  11869. dispose(): void;
  11870. }
  11871. }
  11872. declare module BABYLON {
  11873. interface ILoadingScreen {
  11874. displayLoadingUI: () => void;
  11875. hideLoadingUI: () => void;
  11876. loadingUIBackgroundColor: string;
  11877. loadingUIText: string;
  11878. }
  11879. class DefaultLoadingScreen implements ILoadingScreen {
  11880. private _renderingCanvas;
  11881. private _loadingText;
  11882. private _loadingDivBackgroundColor;
  11883. private _loadingDiv;
  11884. private _loadingTextDiv;
  11885. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  11886. displayLoadingUI(): void;
  11887. hideLoadingUI(): void;
  11888. loadingUIText: string;
  11889. loadingUIBackgroundColor: string;
  11890. private _resizeLoadingUI;
  11891. }
  11892. }
  11893. declare module BABYLON {
  11894. class SceneLoaderProgressEvent {
  11895. readonly lengthComputable: boolean;
  11896. readonly loaded: number;
  11897. readonly total: number;
  11898. constructor(lengthComputable: boolean, loaded: number, total: number);
  11899. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  11900. }
  11901. interface ISceneLoaderPluginExtensions {
  11902. [extension: string]: {
  11903. isBinary: boolean;
  11904. };
  11905. }
  11906. interface ISceneLoaderPluginFactory {
  11907. name: string;
  11908. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  11909. canDirectLoad?: (data: string) => boolean;
  11910. }
  11911. interface ISceneLoaderPlugin {
  11912. /**
  11913. * The friendly name of this plugin.
  11914. */
  11915. name: string;
  11916. /**
  11917. * The file extensions supported by this plugin.
  11918. */
  11919. extensions: string | ISceneLoaderPluginExtensions;
  11920. /**
  11921. * Import meshes into a scene.
  11922. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  11923. * @param scene The scene to import into
  11924. * @param data The data to import
  11925. * @param rootUrl The root url for scene and resources
  11926. * @param meshes The meshes array to import into
  11927. * @param particleSystems The particle systems array to import into
  11928. * @param skeletons The skeletons array to import into
  11929. * @param onError The callback when import fails
  11930. * @returns True if successful or false otherwise
  11931. */
  11932. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: ParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  11933. /**
  11934. * Load into a scene.
  11935. * @param scene The scene to load into
  11936. * @param data The data to import
  11937. * @param rootUrl The root url for scene and resources
  11938. * @param onError The callback when import fails
  11939. * @returns true if successful or false otherwise
  11940. */
  11941. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  11942. /**
  11943. * The callback that returns true if the data can be directly loaded.
  11944. */
  11945. canDirectLoad?: (data: string) => boolean;
  11946. /**
  11947. * The callback that allows custom handling of the root url based on the response url.
  11948. */
  11949. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  11950. /**
  11951. * Load into an asset container.
  11952. * @param scene The scene to load into
  11953. * @param data The data to import
  11954. * @param rootUrl The root url for scene and resources
  11955. * @param onError The callback when import fails
  11956. * @returns The loaded asset container
  11957. */
  11958. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  11959. }
  11960. interface ISceneLoaderPluginAsync {
  11961. /**
  11962. * The friendly name of this plugin.
  11963. */
  11964. name: string;
  11965. /**
  11966. * The file extensions supported by this plugin.
  11967. */
  11968. extensions: string | ISceneLoaderPluginExtensions;
  11969. /**
  11970. * Import meshes into a scene.
  11971. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  11972. * @param scene The scene to import into
  11973. * @param data The data to import
  11974. * @param rootUrl The root url for scene and resources
  11975. * @param onProgress The callback when the load progresses
  11976. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  11977. */
  11978. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<{
  11979. meshes: AbstractMesh[];
  11980. particleSystems: ParticleSystem[];
  11981. skeletons: Skeleton[];
  11982. animationGroups: AnimationGroup[];
  11983. }>;
  11984. /**
  11985. * Load into a scene.
  11986. * @param scene The scene to load into
  11987. * @param data The data to import
  11988. * @param rootUrl The root url for scene and resources
  11989. * @param onProgress The callback when the load progresses
  11990. * @returns Nothing
  11991. */
  11992. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<void>;
  11993. /**
  11994. * The callback that returns true if the data can be directly loaded.
  11995. */
  11996. canDirectLoad?: (data: string) => boolean;
  11997. /**
  11998. * The callback that allows custom handling of the root url based on the response url.
  11999. */
  12000. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  12001. /**
  12002. * Load into an asset container.
  12003. * @param scene The scene to load into
  12004. * @param data The data to import
  12005. * @param rootUrl The root url for scene and resources
  12006. * @param onProgress The callback when the load progresses
  12007. * @returns The loaded asset container
  12008. */
  12009. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<AssetContainer>;
  12010. }
  12011. class SceneLoader {
  12012. private static _ForceFullSceneLoadingForIncremental;
  12013. private static _ShowLoadingScreen;
  12014. private static _CleanBoneMatrixWeights;
  12015. static readonly NO_LOGGING: number;
  12016. static readonly MINIMAL_LOGGING: number;
  12017. static readonly SUMMARY_LOGGING: number;
  12018. static readonly DETAILED_LOGGING: number;
  12019. private static _loggingLevel;
  12020. static ForceFullSceneLoadingForIncremental: boolean;
  12021. static ShowLoadingScreen: boolean;
  12022. static loggingLevel: number;
  12023. static CleanBoneMatrixWeights: boolean;
  12024. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  12025. private static _registeredPlugins;
  12026. private static _getDefaultPlugin();
  12027. private static _getPluginForExtension(extension);
  12028. private static _getPluginForDirectLoad(data);
  12029. private static _getPluginForFilename(sceneFilename);
  12030. private static _getDirectLoad(sceneFilename);
  12031. private static _loadData(rootUrl, sceneFilename, scene, onSuccess, onProgress, onError, onDispose, pluginExtension);
  12032. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  12033. static IsPluginForExtensionAvailable(extension: string): boolean;
  12034. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  12035. /**
  12036. * Import meshes into a scene
  12037. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  12038. * @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)
  12039. * @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)
  12040. * @param scene the instance of BABYLON.Scene to append to
  12041. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  12042. * @param onProgress a callback with a progress event for each file being loaded
  12043. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  12044. * @param pluginExtension the extension used to determine the plugin
  12045. * @returns The loaded plugin
  12046. */
  12047. static ImportMesh(meshNames: any, rootUrl: string, sceneFilename?: any, scene?: Nullable<Scene>, onSuccess?: Nullable<(meshes: AbstractMesh[], particleSystems: ParticleSystem[], skeletons: Skeleton[], animationGroups: AnimationGroup[]) => void>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>, pluginExtension?: Nullable<string>): Nullable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  12048. /**
  12049. * Import meshes into a scene
  12050. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  12051. * @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)
  12052. * @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)
  12053. * @param scene the instance of BABYLON.Scene to append to
  12054. * @param onProgress a callback with a progress event for each file being loaded
  12055. * @param pluginExtension the extension used to determine the plugin
  12056. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  12057. */
  12058. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: any, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  12059. meshes: AbstractMesh[];
  12060. particleSystems: ParticleSystem[];
  12061. skeletons: Skeleton[];
  12062. animationGroups: AnimationGroup[];
  12063. }>;
  12064. /**
  12065. * Load a scene
  12066. * @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)
  12067. * @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)
  12068. * @param engine is the instance of BABYLON.Engine to use to create the scene
  12069. * @param onSuccess a callback with the scene when import succeeds
  12070. * @param onProgress a callback with a progress event for each file being loaded
  12071. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  12072. * @param pluginExtension the extension used to determine the plugin
  12073. * @returns The loaded plugin
  12074. */
  12075. 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>;
  12076. /**
  12077. * Load a scene
  12078. * @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)
  12079. * @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)
  12080. * @param engine is the instance of BABYLON.Engine to use to create the scene
  12081. * @param onProgress a callback with a progress event for each file being loaded
  12082. * @param pluginExtension the extension used to determine the plugin
  12083. * @returns The loaded scene
  12084. */
  12085. static LoadAsync(rootUrl: string, sceneFilename: any, engine: Engine, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  12086. /**
  12087. * Append a scene
  12088. * @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)
  12089. * @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)
  12090. * @param scene is the instance of BABYLON.Scene to append to
  12091. * @param onSuccess a callback with the scene when import succeeds
  12092. * @param onProgress a callback with a progress event for each file being loaded
  12093. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  12094. * @param pluginExtension the extension used to determine the plugin
  12095. * @returns The loaded plugin
  12096. */
  12097. 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>;
  12098. /**
  12099. * Append a scene
  12100. * @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)
  12101. * @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)
  12102. * @param scene is the instance of BABYLON.Scene to append to
  12103. * @param onProgress a callback with a progress event for each file being loaded
  12104. * @param pluginExtension the extension used to determine the plugin
  12105. * @returns The given scene
  12106. */
  12107. static AppendAsync(rootUrl: string, sceneFilename?: any, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  12108. /**
  12109. * Load a scene into an asset container
  12110. * @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)
  12111. * @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)
  12112. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  12113. * @param onSuccess a callback with the scene when import succeeds
  12114. * @param onProgress a callback with a progress event for each file being loaded
  12115. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  12116. * @param pluginExtension the extension used to determine the plugin
  12117. * @returns The loaded plugin
  12118. */
  12119. 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>;
  12120. /**
  12121. * Load a scene into an asset container
  12122. * @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)
  12123. * @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)
  12124. * @param scene is the instance of BABYLON.Scene to append to
  12125. * @param onProgress a callback with a progress event for each file being loaded
  12126. * @param pluginExtension the extension used to determine the plugin
  12127. * @returns The loaded asset container
  12128. */
  12129. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: any, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  12130. }
  12131. }
  12132. declare module BABYLON {
  12133. /**
  12134. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  12135. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  12136. * 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;
  12137. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  12138. */
  12139. class ColorCurves {
  12140. private _dirty;
  12141. private _tempColor;
  12142. private _globalCurve;
  12143. private _highlightsCurve;
  12144. private _midtonesCurve;
  12145. private _shadowsCurve;
  12146. private _positiveCurve;
  12147. private _negativeCurve;
  12148. private _globalHue;
  12149. private _globalDensity;
  12150. private _globalSaturation;
  12151. private _globalExposure;
  12152. /**
  12153. * Gets the global Hue value.
  12154. * 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).
  12155. */
  12156. /**
  12157. * Sets the global Hue value.
  12158. * 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).
  12159. */
  12160. globalHue: number;
  12161. /**
  12162. * Gets the global Density value.
  12163. * 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.
  12164. * Values less than zero provide a filter of opposite hue.
  12165. */
  12166. /**
  12167. * Sets the global Density value.
  12168. * 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.
  12169. * Values less than zero provide a filter of opposite hue.
  12170. */
  12171. globalDensity: number;
  12172. /**
  12173. * Gets the global Saturation value.
  12174. * 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.
  12175. */
  12176. /**
  12177. * Sets the global Saturation value.
  12178. * 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.
  12179. */
  12180. globalSaturation: number;
  12181. /**
  12182. * Gets the global Exposure value.
  12183. * 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.
  12184. */
  12185. /**
  12186. * Sets the global Exposure value.
  12187. * 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.
  12188. */
  12189. globalExposure: number;
  12190. private _highlightsHue;
  12191. private _highlightsDensity;
  12192. private _highlightsSaturation;
  12193. private _highlightsExposure;
  12194. /**
  12195. * Gets the highlights Hue value.
  12196. * 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).
  12197. */
  12198. /**
  12199. * Sets the highlights Hue value.
  12200. * 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).
  12201. */
  12202. highlightsHue: number;
  12203. /**
  12204. * Gets the highlights Density value.
  12205. * 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.
  12206. * Values less than zero provide a filter of opposite hue.
  12207. */
  12208. /**
  12209. * Sets the highlights Density value.
  12210. * 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.
  12211. * Values less than zero provide a filter of opposite hue.
  12212. */
  12213. highlightsDensity: number;
  12214. /**
  12215. * Gets the highlights Saturation value.
  12216. * 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.
  12217. */
  12218. /**
  12219. * Sets the highlights Saturation value.
  12220. * 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.
  12221. */
  12222. highlightsSaturation: number;
  12223. /**
  12224. * Gets the highlights Exposure value.
  12225. * 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.
  12226. */
  12227. /**
  12228. * Sets the highlights Exposure value.
  12229. * 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.
  12230. */
  12231. highlightsExposure: number;
  12232. private _midtonesHue;
  12233. private _midtonesDensity;
  12234. private _midtonesSaturation;
  12235. private _midtonesExposure;
  12236. /**
  12237. * Gets the midtones Hue value.
  12238. * 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).
  12239. */
  12240. /**
  12241. * Sets the midtones Hue value.
  12242. * 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).
  12243. */
  12244. midtonesHue: number;
  12245. /**
  12246. * Gets the midtones Density value.
  12247. * 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.
  12248. * Values less than zero provide a filter of opposite hue.
  12249. */
  12250. /**
  12251. * Sets the midtones Density value.
  12252. * 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.
  12253. * Values less than zero provide a filter of opposite hue.
  12254. */
  12255. midtonesDensity: number;
  12256. /**
  12257. * Gets the midtones Saturation value.
  12258. * 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.
  12259. */
  12260. /**
  12261. * Sets the midtones Saturation value.
  12262. * 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.
  12263. */
  12264. midtonesSaturation: number;
  12265. /**
  12266. * Gets the midtones Exposure value.
  12267. * 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.
  12268. */
  12269. /**
  12270. * Sets the midtones Exposure value.
  12271. * 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.
  12272. */
  12273. midtonesExposure: number;
  12274. private _shadowsHue;
  12275. private _shadowsDensity;
  12276. private _shadowsSaturation;
  12277. private _shadowsExposure;
  12278. /**
  12279. * Gets the shadows Hue value.
  12280. * 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).
  12281. */
  12282. /**
  12283. * Sets the shadows Hue value.
  12284. * 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).
  12285. */
  12286. shadowsHue: number;
  12287. /**
  12288. * Gets the shadows Density value.
  12289. * 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.
  12290. * Values less than zero provide a filter of opposite hue.
  12291. */
  12292. /**
  12293. * Sets the shadows Density value.
  12294. * 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.
  12295. * Values less than zero provide a filter of opposite hue.
  12296. */
  12297. shadowsDensity: number;
  12298. /**
  12299. * Gets the shadows Saturation value.
  12300. * 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.
  12301. */
  12302. /**
  12303. * Sets the shadows Saturation value.
  12304. * 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.
  12305. */
  12306. shadowsSaturation: number;
  12307. /**
  12308. * Gets the shadows Exposure value.
  12309. * 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.
  12310. */
  12311. /**
  12312. * Sets the shadows Exposure value.
  12313. * 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.
  12314. */
  12315. shadowsExposure: number;
  12316. getClassName(): string;
  12317. /**
  12318. * Binds the color curves to the shader.
  12319. * @param colorCurves The color curve to bind
  12320. * @param effect The effect to bind to
  12321. */
  12322. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  12323. /**
  12324. * Prepare the list of uniforms associated with the ColorCurves effects.
  12325. * @param uniformsList The list of uniforms used in the effect
  12326. */
  12327. static PrepareUniforms(uniformsList: string[]): void;
  12328. /**
  12329. * Returns color grading data based on a hue, density, saturation and exposure value.
  12330. * @param filterHue The hue of the color filter.
  12331. * @param filterDensity The density of the color filter.
  12332. * @param saturation The saturation.
  12333. * @param exposure The exposure.
  12334. * @param result The result data container.
  12335. */
  12336. private getColorGradingDataToRef(hue, density, saturation, exposure, result);
  12337. /**
  12338. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  12339. * @param value The input slider value in range [-100,100].
  12340. * @returns Adjusted value.
  12341. */
  12342. private static applyColorGradingSliderNonlinear(value);
  12343. /**
  12344. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  12345. * @param hue The hue (H) input.
  12346. * @param saturation The saturation (S) input.
  12347. * @param brightness The brightness (B) input.
  12348. * @result An RGBA color represented as Vector4.
  12349. */
  12350. private static fromHSBToRef(hue, saturation, brightness, result);
  12351. /**
  12352. * Returns a value clamped between min and max
  12353. * @param value The value to clamp
  12354. * @param min The minimum of value
  12355. * @param max The maximum of value
  12356. * @returns The clamped value.
  12357. */
  12358. private static clamp(value, min, max);
  12359. /**
  12360. * Clones the current color curve instance.
  12361. * @return The cloned curves
  12362. */
  12363. clone(): ColorCurves;
  12364. /**
  12365. * Serializes the current color curve instance to a json representation.
  12366. * @return a JSON representation
  12367. */
  12368. serialize(): any;
  12369. /**
  12370. * Parses the color curve from a json representation.
  12371. * @param source the JSON source to parse
  12372. * @return The parsed curves
  12373. */
  12374. static Parse(source: any): ColorCurves;
  12375. }
  12376. }
  12377. declare module BABYLON {
  12378. /**
  12379. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  12380. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  12381. */
  12382. class EffectFallbacks {
  12383. private _defines;
  12384. private _currentRank;
  12385. private _maxRank;
  12386. private _mesh;
  12387. /**
  12388. * Removes the fallback from the bound mesh.
  12389. */
  12390. unBindMesh(): void;
  12391. /**
  12392. * Adds a fallback on the specified property.
  12393. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  12394. * @param define The name of the define in the shader
  12395. */
  12396. addFallback(rank: number, define: string): void;
  12397. /**
  12398. * Sets the mesh to use CPU skinning when needing to fallback.
  12399. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  12400. * @param mesh The mesh to use the fallbacks.
  12401. */
  12402. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  12403. /**
  12404. * Checks to see if more fallbacks are still availible.
  12405. */
  12406. readonly isMoreFallbacks: boolean;
  12407. /**
  12408. * Removes the defines that shoould be removed when falling back.
  12409. * @param currentDefines defines the current define statements for the shader.
  12410. * @param effect defines the current effect we try to compile
  12411. * @returns The resulting defines with defines of the current rank removed.
  12412. */
  12413. reduce(currentDefines: string, effect: Effect): string;
  12414. }
  12415. /**
  12416. * Options to be used when creating an effect.
  12417. */
  12418. class EffectCreationOptions {
  12419. /**
  12420. * Atrributes that will be used in the shader.
  12421. */
  12422. attributes: string[];
  12423. /**
  12424. * Uniform varible names that will be set in the shader.
  12425. */
  12426. uniformsNames: string[];
  12427. /**
  12428. * Uniform buffer varible names that will be set in the shader.
  12429. */
  12430. uniformBuffersNames: string[];
  12431. /**
  12432. * Sampler texture variable names that will be set in the shader.
  12433. */
  12434. samplers: string[];
  12435. /**
  12436. * Define statements that will be set in the shader.
  12437. */
  12438. defines: any;
  12439. /**
  12440. * Possible fallbacks for this effect to improve performance when needed.
  12441. */
  12442. fallbacks: Nullable<EffectFallbacks>;
  12443. /**
  12444. * Callback that will be called when the shader is compiled.
  12445. */
  12446. onCompiled: Nullable<(effect: Effect) => void>;
  12447. /**
  12448. * Callback that will be called if an error occurs during shader compilation.
  12449. */
  12450. onError: Nullable<(effect: Effect, errors: string) => void>;
  12451. /**
  12452. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  12453. */
  12454. indexParameters: any;
  12455. /**
  12456. * Max number of lights that can be used in the shader.
  12457. */
  12458. maxSimultaneousLights: number;
  12459. /**
  12460. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  12461. */
  12462. transformFeedbackVaryings: Nullable<string[]>;
  12463. }
  12464. /**
  12465. * Effect containing vertex and fragment shader that can be executed on an object.
  12466. */
  12467. class Effect {
  12468. /**
  12469. * Name of the effect.
  12470. */
  12471. name: any;
  12472. /**
  12473. * String container all the define statements that should be set on the shader.
  12474. */
  12475. defines: string;
  12476. /**
  12477. * Callback that will be called when the shader is compiled.
  12478. */
  12479. onCompiled: Nullable<(effect: Effect) => void>;
  12480. /**
  12481. * Callback that will be called if an error occurs during shader compilation.
  12482. */
  12483. onError: Nullable<(effect: Effect, errors: string) => void>;
  12484. /**
  12485. * Callback that will be called when effect is bound.
  12486. */
  12487. onBind: Nullable<(effect: Effect) => void>;
  12488. /**
  12489. * Unique ID of the effect.
  12490. */
  12491. uniqueId: number;
  12492. /**
  12493. * Observable that will be called when the shader is compiled.
  12494. */
  12495. onCompileObservable: Observable<Effect>;
  12496. /**
  12497. * Observable that will be called if an error occurs during shader compilation.
  12498. */
  12499. onErrorObservable: Observable<Effect>;
  12500. /**
  12501. * Observable that will be called when effect is bound.
  12502. */
  12503. onBindObservable: Observable<Effect>;
  12504. /** @hidden */
  12505. _bonesComputationForcedToCPU: boolean;
  12506. private static _uniqueIdSeed;
  12507. private _engine;
  12508. private _uniformBuffersNames;
  12509. private _uniformsNames;
  12510. private _samplers;
  12511. private _isReady;
  12512. private _compilationError;
  12513. private _attributesNames;
  12514. private _attributes;
  12515. private _uniforms;
  12516. /**
  12517. * Key for the effect.
  12518. */
  12519. _key: string;
  12520. private _indexParameters;
  12521. private _fallbacks;
  12522. private _vertexSourceCode;
  12523. private _fragmentSourceCode;
  12524. private _vertexSourceCodeOverride;
  12525. private _fragmentSourceCodeOverride;
  12526. private _transformFeedbackVaryings;
  12527. /**
  12528. * Compiled shader to webGL program.
  12529. */
  12530. _program: WebGLProgram;
  12531. private _valueCache;
  12532. private static _baseCache;
  12533. /**
  12534. * Instantiates an effect.
  12535. * An effect can be used to create/manage/execute vertex and fragment shaders.
  12536. * @param baseName Name of the effect.
  12537. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  12538. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  12539. * @param samplers List of sampler variables that will be passed to the shader.
  12540. * @param engine Engine to be used to render the effect
  12541. * @param defines Define statements to be added to the shader.
  12542. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  12543. * @param onCompiled Callback that will be called when the shader is compiled.
  12544. * @param onError Callback that will be called if an error occurs during shader compilation.
  12545. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  12546. */
  12547. 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);
  12548. /**
  12549. * Unique key for this effect
  12550. */
  12551. readonly key: string;
  12552. /**
  12553. * If the effect has been compiled and prepared.
  12554. * @returns if the effect is compiled and prepared.
  12555. */
  12556. isReady(): boolean;
  12557. /**
  12558. * The engine the effect was initialized with.
  12559. * @returns the engine.
  12560. */
  12561. getEngine(): Engine;
  12562. /**
  12563. * The compiled webGL program for the effect
  12564. * @returns the webGL program.
  12565. */
  12566. getProgram(): WebGLProgram;
  12567. /**
  12568. * The set of names of attribute variables for the shader.
  12569. * @returns An array of attribute names.
  12570. */
  12571. getAttributesNames(): string[];
  12572. /**
  12573. * Returns the attribute at the given index.
  12574. * @param index The index of the attribute.
  12575. * @returns The location of the attribute.
  12576. */
  12577. getAttributeLocation(index: number): number;
  12578. /**
  12579. * Returns the attribute based on the name of the variable.
  12580. * @param name of the attribute to look up.
  12581. * @returns the attribute location.
  12582. */
  12583. getAttributeLocationByName(name: string): number;
  12584. /**
  12585. * The number of attributes.
  12586. * @returns the numnber of attributes.
  12587. */
  12588. getAttributesCount(): number;
  12589. /**
  12590. * Gets the index of a uniform variable.
  12591. * @param uniformName of the uniform to look up.
  12592. * @returns the index.
  12593. */
  12594. getUniformIndex(uniformName: string): number;
  12595. /**
  12596. * Returns the attribute based on the name of the variable.
  12597. * @param uniformName of the uniform to look up.
  12598. * @returns the location of the uniform.
  12599. */
  12600. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  12601. /**
  12602. * Returns an array of sampler variable names
  12603. * @returns The array of sampler variable neames.
  12604. */
  12605. getSamplers(): string[];
  12606. /**
  12607. * The error from the last compilation.
  12608. * @returns the error string.
  12609. */
  12610. getCompilationError(): string;
  12611. /**
  12612. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  12613. * @param func The callback to be used.
  12614. */
  12615. executeWhenCompiled(func: (effect: Effect) => void): void;
  12616. /** @hidden */
  12617. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  12618. /** @hidden */
  12619. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  12620. private _dumpShadersSource(vertexCode, fragmentCode, defines);
  12621. private _processShaderConversion(sourceCode, isFragment, callback);
  12622. private _processIncludes(sourceCode, callback);
  12623. private _processPrecision(source);
  12624. /**
  12625. * Recompiles the webGL program
  12626. * @param vertexSourceCode The source code for the vertex shader.
  12627. * @param fragmentSourceCode The source code for the fragment shader.
  12628. * @param onCompiled Callback called when completed.
  12629. * @param onError Callback called on error.
  12630. */
  12631. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void): void;
  12632. /**
  12633. * Gets the uniform locations of the the specified variable names
  12634. * @param names THe names of the variables to lookup.
  12635. * @returns Array of locations in the same order as variable names.
  12636. */
  12637. getSpecificUniformLocations(names: string[]): Nullable<WebGLUniformLocation>[];
  12638. /**
  12639. * Prepares the effect
  12640. */
  12641. _prepareEffect(): void;
  12642. /**
  12643. * Checks if the effect is supported. (Must be called after compilation)
  12644. */
  12645. readonly isSupported: boolean;
  12646. /**
  12647. * Binds a texture to the engine to be used as output of the shader.
  12648. * @param channel Name of the output variable.
  12649. * @param texture Texture to bind.
  12650. */
  12651. _bindTexture(channel: string, texture: InternalTexture): void;
  12652. /**
  12653. * Sets a texture on the engine to be used in the shader.
  12654. * @param channel Name of the sampler variable.
  12655. * @param texture Texture to set.
  12656. */
  12657. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  12658. /**
  12659. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  12660. * @param channel Name of the sampler variable.
  12661. * @param texture Texture to set.
  12662. */
  12663. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  12664. /**
  12665. * Sets an array of textures on the engine to be used in the shader.
  12666. * @param channel Name of the variable.
  12667. * @param textures Textures to set.
  12668. */
  12669. setTextureArray(channel: string, textures: BaseTexture[]): void;
  12670. /**
  12671. * 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)
  12672. * @param channel Name of the sampler variable.
  12673. * @param postProcess Post process to get the input texture from.
  12674. */
  12675. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  12676. /**
  12677. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  12678. * 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)
  12679. * @param channel Name of the sampler variable.
  12680. * @param postProcess Post process to get the output texture from.
  12681. */
  12682. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  12683. /** @hidden */
  12684. _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  12685. /** @hidden */
  12686. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  12687. /** @hidden */
  12688. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  12689. /** @hidden */
  12690. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  12691. /**
  12692. * Binds a buffer to a uniform.
  12693. * @param buffer Buffer to bind.
  12694. * @param name Name of the uniform variable to bind to.
  12695. */
  12696. bindUniformBuffer(buffer: WebGLBuffer, name: string): void;
  12697. /**
  12698. * Binds block to a uniform.
  12699. * @param blockName Name of the block to bind.
  12700. * @param index Index to bind.
  12701. */
  12702. bindUniformBlock(blockName: string, index: number): void;
  12703. /**
  12704. * Sets an interger value on a uniform variable.
  12705. * @param uniformName Name of the variable.
  12706. * @param value Value to be set.
  12707. * @returns this effect.
  12708. */
  12709. setInt(uniformName: string, value: number): Effect;
  12710. /**
  12711. * Sets an int array on a uniform variable.
  12712. * @param uniformName Name of the variable.
  12713. * @param array array to be set.
  12714. * @returns this effect.
  12715. */
  12716. setIntArray(uniformName: string, array: Int32Array): Effect;
  12717. /**
  12718. * 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)
  12719. * @param uniformName Name of the variable.
  12720. * @param array array to be set.
  12721. * @returns this effect.
  12722. */
  12723. setIntArray2(uniformName: string, array: Int32Array): Effect;
  12724. /**
  12725. * 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)
  12726. * @param uniformName Name of the variable.
  12727. * @param array array to be set.
  12728. * @returns this effect.
  12729. */
  12730. setIntArray3(uniformName: string, array: Int32Array): Effect;
  12731. /**
  12732. * 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)
  12733. * @param uniformName Name of the variable.
  12734. * @param array array to be set.
  12735. * @returns this effect.
  12736. */
  12737. setIntArray4(uniformName: string, array: Int32Array): Effect;
  12738. /**
  12739. * Sets an float array on a uniform variable.
  12740. * @param uniformName Name of the variable.
  12741. * @param array array to be set.
  12742. * @returns this effect.
  12743. */
  12744. setFloatArray(uniformName: string, array: Float32Array): Effect;
  12745. /**
  12746. * 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)
  12747. * @param uniformName Name of the variable.
  12748. * @param array array to be set.
  12749. * @returns this effect.
  12750. */
  12751. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  12752. /**
  12753. * 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)
  12754. * @param uniformName Name of the variable.
  12755. * @param array array to be set.
  12756. * @returns this effect.
  12757. */
  12758. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  12759. /**
  12760. * 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)
  12761. * @param uniformName Name of the variable.
  12762. * @param array array to be set.
  12763. * @returns this effect.
  12764. */
  12765. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  12766. /**
  12767. * Sets an array on a uniform variable.
  12768. * @param uniformName Name of the variable.
  12769. * @param array array to be set.
  12770. * @returns this effect.
  12771. */
  12772. setArray(uniformName: string, array: number[]): Effect;
  12773. /**
  12774. * 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)
  12775. * @param uniformName Name of the variable.
  12776. * @param array array to be set.
  12777. * @returns this effect.
  12778. */
  12779. setArray2(uniformName: string, array: number[]): Effect;
  12780. /**
  12781. * 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)
  12782. * @param uniformName Name of the variable.
  12783. * @param array array to be set.
  12784. * @returns this effect.
  12785. */
  12786. setArray3(uniformName: string, array: number[]): Effect;
  12787. /**
  12788. * 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)
  12789. * @param uniformName Name of the variable.
  12790. * @param array array to be set.
  12791. * @returns this effect.
  12792. */
  12793. setArray4(uniformName: string, array: number[]): Effect;
  12794. /**
  12795. * Sets matrices on a uniform variable.
  12796. * @param uniformName Name of the variable.
  12797. * @param matrices matrices to be set.
  12798. * @returns this effect.
  12799. */
  12800. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  12801. /**
  12802. * Sets matrix on a uniform variable.
  12803. * @param uniformName Name of the variable.
  12804. * @param matrix matrix to be set.
  12805. * @returns this effect.
  12806. */
  12807. setMatrix(uniformName: string, matrix: Matrix): Effect;
  12808. /**
  12809. * 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)
  12810. * @param uniformName Name of the variable.
  12811. * @param matrix matrix to be set.
  12812. * @returns this effect.
  12813. */
  12814. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  12815. /**
  12816. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  12817. * @param uniformName Name of the variable.
  12818. * @param matrix matrix to be set.
  12819. * @returns this effect.
  12820. */
  12821. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  12822. /**
  12823. * Sets a float on a uniform variable.
  12824. * @param uniformName Name of the variable.
  12825. * @param value value to be set.
  12826. * @returns this effect.
  12827. */
  12828. setFloat(uniformName: string, value: number): Effect;
  12829. /**
  12830. * Sets a boolean on a uniform variable.
  12831. * @param uniformName Name of the variable.
  12832. * @param bool value to be set.
  12833. * @returns this effect.
  12834. */
  12835. setBool(uniformName: string, bool: boolean): Effect;
  12836. /**
  12837. * Sets a Vector2 on a uniform variable.
  12838. * @param uniformName Name of the variable.
  12839. * @param vector2 vector2 to be set.
  12840. * @returns this effect.
  12841. */
  12842. setVector2(uniformName: string, vector2: Vector2): Effect;
  12843. /**
  12844. * Sets a float2 on a uniform variable.
  12845. * @param uniformName Name of the variable.
  12846. * @param x First float in float2.
  12847. * @param y Second float in float2.
  12848. * @returns this effect.
  12849. */
  12850. setFloat2(uniformName: string, x: number, y: number): Effect;
  12851. /**
  12852. * Sets a Vector3 on a uniform variable.
  12853. * @param uniformName Name of the variable.
  12854. * @param vector3 Value to be set.
  12855. * @returns this effect.
  12856. */
  12857. setVector3(uniformName: string, vector3: Vector3): Effect;
  12858. /**
  12859. * Sets a float3 on a uniform variable.
  12860. * @param uniformName Name of the variable.
  12861. * @param x First float in float3.
  12862. * @param y Second float in float3.
  12863. * @param z Third float in float3.
  12864. * @returns this effect.
  12865. */
  12866. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  12867. /**
  12868. * Sets a Vector4 on a uniform variable.
  12869. * @param uniformName Name of the variable.
  12870. * @param vector4 Value to be set.
  12871. * @returns this effect.
  12872. */
  12873. setVector4(uniformName: string, vector4: Vector4): Effect;
  12874. /**
  12875. * Sets a float4 on a uniform variable.
  12876. * @param uniformName Name of the variable.
  12877. * @param x First float in float4.
  12878. * @param y Second float in float4.
  12879. * @param z Third float in float4.
  12880. * @param w Fourth float in float4.
  12881. * @returns this effect.
  12882. */
  12883. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  12884. /**
  12885. * Sets a Color3 on a uniform variable.
  12886. * @param uniformName Name of the variable.
  12887. * @param color3 Value to be set.
  12888. * @returns this effect.
  12889. */
  12890. setColor3(uniformName: string, color3: Color3): Effect;
  12891. /**
  12892. * Sets a Color4 on a uniform variable.
  12893. * @param uniformName Name of the variable.
  12894. * @param color3 Value to be set.
  12895. * @param alpha Alpha value to be set.
  12896. * @returns this effect.
  12897. */
  12898. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  12899. /**
  12900. * Sets a Color4 on a uniform variable
  12901. * @param uniformName defines the name of the variable
  12902. * @param color4 defines the value to be set
  12903. * @returns this effect.
  12904. */
  12905. setDirectColor4(uniformName: string, color4: Color4): Effect;
  12906. /**
  12907. * Store of each shader (The can be looked up using effect.key)
  12908. */
  12909. static ShadersStore: {
  12910. [key: string]: string;
  12911. };
  12912. /**
  12913. * Store of each included file for a shader (The can be looked up using effect.key)
  12914. */
  12915. static IncludesShadersStore: {
  12916. [key: string]: string;
  12917. };
  12918. /**
  12919. * Resets the cache of effects.
  12920. */
  12921. static ResetCache(): void;
  12922. }
  12923. }
  12924. declare module BABYLON {
  12925. class FresnelParameters {
  12926. private _isEnabled;
  12927. isEnabled: boolean;
  12928. leftColor: Color3;
  12929. rightColor: Color3;
  12930. bias: number;
  12931. power: number;
  12932. clone(): FresnelParameters;
  12933. serialize(): any;
  12934. static Parse(parsedFresnelParameters: any): FresnelParameters;
  12935. }
  12936. }
  12937. declare module BABYLON {
  12938. /**
  12939. * Interface to follow in your material defines to integrate easily the
  12940. * Image proccessing functions.
  12941. * @hidden
  12942. */
  12943. interface IImageProcessingConfigurationDefines {
  12944. IMAGEPROCESSING: boolean;
  12945. VIGNETTE: boolean;
  12946. VIGNETTEBLENDMODEMULTIPLY: boolean;
  12947. VIGNETTEBLENDMODEOPAQUE: boolean;
  12948. TONEMAPPING: boolean;
  12949. CONTRAST: boolean;
  12950. EXPOSURE: boolean;
  12951. COLORCURVES: boolean;
  12952. COLORGRADING: boolean;
  12953. COLORGRADING3D: boolean;
  12954. SAMPLER3DGREENDEPTH: boolean;
  12955. SAMPLER3DBGRMAP: boolean;
  12956. IMAGEPROCESSINGPOSTPROCESS: boolean;
  12957. }
  12958. /**
  12959. * This groups together the common properties used for image processing either in direct forward pass
  12960. * or through post processing effect depending on the use of the image processing pipeline in your scene
  12961. * or not.
  12962. */
  12963. class ImageProcessingConfiguration {
  12964. /**
  12965. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  12966. */
  12967. colorCurves: Nullable<ColorCurves>;
  12968. private _colorCurvesEnabled;
  12969. /**
  12970. * Gets wether the color curves effect is enabled.
  12971. */
  12972. /**
  12973. * Sets wether the color curves effect is enabled.
  12974. */
  12975. colorCurvesEnabled: boolean;
  12976. /**
  12977. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  12978. */
  12979. colorGradingTexture: Nullable<BaseTexture>;
  12980. private _colorGradingEnabled;
  12981. /**
  12982. * Gets wether the color grading effect is enabled.
  12983. */
  12984. /**
  12985. * Sets wether the color grading effect is enabled.
  12986. */
  12987. colorGradingEnabled: boolean;
  12988. private _colorGradingWithGreenDepth;
  12989. /**
  12990. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  12991. */
  12992. /**
  12993. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  12994. */
  12995. colorGradingWithGreenDepth: boolean;
  12996. private _colorGradingBGR;
  12997. /**
  12998. * Gets wether the color grading texture contains BGR values.
  12999. */
  13000. /**
  13001. * Sets wether the color grading texture contains BGR values.
  13002. */
  13003. colorGradingBGR: boolean;
  13004. _exposure: number;
  13005. /**
  13006. * Gets the Exposure used in the effect.
  13007. */
  13008. /**
  13009. * Sets the Exposure used in the effect.
  13010. */
  13011. exposure: number;
  13012. private _toneMappingEnabled;
  13013. /**
  13014. * Gets wether the tone mapping effect is enabled.
  13015. */
  13016. /**
  13017. * Sets wether the tone mapping effect is enabled.
  13018. */
  13019. toneMappingEnabled: boolean;
  13020. protected _contrast: number;
  13021. /**
  13022. * Gets the contrast used in the effect.
  13023. */
  13024. /**
  13025. * Sets the contrast used in the effect.
  13026. */
  13027. contrast: number;
  13028. /**
  13029. * Vignette stretch size.
  13030. */
  13031. vignetteStretch: number;
  13032. /**
  13033. * Vignette centre X Offset.
  13034. */
  13035. vignetteCentreX: number;
  13036. /**
  13037. * Vignette centre Y Offset.
  13038. */
  13039. vignetteCentreY: number;
  13040. /**
  13041. * Vignette weight or intensity of the vignette effect.
  13042. */
  13043. vignetteWeight: number;
  13044. /**
  13045. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  13046. * if vignetteEnabled is set to true.
  13047. */
  13048. vignetteColor: Color4;
  13049. /**
  13050. * Camera field of view used by the Vignette effect.
  13051. */
  13052. vignetteCameraFov: number;
  13053. private _vignetteBlendMode;
  13054. /**
  13055. * Gets the vignette blend mode allowing different kind of effect.
  13056. */
  13057. /**
  13058. * Sets the vignette blend mode allowing different kind of effect.
  13059. */
  13060. vignetteBlendMode: number;
  13061. private _vignetteEnabled;
  13062. /**
  13063. * Gets wether the vignette effect is enabled.
  13064. */
  13065. /**
  13066. * Sets wether the vignette effect is enabled.
  13067. */
  13068. vignetteEnabled: boolean;
  13069. private _applyByPostProcess;
  13070. /**
  13071. * Gets wether the image processing is applied through a post process or not.
  13072. */
  13073. /**
  13074. * Sets wether the image processing is applied through a post process or not.
  13075. */
  13076. applyByPostProcess: boolean;
  13077. private _isEnabled;
  13078. /**
  13079. * Gets wether the image processing is enabled or not.
  13080. */
  13081. /**
  13082. * Sets wether the image processing is enabled or not.
  13083. */
  13084. isEnabled: boolean;
  13085. /**
  13086. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  13087. */
  13088. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  13089. /**
  13090. * Method called each time the image processing information changes requires to recompile the effect.
  13091. */
  13092. protected _updateParameters(): void;
  13093. getClassName(): string;
  13094. /**
  13095. * Prepare the list of uniforms associated with the Image Processing effects.
  13096. * @param uniformsList The list of uniforms used in the effect
  13097. * @param defines the list of defines currently in use
  13098. */
  13099. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  13100. /**
  13101. * Prepare the list of samplers associated with the Image Processing effects.
  13102. * @param uniformsList The list of uniforms used in the effect
  13103. * @param defines the list of defines currently in use
  13104. */
  13105. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  13106. /**
  13107. * Prepare the list of defines associated to the shader.
  13108. * @param defines the list of defines to complete
  13109. */
  13110. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  13111. /**
  13112. * Returns true if all the image processing information are ready.
  13113. */
  13114. isReady(): boolean;
  13115. /**
  13116. * Binds the image processing to the shader.
  13117. * @param effect The effect to bind to
  13118. */
  13119. bind(effect: Effect, aspectRatio?: number): void;
  13120. /**
  13121. * Clones the current image processing instance.
  13122. * @return The cloned image processing
  13123. */
  13124. clone(): ImageProcessingConfiguration;
  13125. /**
  13126. * Serializes the current image processing instance to a json representation.
  13127. * @return a JSON representation
  13128. */
  13129. serialize(): any;
  13130. /**
  13131. * Parses the image processing from a json representation.
  13132. * @param source the JSON source to parse
  13133. * @return The parsed image processing
  13134. */
  13135. static Parse(source: any): ImageProcessingConfiguration;
  13136. private static _VIGNETTEMODE_MULTIPLY;
  13137. private static _VIGNETTEMODE_OPAQUE;
  13138. /**
  13139. * Used to apply the vignette as a mix with the pixel color.
  13140. */
  13141. static readonly VIGNETTEMODE_MULTIPLY: number;
  13142. /**
  13143. * Used to apply the vignette as a replacement of the pixel color.
  13144. */
  13145. static readonly VIGNETTEMODE_OPAQUE: number;
  13146. }
  13147. }
  13148. declare module BABYLON {
  13149. /**
  13150. * Manages the defines for the Material
  13151. */
  13152. class MaterialDefines {
  13153. private _keys;
  13154. private _isDirty;
  13155. /** @hidden */
  13156. _renderId: number;
  13157. /** @hidden */
  13158. _areLightsDirty: boolean;
  13159. /** @hidden */
  13160. _areAttributesDirty: boolean;
  13161. /** @hidden */
  13162. _areTexturesDirty: boolean;
  13163. /** @hidden */
  13164. _areFresnelDirty: boolean;
  13165. /** @hidden */
  13166. _areMiscDirty: boolean;
  13167. /** @hidden */
  13168. _areImageProcessingDirty: boolean;
  13169. /** @hidden */
  13170. _normals: boolean;
  13171. /** @hidden */
  13172. _uvs: boolean;
  13173. /** @hidden */
  13174. _needNormals: boolean;
  13175. /** @hidden */
  13176. _needUVs: boolean;
  13177. /**
  13178. * Specifies if the material needs to be re-calculated
  13179. */
  13180. readonly isDirty: boolean;
  13181. /**
  13182. * Marks the material to indicate that it has been re-calculated
  13183. */
  13184. markAsProcessed(): void;
  13185. /**
  13186. * Marks the material to indicate that it needs to be re-calculated
  13187. */
  13188. markAsUnprocessed(): void;
  13189. /**
  13190. * Marks the material to indicate all of its defines need to be re-calculated
  13191. */
  13192. markAllAsDirty(): void;
  13193. /**
  13194. * Marks the material to indicate that image processing needs to be re-calculated
  13195. */
  13196. markAsImageProcessingDirty(): void;
  13197. /**
  13198. * Marks the material to indicate the lights need to be re-calculated
  13199. */
  13200. markAsLightDirty(): void;
  13201. /**
  13202. * Marks the attribute state as changed
  13203. */
  13204. markAsAttributesDirty(): void;
  13205. /**
  13206. * Marks the texture state as changed
  13207. */
  13208. markAsTexturesDirty(): void;
  13209. /**
  13210. * Marks the fresnel state as changed
  13211. */
  13212. markAsFresnelDirty(): void;
  13213. /**
  13214. * Marks the misc state as changed
  13215. */
  13216. markAsMiscDirty(): void;
  13217. /**
  13218. * Rebuilds the material defines
  13219. */
  13220. rebuild(): void;
  13221. /**
  13222. * Specifies if two material defines are equal
  13223. * @param other - A material define instance to compare to
  13224. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  13225. */
  13226. isEqual(other: MaterialDefines): boolean;
  13227. /**
  13228. * Clones this instance's defines to another instance
  13229. * @param other - material defines to clone values to
  13230. */
  13231. cloneTo(other: MaterialDefines): void;
  13232. /**
  13233. * Resets the material define values
  13234. */
  13235. reset(): void;
  13236. /**
  13237. * Converts the material define values to a string
  13238. * @returns - String of material define information
  13239. */
  13240. toString(): string;
  13241. }
  13242. /**
  13243. * Base class for the main features of a material in Babylon.js
  13244. */
  13245. class Material implements IAnimatable {
  13246. private static _TriangleFillMode;
  13247. private static _WireFrameFillMode;
  13248. private static _PointFillMode;
  13249. private static _PointListDrawMode;
  13250. private static _LineListDrawMode;
  13251. private static _LineLoopDrawMode;
  13252. private static _LineStripDrawMode;
  13253. private static _TriangleStripDrawMode;
  13254. private static _TriangleFanDrawMode;
  13255. /**
  13256. * Returns the triangle fill mode
  13257. */
  13258. static readonly TriangleFillMode: number;
  13259. /**
  13260. * Returns the wireframe mode
  13261. */
  13262. static readonly WireFrameFillMode: number;
  13263. /**
  13264. * Returns the point fill mode
  13265. */
  13266. static readonly PointFillMode: number;
  13267. /**
  13268. * Returns the point list draw mode
  13269. */
  13270. static readonly PointListDrawMode: number;
  13271. /**
  13272. * Returns the line list draw mode
  13273. */
  13274. static readonly LineListDrawMode: number;
  13275. /**
  13276. * Returns the line loop draw mode
  13277. */
  13278. static readonly LineLoopDrawMode: number;
  13279. /**
  13280. * Returns the line strip draw mode
  13281. */
  13282. static readonly LineStripDrawMode: number;
  13283. /**
  13284. * Returns the triangle strip draw mode
  13285. */
  13286. static readonly TriangleStripDrawMode: number;
  13287. /**
  13288. * Returns the triangle fan draw mode
  13289. */
  13290. static readonly TriangleFanDrawMode: number;
  13291. /**
  13292. * Stores the clock-wise side orientation
  13293. */
  13294. private static _ClockWiseSideOrientation;
  13295. /**
  13296. * Stores the counter clock-wise side orientation
  13297. */
  13298. private static _CounterClockWiseSideOrientation;
  13299. /**
  13300. * Returns the clock-wise side orientation
  13301. */
  13302. static readonly ClockWiseSideOrientation: number;
  13303. /**
  13304. * Returns the counter clock-wise side orientation
  13305. */
  13306. static readonly CounterClockWiseSideOrientation: number;
  13307. /**
  13308. * The dirty texture flag value
  13309. */
  13310. private static _TextureDirtyFlag;
  13311. /**
  13312. * The dirty light flag value
  13313. */
  13314. private static _LightDirtyFlag;
  13315. /**
  13316. * The dirty fresnel flag value
  13317. */
  13318. private static _FresnelDirtyFlag;
  13319. /**
  13320. * The dirty attribute flag value
  13321. */
  13322. private static _AttributesDirtyFlag;
  13323. /**
  13324. * The dirty misc flag value
  13325. */
  13326. private static _MiscDirtyFlag;
  13327. /**
  13328. * Returns the dirty texture flag value
  13329. */
  13330. static readonly TextureDirtyFlag: number;
  13331. /**
  13332. * Returns the dirty light flag value
  13333. */
  13334. static readonly LightDirtyFlag: number;
  13335. /**
  13336. * Returns the dirty fresnel flag value
  13337. */
  13338. static readonly FresnelDirtyFlag: number;
  13339. /**
  13340. * Returns the dirty attributes flag value
  13341. */
  13342. static readonly AttributesDirtyFlag: number;
  13343. /**
  13344. * Returns the dirty misc flag value
  13345. */
  13346. static readonly MiscDirtyFlag: number;
  13347. /**
  13348. * The ID of the material
  13349. */
  13350. id: string;
  13351. /**
  13352. * Gets or sets the unique id of the material
  13353. */
  13354. uniqueId: number;
  13355. /**
  13356. * The name of the material
  13357. */
  13358. name: string;
  13359. /**
  13360. * Specifies if the ready state should be checked on each call
  13361. */
  13362. checkReadyOnEveryCall: boolean;
  13363. /**
  13364. * Specifies if the ready state should be checked once
  13365. */
  13366. checkReadyOnlyOnce: boolean;
  13367. /**
  13368. * The state of the material
  13369. */
  13370. state: string;
  13371. /**
  13372. * The alpha value of the material
  13373. */
  13374. protected _alpha: number;
  13375. /**
  13376. * Gets the alpha value of the material
  13377. */
  13378. /**
  13379. * Sets the alpha value of the material
  13380. */
  13381. alpha: number;
  13382. /**
  13383. * Specifies if back face culling is enabled
  13384. */
  13385. protected _backFaceCulling: boolean;
  13386. /**
  13387. * Gets the back-face culling state
  13388. */
  13389. /**
  13390. * Sets the back-face culling state
  13391. */
  13392. backFaceCulling: boolean;
  13393. /**
  13394. * Stores the value for side orientation
  13395. */
  13396. sideOrientation: number;
  13397. /**
  13398. * Callback triggered when the material is compiled
  13399. */
  13400. onCompiled: (effect: Effect) => void;
  13401. /**
  13402. * Callback triggered when an error occurs
  13403. */
  13404. onError: (effect: Effect, errors: string) => void;
  13405. /**
  13406. * Callback triggered to get the render target textures
  13407. */
  13408. getRenderTargetTextures: () => SmartArray<RenderTargetTexture>;
  13409. /**
  13410. * Specifies if the material should be serialized
  13411. */
  13412. doNotSerialize: boolean;
  13413. /**
  13414. * Specifies if the effect should be stored on sub meshes
  13415. */
  13416. storeEffectOnSubMeshes: boolean;
  13417. /**
  13418. * Stores the animations for the material
  13419. */
  13420. animations: Array<Animation>;
  13421. /**
  13422. * An event triggered when the material is disposed
  13423. */
  13424. onDisposeObservable: Observable<Material>;
  13425. /**
  13426. * An observer which watches for dispose events
  13427. */
  13428. private _onDisposeObserver;
  13429. /**
  13430. * Called during a dispose event
  13431. */
  13432. onDispose: () => void;
  13433. /**
  13434. * An event triggered when the material is bound
  13435. */
  13436. onBindObservable: Observable<AbstractMesh>;
  13437. /**
  13438. * An observer which watches for bind events
  13439. */
  13440. private _onBindObserver;
  13441. /**
  13442. * Called during a bind event
  13443. */
  13444. onBind: (Mesh: AbstractMesh) => void;
  13445. /**
  13446. * An event triggered when the material is unbound
  13447. */
  13448. onUnBindObservable: Observable<Material>;
  13449. /**
  13450. * Stores the value of the alpha mode
  13451. */
  13452. private _alphaMode;
  13453. /**
  13454. * Gets the value of the alpha mode
  13455. */
  13456. /**
  13457. * Sets the value of the alpha mode.
  13458. *
  13459. * | Value | Type | Description |
  13460. * | --- | --- | --- |
  13461. * | 0 | ALPHA_DISABLE | |
  13462. * | 1 | ALPHA_ADD | |
  13463. * | 2 | ALPHA_COMBINE | |
  13464. * | 3 | ALPHA_SUBTRACT | |
  13465. * | 4 | ALPHA_MULTIPLY | |
  13466. * | 5 | ALPHA_MAXIMIZED | |
  13467. * | 6 | ALPHA_ONEONE | |
  13468. * | 7 | ALPHA_PREMULTIPLIED | |
  13469. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  13470. * | 9 | ALPHA_INTERPOLATE | |
  13471. * | 10 | ALPHA_SCREENMODE | |
  13472. *
  13473. */
  13474. alphaMode: number;
  13475. /**
  13476. * Stores the state of the need depth pre-pass value
  13477. */
  13478. private _needDepthPrePass;
  13479. /**
  13480. * Gets the depth pre-pass value
  13481. */
  13482. /**
  13483. * Sets the need depth pre-pass value
  13484. */
  13485. needDepthPrePass: boolean;
  13486. /**
  13487. * Specifies if depth writing should be disabled
  13488. */
  13489. disableDepthWrite: boolean;
  13490. /**
  13491. * Specifies if depth writing should be forced
  13492. */
  13493. forceDepthWrite: boolean;
  13494. /**
  13495. * Specifies if there should be a separate pass for culling
  13496. */
  13497. separateCullingPass: boolean;
  13498. /**
  13499. * Stores the state specifing if fog should be enabled
  13500. */
  13501. private _fogEnabled;
  13502. /**
  13503. * Gets the value of the fog enabled state
  13504. */
  13505. /**
  13506. * Sets the state for enabling fog
  13507. */
  13508. fogEnabled: boolean;
  13509. /**
  13510. * Stores the size of points
  13511. */
  13512. pointSize: number;
  13513. /**
  13514. * Stores the z offset value
  13515. */
  13516. zOffset: number;
  13517. /**
  13518. * Gets a value specifying if wireframe mode is enabled
  13519. */
  13520. /**
  13521. * Sets the state of wireframe mode
  13522. */
  13523. wireframe: boolean;
  13524. /**
  13525. * Gets the value specifying if point clouds are enabled
  13526. */
  13527. /**
  13528. * Sets the state of point cloud mode
  13529. */
  13530. pointsCloud: boolean;
  13531. /**
  13532. * Gets the material fill mode
  13533. */
  13534. /**
  13535. * Sets the material fill mode
  13536. */
  13537. fillMode: number;
  13538. /**
  13539. * Stores the effects for the material
  13540. */
  13541. _effect: Nullable<Effect>;
  13542. /**
  13543. * Specifies if the material was previously ready
  13544. */
  13545. _wasPreviouslyReady: boolean;
  13546. /**
  13547. * Specifies if uniform buffers should be used
  13548. */
  13549. private _useUBO;
  13550. /**
  13551. * Stores a reference to the scene
  13552. */
  13553. private _scene;
  13554. /**
  13555. * Stores the fill mode state
  13556. */
  13557. private _fillMode;
  13558. /**
  13559. * Specifies if the depth write state should be cached
  13560. */
  13561. private _cachedDepthWriteState;
  13562. /**
  13563. * Stores the uniform buffer
  13564. */
  13565. protected _uniformBuffer: UniformBuffer;
  13566. /**
  13567. * Creates a material instance
  13568. * @param name defines the name of the material
  13569. * @param scene defines the scene to reference
  13570. * @param doNotAdd specifies if the material should be added to the scene
  13571. */
  13572. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  13573. /**
  13574. * Returns a string representation of the current material
  13575. * @param fullDetails defines a boolean indicating which levels of logging is desired
  13576. * @returns a string with material information
  13577. */
  13578. toString(fullDetails?: boolean): string;
  13579. /**
  13580. * Gets the class name of the material
  13581. * @returns a string with the class name of the material
  13582. */
  13583. getClassName(): string;
  13584. /**
  13585. * Specifies if updates for the material been locked
  13586. */
  13587. readonly isFrozen: boolean;
  13588. /**
  13589. * Locks updates for the material
  13590. */
  13591. freeze(): void;
  13592. /**
  13593. * Unlocks updates for the material
  13594. */
  13595. unfreeze(): void;
  13596. /**
  13597. * Specifies if the material is ready to be used
  13598. * @param mesh defines the mesh to check
  13599. * @param useInstances specifies if instances should be used
  13600. * @returns a boolean indicating if the material is ready to be used
  13601. */
  13602. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  13603. /**
  13604. * Specifies that the submesh is ready to be used
  13605. * @param mesh defines the mesh to check
  13606. * @param subMesh defines which submesh to check
  13607. * @param useInstances specifies that instances should be used
  13608. * @returns a boolean indicating that the submesh is ready or not
  13609. */
  13610. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  13611. /**
  13612. * Returns the material effect
  13613. * @returns the effect associated with the material
  13614. */
  13615. getEffect(): Nullable<Effect>;
  13616. /**
  13617. * Returns the current scene
  13618. * @returns a Scene
  13619. */
  13620. getScene(): Scene;
  13621. /**
  13622. * Specifies if the material will require alpha blending
  13623. * @returns a boolean specifying if alpha blending is needed
  13624. */
  13625. needAlphaBlending(): boolean;
  13626. /**
  13627. * Specifies if the mesh will require alpha blending
  13628. * @param mesh defines the mesh to check
  13629. * @returns a boolean specifying if alpha blending is needed for the mesh
  13630. */
  13631. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  13632. /**
  13633. * Specifies if this material should be rendered in alpha test mode
  13634. * @returns a boolean specifying if an alpha test is needed.
  13635. */
  13636. needAlphaTesting(): boolean;
  13637. /**
  13638. * Gets the texture used for the alpha test
  13639. * @returns the texture to use for alpha testing
  13640. */
  13641. getAlphaTestTexture(): Nullable<BaseTexture>;
  13642. /**
  13643. * Marks the material to indicate that it needs to be re-calculated
  13644. */
  13645. markDirty(): void;
  13646. /** @hidden */
  13647. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  13648. /**
  13649. * Binds the material to the mesh
  13650. * @param world defines the world transformation matrix
  13651. * @param mesh defines the mesh to bind the material to
  13652. */
  13653. bind(world: Matrix, mesh?: Mesh): void;
  13654. /**
  13655. * Binds the submesh to the material
  13656. * @param world defines the world transformation matrix
  13657. * @param mesh defines the mesh containing the submesh
  13658. * @param subMesh defines the submesh to bind the material to
  13659. */
  13660. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  13661. /**
  13662. * Binds the world matrix to the material
  13663. * @param world defines the world transformation matrix
  13664. */
  13665. bindOnlyWorldMatrix(world: Matrix): void;
  13666. /**
  13667. * Binds the scene's uniform buffer to the effect.
  13668. * @param effect defines the effect to bind to the scene uniform buffer
  13669. * @param sceneUbo defines the uniform buffer storing scene data
  13670. */
  13671. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  13672. /**
  13673. * Binds the view matrix to the effect
  13674. * @param effect defines the effect to bind the view matrix to
  13675. */
  13676. bindView(effect: Effect): void;
  13677. /**
  13678. * Binds the view projection matrix to the effect
  13679. * @param effect defines the effect to bind the view projection matrix to
  13680. */
  13681. bindViewProjection(effect: Effect): void;
  13682. /**
  13683. * Specifies if material alpha testing should be turned on for the mesh
  13684. * @param mesh defines the mesh to check
  13685. */
  13686. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  13687. /**
  13688. * Processes to execute after binding the material to a mesh
  13689. * @param mesh defines the rendered mesh
  13690. */
  13691. protected _afterBind(mesh?: Mesh): void;
  13692. /**
  13693. * Unbinds the material from the mesh
  13694. */
  13695. unbind(): void;
  13696. /**
  13697. * Gets the active textures from the material
  13698. * @returns an array of textures
  13699. */
  13700. getActiveTextures(): BaseTexture[];
  13701. /**
  13702. * Specifies if the material uses a texture
  13703. * @param texture defines the texture to check against the material
  13704. * @returns a boolean specifying if the material uses the texture
  13705. */
  13706. hasTexture(texture: BaseTexture): boolean;
  13707. /**
  13708. * Makes a duplicate of the material, and gives it a new name
  13709. * @param name defines the new name for the duplicated material
  13710. * @returns the cloned material
  13711. */
  13712. clone(name: string): Nullable<Material>;
  13713. /**
  13714. * Gets the meshes bound to the material
  13715. * @returns an array of meshes bound to the material
  13716. */
  13717. getBindedMeshes(): AbstractMesh[];
  13718. /**
  13719. * Force shader compilation
  13720. * @param mesh defines the mesh associated with this material
  13721. * @param onCompiled defines a function to execute once the material is compiled
  13722. * @param options defines the options to configure the compilation
  13723. */
  13724. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  13725. clipPlane: boolean;
  13726. }>): void;
  13727. /**
  13728. * Force shader compilation
  13729. * @param mesh defines the mesh that will use this material
  13730. * @param options defines additional options for compiling the shaders
  13731. * @returns a promise that resolves when the compilation completes
  13732. */
  13733. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  13734. clipPlane: boolean;
  13735. }>): Promise<void>;
  13736. /**
  13737. * Marks a define in the material to indicate that it needs to be re-computed
  13738. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  13739. */
  13740. markAsDirty(flag: number): void;
  13741. /**
  13742. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  13743. * @param func defines a function which checks material defines against the submeshes
  13744. */
  13745. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  13746. /**
  13747. * Indicates that image processing needs to be re-calculated for all submeshes
  13748. */
  13749. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  13750. /**
  13751. * Indicates that textures need to be re-calculated for all submeshes
  13752. */
  13753. protected _markAllSubMeshesAsTexturesDirty(): void;
  13754. /**
  13755. * Indicates that fresnel needs to be re-calculated for all submeshes
  13756. */
  13757. protected _markAllSubMeshesAsFresnelDirty(): void;
  13758. /**
  13759. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  13760. */
  13761. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  13762. /**
  13763. * Indicates that lights need to be re-calculated for all submeshes
  13764. */
  13765. protected _markAllSubMeshesAsLightsDirty(): void;
  13766. /**
  13767. * Indicates that attributes need to be re-calculated for all submeshes
  13768. */
  13769. protected _markAllSubMeshesAsAttributesDirty(): void;
  13770. /**
  13771. * Indicates that misc needs to be re-calculated for all submeshes
  13772. */
  13773. protected _markAllSubMeshesAsMiscDirty(): void;
  13774. /**
  13775. * Indicates that textures and misc need to be re-calculated for all submeshes
  13776. */
  13777. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  13778. /**
  13779. * Disposes the material
  13780. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  13781. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  13782. */
  13783. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  13784. /**
  13785. * Serializes this material
  13786. * @returns the serialized material object
  13787. */
  13788. serialize(): any;
  13789. /**
  13790. * Creates a MultiMaterial from parsed MultiMaterial data.
  13791. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  13792. * @param scene defines the hosting scene
  13793. * @returns a new MultiMaterial
  13794. */
  13795. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  13796. /**
  13797. * Creates a material from parsed material data
  13798. * @param parsedMaterial defines parsed material data
  13799. * @param scene defines the hosting scene
  13800. * @param rootUrl defines the root URL to use to load textures
  13801. * @returns a new material
  13802. */
  13803. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): any;
  13804. }
  13805. }
  13806. declare module BABYLON {
  13807. /**
  13808. * "Static Class" containing the most commonly used helper while dealing with material for
  13809. * rendering purpose.
  13810. *
  13811. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  13812. *
  13813. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  13814. */
  13815. class MaterialHelper {
  13816. /**
  13817. * Bind the current view position to an effect.
  13818. * @param effect The effect to be bound
  13819. * @param scene The scene the eyes position is used from
  13820. */
  13821. static BindEyePosition(effect: Effect, scene: Scene): void;
  13822. /**
  13823. * Helps preparing the defines values about the UVs in used in the effect.
  13824. * UVs are shared as much as we can accross chanels in the shaders.
  13825. * @param texture The texture we are preparing the UVs for
  13826. * @param defines The defines to update
  13827. * @param key The chanel key "diffuse", "specular"... used in the shader
  13828. */
  13829. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  13830. /**
  13831. * Binds a texture matrix value to its corrsponding uniform
  13832. * @param texture The texture to bind the matrix for
  13833. * @param uniformBuffer The uniform buffer receivin the data
  13834. * @param key The chanel key "diffuse", "specular"... used in the shader
  13835. */
  13836. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  13837. /**
  13838. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  13839. * @param mesh defines the current mesh
  13840. * @param scene defines the current scene
  13841. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  13842. * @param pointsCloud defines if point cloud rendering has to be turned on
  13843. * @param fogEnabled defines if fog has to be turned on
  13844. * @param alphaTest defines if alpha testing has to be turned on
  13845. * @param defines defines the current list of defines
  13846. */
  13847. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  13848. /**
  13849. * Helper used to prepare the list of defines associated with frame values for shader compilation
  13850. * @param scene defines the current scene
  13851. * @param engine defines the current engine
  13852. * @param defines specifies the list of active defines
  13853. * @param useInstances defines if instances have to be turned on
  13854. * @param useClipPlane defines if clip plane have to be turned on
  13855. */
  13856. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  13857. /**
  13858. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  13859. * @param mesh The mesh containing the geometry data we will draw
  13860. * @param defines The defines to update
  13861. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  13862. * @param useBones Precise whether bones should be used or not (override mesh info)
  13863. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  13864. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  13865. * @returns false if defines are considered not dirty and have not been checked
  13866. */
  13867. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  13868. /**
  13869. * Prepares the defines related to the light information passed in parameter
  13870. * @param scene The scene we are intending to draw
  13871. * @param mesh The mesh the effect is compiling for
  13872. * @param defines The defines to update
  13873. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  13874. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  13875. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  13876. * @returns true if normals will be required for the rest of the effect
  13877. */
  13878. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  13879. /**
  13880. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  13881. * that won t be acctive due to defines being turned off.
  13882. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  13883. * @param samplersList The samplers list
  13884. * @param defines The defines helping in the list generation
  13885. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  13886. */
  13887. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  13888. /**
  13889. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  13890. * @param defines The defines to update while falling back
  13891. * @param fallbacks The authorized effect fallbacks
  13892. * @param maxSimultaneousLights The maximum number of lights allowed
  13893. * @param rank the current rank of the Effect
  13894. * @returns The newly affected rank
  13895. */
  13896. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  13897. /**
  13898. * Prepares the list of attributes required for morph targets according to the effect defines.
  13899. * @param attribs The current list of supported attribs
  13900. * @param mesh The mesh to prepare the morph targets attributes for
  13901. * @param defines The current Defines of the effect
  13902. */
  13903. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  13904. /**
  13905. * Prepares the list of attributes required for bones according to the effect defines.
  13906. * @param attribs The current list of supported attribs
  13907. * @param mesh The mesh to prepare the bones attributes for
  13908. * @param defines The current Defines of the effect
  13909. * @param fallbacks The current efffect fallback strategy
  13910. */
  13911. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  13912. /**
  13913. * Prepares the list of attributes required for instances according to the effect defines.
  13914. * @param attribs The current list of supported attribs
  13915. * @param defines The current Defines of the effect
  13916. */
  13917. static PrepareAttributesForInstances(attribs: string[], defines: any): void;
  13918. /**
  13919. * Binds the light shadow information to the effect for the given mesh.
  13920. * @param light The light containing the generator
  13921. * @param scene The scene the lights belongs to
  13922. * @param mesh The mesh we are binding the information to render
  13923. * @param lightIndex The light index in the effect used to render the mesh
  13924. * @param effect The effect we are binding the data to
  13925. */
  13926. static BindLightShadow(light: Light, scene: Scene, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  13927. /**
  13928. * Binds the light information to the effect.
  13929. * @param light The light containing the generator
  13930. * @param effect The effect we are binding the data to
  13931. * @param lightIndex The light index in the effect used to render
  13932. */
  13933. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  13934. /**
  13935. * Binds the lights information from the scene to the effect for the given mesh.
  13936. * @param scene The scene the lights belongs to
  13937. * @param mesh The mesh we are binding the information to render
  13938. * @param effect The effect we are binding the data to
  13939. * @param defines The generated defines for the effect
  13940. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  13941. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  13942. */
  13943. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  13944. /**
  13945. * Binds the fog information from the scene to the effect for the given mesh.
  13946. * @param scene The scene the lights belongs to
  13947. * @param mesh The mesh we are binding the information to render
  13948. * @param effect The effect we are binding the data to
  13949. */
  13950. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect): void;
  13951. /**
  13952. * Binds the bones information from the mesh to the effect.
  13953. * @param mesh The mesh we are binding the information to render
  13954. * @param effect The effect we are binding the data to
  13955. */
  13956. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  13957. /**
  13958. * Binds the morph targets information from the mesh to the effect.
  13959. * @param abstractMesh The mesh we are binding the information to render
  13960. * @param effect The effect we are binding the data to
  13961. */
  13962. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  13963. /**
  13964. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  13965. * @param defines The generated defines used in the effect
  13966. * @param effect The effect we are binding the data to
  13967. * @param scene The scene we are willing to render with logarithmic scale for
  13968. */
  13969. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  13970. /**
  13971. * Binds the clip plane information from the scene to the effect.
  13972. * @param scene The scene the clip plane information are extracted from
  13973. * @param effect The effect we are binding the data to
  13974. */
  13975. static BindClipPlane(effect: Effect, scene: Scene): void;
  13976. }
  13977. }
  13978. declare module BABYLON {
  13979. class MultiMaterial extends Material {
  13980. private _subMaterials;
  13981. subMaterials: Nullable<Material>[];
  13982. constructor(name: string, scene: Scene);
  13983. private _hookArray(array);
  13984. getSubMaterial(index: number): Nullable<Material>;
  13985. getActiveTextures(): BaseTexture[];
  13986. getClassName(): string;
  13987. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  13988. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  13989. serialize(): any;
  13990. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  13991. }
  13992. }
  13993. declare module BABYLON {
  13994. class PushMaterial extends Material {
  13995. protected _activeEffect: Effect;
  13996. protected _normalMatrix: Matrix;
  13997. constructor(name: string, scene: Scene);
  13998. getEffect(): Effect;
  13999. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  14000. /**
  14001. * Binds the given world matrix to the active effect
  14002. *
  14003. * @param world the matrix to bind
  14004. */
  14005. bindOnlyWorldMatrix(world: Matrix): void;
  14006. /**
  14007. * Binds the given normal matrix to the active effect
  14008. *
  14009. * @param normalMatrix the matrix to bind
  14010. */
  14011. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  14012. bind(world: Matrix, mesh?: Mesh): void;
  14013. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  14014. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  14015. }
  14016. }
  14017. declare module BABYLON {
  14018. class ShaderMaterial extends Material {
  14019. private _shaderPath;
  14020. private _options;
  14021. private _textures;
  14022. private _textureArrays;
  14023. private _floats;
  14024. private _ints;
  14025. private _floatsArrays;
  14026. private _colors3;
  14027. private _colors3Arrays;
  14028. private _colors4;
  14029. private _vectors2;
  14030. private _vectors3;
  14031. private _vectors4;
  14032. private _matrices;
  14033. private _matrices3x3;
  14034. private _matrices2x2;
  14035. private _vectors2Arrays;
  14036. private _vectors3Arrays;
  14037. private _cachedWorldViewMatrix;
  14038. private _renderId;
  14039. constructor(name: string, scene: Scene, shaderPath: any, options: any);
  14040. getClassName(): string;
  14041. needAlphaBlending(): boolean;
  14042. needAlphaTesting(): boolean;
  14043. private _checkUniform(uniformName);
  14044. setTexture(name: string, texture: Texture): ShaderMaterial;
  14045. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  14046. setFloat(name: string, value: number): ShaderMaterial;
  14047. setInt(name: string, value: number): ShaderMaterial;
  14048. setFloats(name: string, value: number[]): ShaderMaterial;
  14049. setColor3(name: string, value: Color3): ShaderMaterial;
  14050. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  14051. setColor4(name: string, value: Color4): ShaderMaterial;
  14052. setVector2(name: string, value: Vector2): ShaderMaterial;
  14053. setVector3(name: string, value: Vector3): ShaderMaterial;
  14054. setVector4(name: string, value: Vector4): ShaderMaterial;
  14055. setMatrix(name: string, value: Matrix): ShaderMaterial;
  14056. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  14057. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  14058. setArray2(name: string, value: number[]): ShaderMaterial;
  14059. setArray3(name: string, value: number[]): ShaderMaterial;
  14060. private _checkCache(scene, mesh?, useInstances?);
  14061. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  14062. bindOnlyWorldMatrix(world: Matrix): void;
  14063. bind(world: Matrix, mesh?: Mesh): void;
  14064. getActiveTextures(): BaseTexture[];
  14065. hasTexture(texture: BaseTexture): boolean;
  14066. clone(name: string): ShaderMaterial;
  14067. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  14068. serialize(): any;
  14069. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  14070. }
  14071. }
  14072. declare module BABYLON {
  14073. /** @hidden */
  14074. class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  14075. MAINUV1: boolean;
  14076. MAINUV2: boolean;
  14077. DIFFUSE: boolean;
  14078. DIFFUSEDIRECTUV: number;
  14079. AMBIENT: boolean;
  14080. AMBIENTDIRECTUV: number;
  14081. OPACITY: boolean;
  14082. OPACITYDIRECTUV: number;
  14083. OPACITYRGB: boolean;
  14084. REFLECTION: boolean;
  14085. EMISSIVE: boolean;
  14086. EMISSIVEDIRECTUV: number;
  14087. SPECULAR: boolean;
  14088. SPECULARDIRECTUV: number;
  14089. BUMP: boolean;
  14090. BUMPDIRECTUV: number;
  14091. PARALLAX: boolean;
  14092. PARALLAXOCCLUSION: boolean;
  14093. SPECULAROVERALPHA: boolean;
  14094. CLIPPLANE: boolean;
  14095. ALPHATEST: boolean;
  14096. DEPTHPREPASS: boolean;
  14097. ALPHAFROMDIFFUSE: boolean;
  14098. POINTSIZE: boolean;
  14099. FOG: boolean;
  14100. SPECULARTERM: boolean;
  14101. DIFFUSEFRESNEL: boolean;
  14102. OPACITYFRESNEL: boolean;
  14103. REFLECTIONFRESNEL: boolean;
  14104. REFRACTIONFRESNEL: boolean;
  14105. EMISSIVEFRESNEL: boolean;
  14106. FRESNEL: boolean;
  14107. NORMAL: boolean;
  14108. UV1: boolean;
  14109. UV2: boolean;
  14110. VERTEXCOLOR: boolean;
  14111. VERTEXALPHA: boolean;
  14112. NUM_BONE_INFLUENCERS: number;
  14113. BonesPerMesh: number;
  14114. INSTANCES: boolean;
  14115. GLOSSINESS: boolean;
  14116. ROUGHNESS: boolean;
  14117. EMISSIVEASILLUMINATION: boolean;
  14118. LINKEMISSIVEWITHDIFFUSE: boolean;
  14119. REFLECTIONFRESNELFROMSPECULAR: boolean;
  14120. LIGHTMAP: boolean;
  14121. LIGHTMAPDIRECTUV: number;
  14122. OBJECTSPACE_NORMALMAP: boolean;
  14123. USELIGHTMAPASSHADOWMAP: boolean;
  14124. REFLECTIONMAP_3D: boolean;
  14125. REFLECTIONMAP_SPHERICAL: boolean;
  14126. REFLECTIONMAP_PLANAR: boolean;
  14127. REFLECTIONMAP_CUBIC: boolean;
  14128. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  14129. REFLECTIONMAP_PROJECTION: boolean;
  14130. REFLECTIONMAP_SKYBOX: boolean;
  14131. REFLECTIONMAP_EXPLICIT: boolean;
  14132. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  14133. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  14134. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  14135. INVERTCUBICMAP: boolean;
  14136. LOGARITHMICDEPTH: boolean;
  14137. REFRACTION: boolean;
  14138. REFRACTIONMAP_3D: boolean;
  14139. REFLECTIONOVERALPHA: boolean;
  14140. TWOSIDEDLIGHTING: boolean;
  14141. SHADOWFLOAT: boolean;
  14142. MORPHTARGETS: boolean;
  14143. MORPHTARGETS_NORMAL: boolean;
  14144. MORPHTARGETS_TANGENT: boolean;
  14145. NUM_MORPH_INFLUENCERS: number;
  14146. NONUNIFORMSCALING: boolean;
  14147. PREMULTIPLYALPHA: boolean;
  14148. IMAGEPROCESSING: boolean;
  14149. VIGNETTE: boolean;
  14150. VIGNETTEBLENDMODEMULTIPLY: boolean;
  14151. VIGNETTEBLENDMODEOPAQUE: boolean;
  14152. TONEMAPPING: boolean;
  14153. CONTRAST: boolean;
  14154. COLORCURVES: boolean;
  14155. COLORGRADING: boolean;
  14156. COLORGRADING3D: boolean;
  14157. SAMPLER3DGREENDEPTH: boolean;
  14158. SAMPLER3DBGRMAP: boolean;
  14159. IMAGEPROCESSINGPOSTPROCESS: boolean;
  14160. /**
  14161. * If the reflection texture on this material is in linear color space
  14162. * @hidden
  14163. */
  14164. IS_REFLECTION_LINEAR: boolean;
  14165. /**
  14166. * If the refraction texture on this material is in linear color space
  14167. * @hidden
  14168. */
  14169. IS_REFRACTION_LINEAR: boolean;
  14170. EXPOSURE: boolean;
  14171. constructor();
  14172. setReflectionMode(modeToEnable: string): void;
  14173. }
  14174. class StandardMaterial extends PushMaterial {
  14175. private _diffuseTexture;
  14176. diffuseTexture: Nullable<BaseTexture>;
  14177. private _ambientTexture;
  14178. ambientTexture: Nullable<BaseTexture>;
  14179. private _opacityTexture;
  14180. opacityTexture: Nullable<BaseTexture>;
  14181. private _reflectionTexture;
  14182. reflectionTexture: Nullable<BaseTexture>;
  14183. private _emissiveTexture;
  14184. emissiveTexture: Nullable<BaseTexture>;
  14185. private _specularTexture;
  14186. specularTexture: Nullable<BaseTexture>;
  14187. private _bumpTexture;
  14188. bumpTexture: Nullable<BaseTexture>;
  14189. private _lightmapTexture;
  14190. lightmapTexture: Nullable<BaseTexture>;
  14191. private _refractionTexture;
  14192. refractionTexture: Nullable<BaseTexture>;
  14193. ambientColor: Color3;
  14194. diffuseColor: Color3;
  14195. specularColor: Color3;
  14196. emissiveColor: Color3;
  14197. specularPower: number;
  14198. private _useAlphaFromDiffuseTexture;
  14199. useAlphaFromDiffuseTexture: boolean;
  14200. private _useEmissiveAsIllumination;
  14201. useEmissiveAsIllumination: boolean;
  14202. private _linkEmissiveWithDiffuse;
  14203. linkEmissiveWithDiffuse: boolean;
  14204. private _useSpecularOverAlpha;
  14205. useSpecularOverAlpha: boolean;
  14206. private _useReflectionOverAlpha;
  14207. useReflectionOverAlpha: boolean;
  14208. private _disableLighting;
  14209. disableLighting: boolean;
  14210. private _useObjectSpaceNormalMap;
  14211. /**
  14212. * Allows using an object space normal map (instead of tangent space).
  14213. */
  14214. useObjectSpaceNormalMap: boolean;
  14215. private _useParallax;
  14216. useParallax: boolean;
  14217. private _useParallaxOcclusion;
  14218. useParallaxOcclusion: boolean;
  14219. parallaxScaleBias: number;
  14220. private _roughness;
  14221. roughness: number;
  14222. indexOfRefraction: number;
  14223. invertRefractionY: boolean;
  14224. /**
  14225. * Defines the alpha limits in alpha test mode
  14226. */
  14227. alphaCutOff: number;
  14228. private _useLightmapAsShadowmap;
  14229. useLightmapAsShadowmap: boolean;
  14230. private _diffuseFresnelParameters;
  14231. diffuseFresnelParameters: FresnelParameters;
  14232. private _opacityFresnelParameters;
  14233. opacityFresnelParameters: FresnelParameters;
  14234. private _reflectionFresnelParameters;
  14235. reflectionFresnelParameters: FresnelParameters;
  14236. private _refractionFresnelParameters;
  14237. refractionFresnelParameters: FresnelParameters;
  14238. private _emissiveFresnelParameters;
  14239. emissiveFresnelParameters: FresnelParameters;
  14240. private _useReflectionFresnelFromSpecular;
  14241. useReflectionFresnelFromSpecular: boolean;
  14242. private _useGlossinessFromSpecularMapAlpha;
  14243. useGlossinessFromSpecularMapAlpha: boolean;
  14244. private _maxSimultaneousLights;
  14245. maxSimultaneousLights: number;
  14246. /**
  14247. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  14248. */
  14249. private _invertNormalMapX;
  14250. invertNormalMapX: boolean;
  14251. /**
  14252. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  14253. */
  14254. private _invertNormalMapY;
  14255. invertNormalMapY: boolean;
  14256. /**
  14257. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  14258. */
  14259. private _twoSidedLighting;
  14260. twoSidedLighting: boolean;
  14261. /**
  14262. * Default configuration related to image processing available in the standard Material.
  14263. */
  14264. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  14265. /**
  14266. * Gets the image processing configuration used either in this material.
  14267. */
  14268. /**
  14269. * Sets the Default image processing configuration used either in the this material.
  14270. *
  14271. * If sets to null, the scene one is in use.
  14272. */
  14273. imageProcessingConfiguration: ImageProcessingConfiguration;
  14274. /**
  14275. * Keep track of the image processing observer to allow dispose and replace.
  14276. */
  14277. private _imageProcessingObserver;
  14278. /**
  14279. * Attaches a new image processing configuration to the Standard Material.
  14280. * @param configuration
  14281. */
  14282. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  14283. /**
  14284. * Gets wether the color curves effect is enabled.
  14285. */
  14286. /**
  14287. * Sets wether the color curves effect is enabled.
  14288. */
  14289. cameraColorCurvesEnabled: boolean;
  14290. /**
  14291. * Gets wether the color grading effect is enabled.
  14292. */
  14293. /**
  14294. * Gets wether the color grading effect is enabled.
  14295. */
  14296. cameraColorGradingEnabled: boolean;
  14297. /**
  14298. * Gets wether tonemapping is enabled or not.
  14299. */
  14300. /**
  14301. * Sets wether tonemapping is enabled or not
  14302. */
  14303. cameraToneMappingEnabled: boolean;
  14304. /**
  14305. * The camera exposure used on this material.
  14306. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  14307. * This corresponds to a photographic exposure.
  14308. */
  14309. /**
  14310. * The camera exposure used on this material.
  14311. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  14312. * This corresponds to a photographic exposure.
  14313. */
  14314. cameraExposure: number;
  14315. /**
  14316. * Gets The camera contrast used on this material.
  14317. */
  14318. /**
  14319. * Sets The camera contrast used on this material.
  14320. */
  14321. cameraContrast: number;
  14322. /**
  14323. * Gets the Color Grading 2D Lookup Texture.
  14324. */
  14325. /**
  14326. * Sets the Color Grading 2D Lookup Texture.
  14327. */
  14328. cameraColorGradingTexture: Nullable<BaseTexture>;
  14329. /**
  14330. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  14331. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  14332. * 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;
  14333. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  14334. */
  14335. /**
  14336. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  14337. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  14338. * 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;
  14339. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  14340. */
  14341. cameraColorCurves: Nullable<ColorCurves>;
  14342. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  14343. protected _renderTargets: SmartArray<RenderTargetTexture>;
  14344. protected _worldViewProjectionMatrix: Matrix;
  14345. protected _globalAmbientColor: Color3;
  14346. protected _useLogarithmicDepth: boolean;
  14347. constructor(name: string, scene: Scene);
  14348. getClassName(): string;
  14349. useLogarithmicDepth: boolean;
  14350. needAlphaBlending(): boolean;
  14351. needAlphaTesting(): boolean;
  14352. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  14353. getAlphaTestTexture(): Nullable<BaseTexture>;
  14354. /**
  14355. * Child classes can use it to update shaders
  14356. */
  14357. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  14358. buildUniformLayout(): void;
  14359. unbind(): void;
  14360. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  14361. getAnimatables(): IAnimatable[];
  14362. getActiveTextures(): BaseTexture[];
  14363. hasTexture(texture: BaseTexture): boolean;
  14364. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  14365. clone(name: string): StandardMaterial;
  14366. serialize(): any;
  14367. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  14368. static _DiffuseTextureEnabled: boolean;
  14369. static DiffuseTextureEnabled: boolean;
  14370. static _AmbientTextureEnabled: boolean;
  14371. static AmbientTextureEnabled: boolean;
  14372. static _OpacityTextureEnabled: boolean;
  14373. static OpacityTextureEnabled: boolean;
  14374. static _ReflectionTextureEnabled: boolean;
  14375. static ReflectionTextureEnabled: boolean;
  14376. static _EmissiveTextureEnabled: boolean;
  14377. static EmissiveTextureEnabled: boolean;
  14378. static _SpecularTextureEnabled: boolean;
  14379. static SpecularTextureEnabled: boolean;
  14380. static _BumpTextureEnabled: boolean;
  14381. static BumpTextureEnabled: boolean;
  14382. static _LightmapTextureEnabled: boolean;
  14383. static LightmapTextureEnabled: boolean;
  14384. static _RefractionTextureEnabled: boolean;
  14385. static RefractionTextureEnabled: boolean;
  14386. static _ColorGradingTextureEnabled: boolean;
  14387. static ColorGradingTextureEnabled: boolean;
  14388. static _FresnelEnabled: boolean;
  14389. static FresnelEnabled: boolean;
  14390. }
  14391. }
  14392. declare module BABYLON {
  14393. class UniformBuffer {
  14394. private _engine;
  14395. private _buffer;
  14396. private _data;
  14397. private _bufferData;
  14398. private _dynamic?;
  14399. private _uniformLocations;
  14400. private _uniformSizes;
  14401. private _uniformLocationPointer;
  14402. private _needSync;
  14403. private _noUBO;
  14404. private _currentEffect;
  14405. private static _MAX_UNIFORM_SIZE;
  14406. private static _tempBuffer;
  14407. /**
  14408. * Wrapper for updateUniform.
  14409. * @method updateMatrix3x3
  14410. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  14411. * @param {Float32Array} matrix
  14412. */
  14413. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  14414. /**
  14415. * Wrapper for updateUniform.
  14416. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  14417. * @param {Float32Array} matrix
  14418. */
  14419. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  14420. /**
  14421. * Wrapper for updateUniform.
  14422. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  14423. * @param {number} x
  14424. */
  14425. updateFloat: (name: string, x: number) => void;
  14426. /**
  14427. * Wrapper for updateUniform.
  14428. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  14429. * @param {number} x
  14430. * @param {number} y
  14431. * @param {string} [suffix] Suffix to add to the uniform name.
  14432. */
  14433. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  14434. /**
  14435. * Wrapper for updateUniform.
  14436. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  14437. * @param {number} x
  14438. * @param {number} y
  14439. * @param {number} z
  14440. * @param {string} [suffix] Suffix to add to the uniform name.
  14441. */
  14442. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  14443. /**
  14444. * Wrapper for updateUniform.
  14445. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  14446. * @param {number} x
  14447. * @param {number} y
  14448. * @param {number} z
  14449. * @param {number} w
  14450. * @param {string} [suffix] Suffix to add to the uniform name.
  14451. */
  14452. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  14453. /**
  14454. * Wrapper for updateUniform.
  14455. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  14456. * @param {Matrix} A 4x4 matrix.
  14457. */
  14458. updateMatrix: (name: string, mat: Matrix) => void;
  14459. /**
  14460. * Wrapper for updateUniform.
  14461. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  14462. * @param {Vector3} vector
  14463. */
  14464. updateVector3: (name: string, vector: Vector3) => void;
  14465. /**
  14466. * Wrapper for updateUniform.
  14467. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  14468. * @param {Vector4} vector
  14469. */
  14470. updateVector4: (name: string, vector: Vector4) => void;
  14471. /**
  14472. * Wrapper for updateUniform.
  14473. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  14474. * @param {Color3} color
  14475. * @param {string} [suffix] Suffix to add to the uniform name.
  14476. */
  14477. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  14478. /**
  14479. * Wrapper for updateUniform.
  14480. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  14481. * @param {Color3} color
  14482. * @param {number} alpha
  14483. * @param {string} [suffix] Suffix to add to the uniform name.
  14484. */
  14485. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  14486. /**
  14487. * Uniform buffer objects.
  14488. *
  14489. * Handles blocks of uniform on the GPU.
  14490. *
  14491. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  14492. *
  14493. * For more information, please refer to :
  14494. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  14495. */
  14496. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  14497. /**
  14498. * Indicates if the buffer is using the WebGL2 UBO implementation,
  14499. * or just falling back on setUniformXXX calls.
  14500. */
  14501. readonly useUbo: boolean;
  14502. /**
  14503. * Indicates if the WebGL underlying uniform buffer is in sync
  14504. * with the javascript cache data.
  14505. */
  14506. readonly isSync: boolean;
  14507. /**
  14508. * Indicates if the WebGL underlying uniform buffer is dynamic.
  14509. * Also, a dynamic UniformBuffer will disable cache verification and always
  14510. * update the underlying WebGL uniform buffer to the GPU.
  14511. */
  14512. isDynamic(): boolean;
  14513. /**
  14514. * The data cache on JS side.
  14515. */
  14516. getData(): Float32Array;
  14517. /**
  14518. * The underlying WebGL Uniform buffer.
  14519. */
  14520. getBuffer(): Nullable<WebGLBuffer>;
  14521. /**
  14522. * std140 layout specifies how to align data within an UBO structure.
  14523. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  14524. * for specs.
  14525. */
  14526. private _fillAlignment(size);
  14527. /**
  14528. * Adds an uniform in the buffer.
  14529. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  14530. * for the layout to be correct !
  14531. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  14532. * @param {number|number[]} size Data size, or data directly.
  14533. */
  14534. addUniform(name: string, size: number | number[]): void;
  14535. /**
  14536. * Wrapper for addUniform.
  14537. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  14538. * @param {Matrix} mat A 4x4 matrix.
  14539. */
  14540. addMatrix(name: string, mat: Matrix): void;
  14541. /**
  14542. * Wrapper for addUniform.
  14543. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  14544. * @param {number} x
  14545. * @param {number} y
  14546. */
  14547. addFloat2(name: string, x: number, y: number): void;
  14548. /**
  14549. * Wrapper for addUniform.
  14550. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  14551. * @param {number} x
  14552. * @param {number} y
  14553. * @param {number} z
  14554. */
  14555. addFloat3(name: string, x: number, y: number, z: number): void;
  14556. /**
  14557. * Wrapper for addUniform.
  14558. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  14559. * @param {Color3} color
  14560. */
  14561. addColor3(name: string, color: Color3): void;
  14562. /**
  14563. * Wrapper for addUniform.
  14564. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  14565. * @param {Color3} color
  14566. * @param {number} alpha
  14567. */
  14568. addColor4(name: string, color: Color3, alpha: number): void;
  14569. /**
  14570. * Wrapper for addUniform.
  14571. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  14572. * @param {Vector3} vector
  14573. */
  14574. addVector3(name: string, vector: Vector3): void;
  14575. /**
  14576. * Wrapper for addUniform.
  14577. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  14578. */
  14579. addMatrix3x3(name: string): void;
  14580. /**
  14581. * Wrapper for addUniform.
  14582. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  14583. */
  14584. addMatrix2x2(name: string): void;
  14585. /**
  14586. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  14587. */
  14588. create(): void;
  14589. _rebuild(): void;
  14590. /**
  14591. * Updates the WebGL Uniform Buffer on the GPU.
  14592. * If the `dynamic` flag is set to true, no cache comparison is done.
  14593. * Otherwise, the buffer will be updated only if the cache differs.
  14594. */
  14595. update(): void;
  14596. /**
  14597. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  14598. * @param {string} uniformName Name of the uniform, as used in the uniform block in the shader.
  14599. * @param {number[]|Float32Array} data Flattened data
  14600. * @param {number} size Size of the data.
  14601. */
  14602. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  14603. private _updateMatrix3x3ForUniform(name, matrix);
  14604. private _updateMatrix3x3ForEffect(name, matrix);
  14605. private _updateMatrix2x2ForEffect(name, matrix);
  14606. private _updateMatrix2x2ForUniform(name, matrix);
  14607. private _updateFloatForEffect(name, x);
  14608. private _updateFloatForUniform(name, x);
  14609. private _updateFloat2ForEffect(name, x, y, suffix?);
  14610. private _updateFloat2ForUniform(name, x, y, suffix?);
  14611. private _updateFloat3ForEffect(name, x, y, z, suffix?);
  14612. private _updateFloat3ForUniform(name, x, y, z, suffix?);
  14613. private _updateFloat4ForEffect(name, x, y, z, w, suffix?);
  14614. private _updateFloat4ForUniform(name, x, y, z, w, suffix?);
  14615. private _updateMatrixForEffect(name, mat);
  14616. private _updateMatrixForUniform(name, mat);
  14617. private _updateVector3ForEffect(name, vector);
  14618. private _updateVector3ForUniform(name, vector);
  14619. private _updateVector4ForEffect(name, vector);
  14620. private _updateVector4ForUniform(name, vector);
  14621. private _updateColor3ForEffect(name, color, suffix?);
  14622. private _updateColor3ForUniform(name, color, suffix?);
  14623. private _updateColor4ForEffect(name, color, alpha, suffix?);
  14624. private _updateColor4ForUniform(name, color, alpha, suffix?);
  14625. /**
  14626. * Sets a sampler uniform on the effect.
  14627. * @param {string} name Name of the sampler.
  14628. * @param {Texture} texture
  14629. */
  14630. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  14631. /**
  14632. * Directly updates the value of the uniform in the cache AND on the GPU.
  14633. * @param {string} uniformName Name of the uniform, as used in the uniform block in the shader.
  14634. * @param {number[]|Float32Array} data Flattened data
  14635. */
  14636. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  14637. /**
  14638. * Binds this uniform buffer to an effect.
  14639. * @param {Effect} effect
  14640. * @param {string} name Name of the uniform block in the shader.
  14641. */
  14642. bindToEffect(effect: Effect, name: string): void;
  14643. /**
  14644. * Disposes the uniform buffer.
  14645. */
  14646. dispose(): void;
  14647. }
  14648. }
  14649. declare module BABYLON {
  14650. class Scalar {
  14651. /**
  14652. * Two pi constants convenient for computation.
  14653. */
  14654. static TwoPi: number;
  14655. /**
  14656. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  14657. */
  14658. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  14659. /**
  14660. * Returns a string : the upper case translation of the number i to hexadecimal.
  14661. */
  14662. static ToHex(i: number): string;
  14663. /**
  14664. * Returns -1 if value is negative and +1 is value is positive.
  14665. * Returns the value itself if it's equal to zero.
  14666. */
  14667. static Sign(value: number): number;
  14668. /**
  14669. * Returns the value itself if it's between min and max.
  14670. * Returns min if the value is lower than min.
  14671. * Returns max if the value is greater than max.
  14672. */
  14673. static Clamp(value: number, min?: number, max?: number): number;
  14674. /**
  14675. * Returns the log2 of value.
  14676. */
  14677. static Log2(value: number): number;
  14678. /**
  14679. * Loops the value, so that it is never larger than length and never smaller than 0.
  14680. *
  14681. * This is similar to the modulo operator but it works with floating point numbers.
  14682. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  14683. * With t = 5 and length = 2.5, the result would be 0.0.
  14684. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  14685. */
  14686. static Repeat(value: number, length: number): number;
  14687. /**
  14688. * Normalize the value between 0.0 and 1.0 using min and max values
  14689. */
  14690. static Normalize(value: number, min: number, max: number): number;
  14691. /**
  14692. * Denormalize the value from 0.0 and 1.0 using min and max values
  14693. */
  14694. static Denormalize(normalized: number, min: number, max: number): number;
  14695. /**
  14696. * Calculates the shortest difference between two given angles given in degrees.
  14697. */
  14698. static DeltaAngle(current: number, target: number): number;
  14699. /**
  14700. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  14701. *
  14702. * The returned value will move back and forth between 0 and length
  14703. */
  14704. static PingPong(tx: number, length: number): number;
  14705. /**
  14706. * Interpolates between min and max with smoothing at the limits.
  14707. *
  14708. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  14709. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  14710. */
  14711. static SmoothStep(from: number, to: number, tx: number): number;
  14712. /**
  14713. * Moves a value current towards target.
  14714. *
  14715. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  14716. * Negative values of maxDelta pushes the value away from target.
  14717. */
  14718. static MoveTowards(current: number, target: number, maxDelta: number): number;
  14719. /**
  14720. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  14721. *
  14722. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  14723. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  14724. */
  14725. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  14726. /**
  14727. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  14728. */
  14729. static Lerp(start: number, end: number, amount: number): number;
  14730. /**
  14731. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  14732. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  14733. */
  14734. static LerpAngle(start: number, end: number, amount: number): number;
  14735. /**
  14736. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  14737. */
  14738. static InverseLerp(a: number, b: number, value: number): number;
  14739. /**
  14740. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  14741. */
  14742. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  14743. /**
  14744. * Returns a random float number between and min and max values
  14745. */
  14746. static RandomRange(min: number, max: number): number;
  14747. /**
  14748. * This function returns percentage of a number in a given range.
  14749. *
  14750. * RangeToPercent(40,20,60) will return 0.5 (50%)
  14751. * RangeToPercent(34,0,100) will return 0.34 (34%)
  14752. */
  14753. static RangeToPercent(number: number, min: number, max: number): number;
  14754. /**
  14755. * This function returns number that corresponds to the percentage in a given range.
  14756. *
  14757. * PercentToRange(0.34,0,100) will return 34.
  14758. */
  14759. static PercentToRange(percent: number, min: number, max: number): number;
  14760. /**
  14761. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  14762. * @param angle The angle to normalize in radian.
  14763. * @return The converted angle.
  14764. */
  14765. static NormalizeRadians(angle: number): number;
  14766. }
  14767. }
  14768. declare module BABYLON {
  14769. const ToGammaSpace: number;
  14770. const ToLinearSpace = 2.2;
  14771. const Epsilon = 0.001;
  14772. /**
  14773. * Class used to hold a RBG color
  14774. */
  14775. class Color3 {
  14776. /**
  14777. * Defines the red component (between 0 and 1, default is 0)
  14778. */
  14779. r: number;
  14780. /**
  14781. * Defines the green component (between 0 and 1, default is 0)
  14782. */
  14783. g: number;
  14784. /**
  14785. * Defines the blue component (between 0 and 1, default is 0)
  14786. */
  14787. b: number;
  14788. /**
  14789. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  14790. * @param r defines the red component (between 0 and 1, default is 0)
  14791. * @param g defines the green component (between 0 and 1, default is 0)
  14792. * @param b defines the blue component (between 0 and 1, default is 0)
  14793. */
  14794. constructor(
  14795. /**
  14796. * Defines the red component (between 0 and 1, default is 0)
  14797. */
  14798. r?: number,
  14799. /**
  14800. * Defines the green component (between 0 and 1, default is 0)
  14801. */
  14802. g?: number,
  14803. /**
  14804. * Defines the blue component (between 0 and 1, default is 0)
  14805. */
  14806. b?: number);
  14807. /**
  14808. * Creates a string with the Color3 current values
  14809. * @returns the string representation of the Color3 object
  14810. */
  14811. toString(): string;
  14812. /**
  14813. * Returns the string "Color3"
  14814. * @returns "Color3"
  14815. */
  14816. getClassName(): string;
  14817. /**
  14818. * Compute the Color3 hash code
  14819. * @returns an unique number that can be used to hash Color3 objects
  14820. */
  14821. getHashCode(): number;
  14822. /**
  14823. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  14824. * @param array defines the array where to store the r,g,b components
  14825. * @param index defines an optional index in the target array to define where to start storing values
  14826. * @returns the current Color3 object
  14827. */
  14828. toArray(array: FloatArray, index?: number): Color3;
  14829. /**
  14830. * Returns a new {BABYLON.Color4} object from the current Color3 and the given alpha
  14831. * @param alpha defines the alpha component on the new {BABYLON.Color4} object (default is 1)
  14832. * @returns a new {BABYLON.Color4} object
  14833. */
  14834. toColor4(alpha?: number): Color4;
  14835. /**
  14836. * Returns a new array populated with 3 numeric elements : red, green and blue values
  14837. * @returns the new array
  14838. */
  14839. asArray(): number[];
  14840. /**
  14841. * Returns the luminance value
  14842. * @returns a float value
  14843. */
  14844. toLuminance(): number;
  14845. /**
  14846. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  14847. * @param otherColor defines the second operand
  14848. * @returns the new Color3 object
  14849. */
  14850. multiply(otherColor: Color3): Color3;
  14851. /**
  14852. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  14853. * @param otherColor defines the second operand
  14854. * @param result defines the Color3 object where to store the result
  14855. * @returns the current Color3
  14856. */
  14857. multiplyToRef(otherColor: Color3, result: Color3): Color3;
  14858. /**
  14859. * Determines equality between Color3 objects
  14860. * @param otherColor defines the second operand
  14861. * @returns true if the rgb values are equal to the given ones
  14862. */
  14863. equals(otherColor: Color3): boolean;
  14864. /**
  14865. * Determines equality between the current Color3 object and a set of r,b,g values
  14866. * @param r defines the red component to check
  14867. * @param g defines the green component to check
  14868. * @param b defines the blue component to check
  14869. * @returns true if the rgb values are equal to the given ones
  14870. */
  14871. equalsFloats(r: number, g: number, b: number): boolean;
  14872. /**
  14873. * Multiplies in place each rgb value by scale
  14874. * @param scale defines the scaling factor
  14875. * @returns the updated Color3
  14876. */
  14877. scale(scale: number): Color3;
  14878. /**
  14879. * Multiplies the rgb values by scale and stores the result into "result"
  14880. * @param scale defines the scaling factor
  14881. * @param result defines the Color3 object where to store the result
  14882. * @returns the unmodified current Color3
  14883. */
  14884. scaleToRef(scale: number, result: Color3): Color3;
  14885. /**
  14886. * Scale the current Color3 values by a factor and add the result to a given Color3
  14887. * @param scale defines the scale factor
  14888. * @param result defines color to store the result into
  14889. * @returns the unmodified current Color3
  14890. */
  14891. scaleAndAddToRef(scale: number, result: Color3): Color3;
  14892. /**
  14893. * Clamps the rgb values by the min and max values and stores the result into "result"
  14894. * @param min defines minimum clamping value (default is 0)
  14895. * @param max defines maximum clamping value (default is 1)
  14896. * @param result defines color to store the result into
  14897. * @returns the original Color3
  14898. */
  14899. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  14900. /**
  14901. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  14902. * @param otherColor defines the second operand
  14903. * @returns the new Color3
  14904. */
  14905. add(otherColor: Color3): Color3;
  14906. /**
  14907. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  14908. * @param otherColor defines the second operand
  14909. * @param result defines Color3 object to store the result into
  14910. * @returns the unmodified current Color3
  14911. */
  14912. addToRef(otherColor: Color3, result: Color3): Color3;
  14913. /**
  14914. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  14915. * @param otherColor defines the second operand
  14916. * @returns the new Color3
  14917. */
  14918. subtract(otherColor: Color3): Color3;
  14919. /**
  14920. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  14921. * @param otherColor defines the second operand
  14922. * @param result defines Color3 object to store the result into
  14923. * @returns the unmodified current Color3
  14924. */
  14925. subtractToRef(otherColor: Color3, result: Color3): Color3;
  14926. /**
  14927. * Copy the current object
  14928. * @returns a new Color3 copied the current one
  14929. */
  14930. clone(): Color3;
  14931. /**
  14932. * Copies the rgb values from the source in the current Color3
  14933. * @param source defines the source Color3 object
  14934. * @returns the updated Color3 object
  14935. */
  14936. copyFrom(source: Color3): Color3;
  14937. /**
  14938. * Updates the Color3 rgb values from the given floats
  14939. * @param r defines the red component to read from
  14940. * @param g defines the green component to read from
  14941. * @param b defines the blue component to read from
  14942. * @returns the current Color3 object
  14943. */
  14944. copyFromFloats(r: number, g: number, b: number): Color3;
  14945. /**
  14946. * Updates the Color3 rgb values from the given floats
  14947. * @param r defines the red component to read from
  14948. * @param g defines the green component to read from
  14949. * @param b defines the blue component to read from
  14950. * @returns the current Color3 object
  14951. */
  14952. set(r: number, g: number, b: number): Color3;
  14953. /**
  14954. * Compute the Color3 hexadecimal code as a string
  14955. * @returns a string containing the hexadecimal representation of the Color3 object
  14956. */
  14957. toHexString(): string;
  14958. /**
  14959. * Computes a new Color3 converted from the current one to linear space
  14960. * @returns a new Color3 object
  14961. */
  14962. toLinearSpace(): Color3;
  14963. /**
  14964. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  14965. * @param convertedColor defines the Color3 object where to store the linear space version
  14966. * @returns the unmodified Color3
  14967. */
  14968. toLinearSpaceToRef(convertedColor: Color3): Color3;
  14969. /**
  14970. * Computes a new Color3 converted from the current one to gamma space
  14971. * @returns a new Color3 object
  14972. */
  14973. toGammaSpace(): Color3;
  14974. /**
  14975. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  14976. * @param convertedColor defines the Color3 object where to store the gamma space version
  14977. * @returns the unmodified Color3
  14978. */
  14979. toGammaSpaceToRef(convertedColor: Color3): Color3;
  14980. /**
  14981. * Creates a new Color3 from the string containing valid hexadecimal values
  14982. * @param hex defines a string containing valid hexadecimal values
  14983. * @returns a new Color3 object
  14984. */
  14985. static FromHexString(hex: string): Color3;
  14986. /**
  14987. * Creates a new Vector3 from the starting index of the given array
  14988. * @param array defines the source array
  14989. * @param offset defines an offset in the source array
  14990. * @returns a new Color3 object
  14991. */
  14992. static FromArray(array: ArrayLike<number>, offset?: number): Color3;
  14993. /**
  14994. * Creates a new Color3 from integer values (< 256)
  14995. * @param r defines the red component to read from (value between 0 and 255)
  14996. * @param g defines the green component to read from (value between 0 and 255)
  14997. * @param b defines the blue component to read from (value between 0 and 255)
  14998. * @returns a new Color3 object
  14999. */
  15000. static FromInts(r: number, g: number, b: number): Color3;
  15001. /**
  15002. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  15003. * @param start defines the start Color3 value
  15004. * @param end defines the end Color3 value
  15005. * @param amount defines the gradient value between start and end
  15006. * @returns a new Color3 object
  15007. */
  15008. static Lerp(start: Color3, end: Color3, amount: number): Color3;
  15009. /**
  15010. * Returns a Color3 value containing a red color
  15011. * @returns a new Color3 object
  15012. */
  15013. static Red(): Color3;
  15014. /**
  15015. * Returns a Color3 value containing a green color
  15016. * @returns a new Color3 object
  15017. */
  15018. static Green(): Color3;
  15019. /**
  15020. * Returns a Color3 value containing a blue color
  15021. * @returns a new Color3 object
  15022. */
  15023. static Blue(): Color3;
  15024. /**
  15025. * Returns a Color3 value containing a black color
  15026. * @returns a new Color3 object
  15027. */
  15028. static Black(): Color3;
  15029. /**
  15030. * Returns a Color3 value containing a white color
  15031. * @returns a new Color3 object
  15032. */
  15033. static White(): Color3;
  15034. /**
  15035. * Returns a Color3 value containing a purple color
  15036. * @returns a new Color3 object
  15037. */
  15038. static Purple(): Color3;
  15039. /**
  15040. * Returns a Color3 value containing a magenta color
  15041. * @returns a new Color3 object
  15042. */
  15043. static Magenta(): Color3;
  15044. /**
  15045. * Returns a Color3 value containing a yellow color
  15046. * @returns a new Color3 object
  15047. */
  15048. static Yellow(): Color3;
  15049. /**
  15050. * Returns a Color3 value containing a gray color
  15051. * @returns a new Color3 object
  15052. */
  15053. static Gray(): Color3;
  15054. /**
  15055. * Returns a Color3 value containing a teal color
  15056. * @returns a new Color3 object
  15057. */
  15058. static Teal(): Color3;
  15059. /**
  15060. * Returns a Color3 value containing a random color
  15061. * @returns a new Color3 object
  15062. */
  15063. static Random(): Color3;
  15064. }
  15065. /**
  15066. * Class used to hold a RBGA color
  15067. */
  15068. class Color4 {
  15069. /**
  15070. * Defines the red component (between 0 and 1, default is 0)
  15071. */
  15072. r: number;
  15073. /**
  15074. * Defines the green component (between 0 and 1, default is 0)
  15075. */
  15076. g: number;
  15077. /**
  15078. * Defines the blue component (between 0 and 1, default is 0)
  15079. */
  15080. b: number;
  15081. /**
  15082. * Defines the alpha component (between 0 and 1, default is 1)
  15083. */
  15084. a: number;
  15085. /**
  15086. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  15087. * @param r defines the red component (between 0 and 1, default is 0)
  15088. * @param g defines the green component (between 0 and 1, default is 0)
  15089. * @param b defines the blue component (between 0 and 1, default is 0)
  15090. * @param a defines the alpha component (between 0 and 1, default is 1)
  15091. */
  15092. constructor(
  15093. /**
  15094. * Defines the red component (between 0 and 1, default is 0)
  15095. */
  15096. r?: number,
  15097. /**
  15098. * Defines the green component (between 0 and 1, default is 0)
  15099. */
  15100. g?: number,
  15101. /**
  15102. * Defines the blue component (between 0 and 1, default is 0)
  15103. */
  15104. b?: number,
  15105. /**
  15106. * Defines the alpha component (between 0 and 1, default is 1)
  15107. */
  15108. a?: number);
  15109. /**
  15110. * Adds in place the given Color4 values to the current Color4 object
  15111. * @param right defines the second operand
  15112. * @returns the current updated Color4 object
  15113. */
  15114. addInPlace(right: Color4): Color4;
  15115. /**
  15116. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  15117. * @returns the new array
  15118. */
  15119. asArray(): number[];
  15120. /**
  15121. * Stores from the starting index in the given array the Color4 successive values
  15122. * @param array defines the array where to store the r,g,b components
  15123. * @param index defines an optional index in the target array to define where to start storing values
  15124. * @returns the current Color4 object
  15125. */
  15126. toArray(array: number[], index?: number): Color4;
  15127. /**
  15128. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  15129. * @param right defines the second operand
  15130. * @returns a new Color4 object
  15131. */
  15132. add(right: Color4): Color4;
  15133. /**
  15134. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  15135. * @param right defines the second operand
  15136. * @returns a new Color4 object
  15137. */
  15138. subtract(right: Color4): Color4;
  15139. /**
  15140. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  15141. * @param right defines the second operand
  15142. * @param result defines the Color4 object where to store the result
  15143. * @returns the current Color4 object
  15144. */
  15145. subtractToRef(right: Color4, result: Color4): Color4;
  15146. /**
  15147. * Creates a new Color4 with the current Color4 values multiplied by scale
  15148. * @param scale defines the scaling factor to apply
  15149. * @returns a new Color4 object
  15150. */
  15151. scale(scale: number): Color4;
  15152. /**
  15153. * Multiplies the current Color4 values by scale and stores the result in "result"
  15154. * @param scale defines the scaling factor to apply
  15155. * @param result defines the Color4 object where to store the result
  15156. * @returns the current unmodified Color4
  15157. */
  15158. scaleToRef(scale: number, result: Color4): Color4;
  15159. /**
  15160. * Scale the current Color4 values by a factor and add the result to a given Color4
  15161. * @param scale defines the scale factor
  15162. * @param result defines the Color4 object where to store the result
  15163. * @returns the unmodified current Color4
  15164. */
  15165. scaleAndAddToRef(scale: number, result: Color4): Color4;
  15166. /**
  15167. * Clamps the rgb values by the min and max values and stores the result into "result"
  15168. * @param min defines minimum clamping value (default is 0)
  15169. * @param max defines maximum clamping value (default is 1)
  15170. * @param result defines color to store the result into.
  15171. * @returns the cuurent Color4
  15172. */
  15173. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  15174. /**
  15175. * Multipy an Color4 value by another and return a new Color4 object
  15176. * @param color defines the Color4 value to multiply by
  15177. * @returns a new Color4 object
  15178. */
  15179. multiply(color: Color4): Color4;
  15180. /**
  15181. * Multipy a Color4 value by another and push the result in a reference value
  15182. * @param color defines the Color4 value to multiply by
  15183. * @param result defines the Color4 to fill the result in
  15184. * @returns the result Color4
  15185. */
  15186. multiplyToRef(color: Color4, result: Color4): Color4;
  15187. /**
  15188. * Creates a string with the Color4 current values
  15189. * @returns the string representation of the Color4 object
  15190. */
  15191. toString(): string;
  15192. /**
  15193. * Returns the string "Color4"
  15194. * @returns "Color4"
  15195. */
  15196. getClassName(): string;
  15197. /**
  15198. * Compute the Color4 hash code
  15199. * @returns an unique number that can be used to hash Color4 objects
  15200. */
  15201. getHashCode(): number;
  15202. /**
  15203. * Creates a new Color4 copied from the current one
  15204. * @returns a new Color4 object
  15205. */
  15206. clone(): Color4;
  15207. /**
  15208. * Copies the given Color4 values into the current one
  15209. * @param source defines the source Color4 object
  15210. * @returns the current updated Color4 object
  15211. */
  15212. copyFrom(source: Color4): Color4;
  15213. /**
  15214. * Copies the given float values into the current one
  15215. * @param r defines the red component to read from
  15216. * @param g defines the green component to read from
  15217. * @param b defines the blue component to read from
  15218. * @param a defines the alpha component to read from
  15219. * @returns the current updated Color4 object
  15220. */
  15221. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  15222. /**
  15223. * Copies the given float values into the current one
  15224. * @param r defines the red component to read from
  15225. * @param g defines the green component to read from
  15226. * @param b defines the blue component to read from
  15227. * @param a defines the alpha component to read from
  15228. * @returns the current updated Color4 object
  15229. */
  15230. set(r: number, g: number, b: number, a: number): Color4;
  15231. /**
  15232. * Compute the Color4 hexadecimal code as a string
  15233. * @returns a string containing the hexadecimal representation of the Color4 object
  15234. */
  15235. toHexString(): string;
  15236. /**
  15237. * Computes a new Color4 converted from the current one to linear space
  15238. * @returns a new Color4 object
  15239. */
  15240. toLinearSpace(): Color4;
  15241. /**
  15242. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  15243. * @param convertedColor defines the Color4 object where to store the linear space version
  15244. * @returns the unmodified Color4
  15245. */
  15246. toLinearSpaceToRef(convertedColor: Color4): Color4;
  15247. /**
  15248. * Computes a new Color4 converted from the current one to gamma space
  15249. * @returns a new Color4 object
  15250. */
  15251. toGammaSpace(): Color4;
  15252. /**
  15253. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  15254. * @param convertedColor defines the Color4 object where to store the gamma space version
  15255. * @returns the unmodified Color4
  15256. */
  15257. toGammaSpaceToRef(convertedColor: Color4): Color4;
  15258. /**
  15259. * Creates a new Color4 from the string containing valid hexadecimal values
  15260. * @param hex defines a string containing valid hexadecimal values
  15261. * @returns a new Color4 object
  15262. */
  15263. static FromHexString(hex: string): Color4;
  15264. /**
  15265. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  15266. * @param left defines the start value
  15267. * @param right defines the end value
  15268. * @param amount defines the gradient factor
  15269. * @returns a new Color4 object
  15270. */
  15271. static Lerp(left: Color4, right: Color4, amount: number): Color4;
  15272. /**
  15273. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  15274. * @param left defines the start value
  15275. * @param right defines the end value
  15276. * @param amount defines the gradient factor
  15277. * @param result defines the Color4 object where to store data
  15278. */
  15279. static LerpToRef(left: Color4, right: Color4, amount: number, result: Color4): void;
  15280. /**
  15281. * Creates a new Color4 from the starting index element of the given array
  15282. * @param array defines the source array to read from
  15283. * @param offset defines the offset in the source array
  15284. * @returns a new Color4 object
  15285. */
  15286. static FromArray(array: ArrayLike<number>, offset?: number): Color4;
  15287. /**
  15288. * Creates a new Color3 from integer values (< 256)
  15289. * @param r defines the red component to read from (value between 0 and 255)
  15290. * @param g defines the green component to read from (value between 0 and 255)
  15291. * @param b defines the blue component to read from (value between 0 and 255)
  15292. * @param a defines the alpha component to read from (value between 0 and 255)
  15293. * @returns a new Color3 object
  15294. */
  15295. static FromInts(r: number, g: number, b: number, a: number): Color4;
  15296. /**
  15297. * Check the content of a given array and convert it to an array containing RGBA data
  15298. * If the original array was already containing count * 4 values then it is returned directly
  15299. * @param colors defines the array to check
  15300. * @param count defines the number of RGBA data to expect
  15301. * @returns an array containing count * 4 values (RGBA)
  15302. */
  15303. static CheckColors4(colors: number[], count: number): number[];
  15304. }
  15305. /**
  15306. * Class representing a vector containing 2 coordinates
  15307. */
  15308. class Vector2 {
  15309. /** defines the first coordinate */
  15310. x: number;
  15311. /** defines the second coordinate */
  15312. y: number;
  15313. /**
  15314. * Creates a new Vector2 from the given x and y coordinates
  15315. * @param x defines the first coordinate
  15316. * @param y defines the second coordinate
  15317. */
  15318. constructor(
  15319. /** defines the first coordinate */
  15320. x: number,
  15321. /** defines the second coordinate */
  15322. y: number);
  15323. /**
  15324. * Gets a string with the Vector2 coordinates
  15325. * @returns a string with the Vector2 coordinates
  15326. */
  15327. toString(): string;
  15328. /**
  15329. * Gets class name
  15330. * @returns the string "Vector2"
  15331. */
  15332. getClassName(): string;
  15333. /**
  15334. * Gets current vector hash code
  15335. * @returns the Vector2 hash code as a number
  15336. */
  15337. getHashCode(): number;
  15338. /**
  15339. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  15340. * @param array defines the source array
  15341. * @param index defines the offset in source array
  15342. * @returns the current Vector2
  15343. */
  15344. toArray(array: FloatArray, index?: number): Vector2;
  15345. /**
  15346. * Copy the current vector to an array
  15347. * @returns a new array with 2 elements: the Vector2 coordinates.
  15348. */
  15349. asArray(): number[];
  15350. /**
  15351. * Sets the Vector2 coordinates with the given Vector2 coordinates
  15352. * @param source defines the source Vector2
  15353. * @returns the current updated Vector2
  15354. */
  15355. copyFrom(source: Vector2): Vector2;
  15356. /**
  15357. * Sets the Vector2 coordinates with the given floats
  15358. * @param x defines the first coordinate
  15359. * @param y defines the second coordinate
  15360. * @returns the current updated Vector2
  15361. */
  15362. copyFromFloats(x: number, y: number): Vector2;
  15363. /**
  15364. * Sets the Vector2 coordinates with the given floats
  15365. * @param x defines the first coordinate
  15366. * @param y defines the second coordinate
  15367. * @returns the current updated Vector2
  15368. */
  15369. set(x: number, y: number): Vector2;
  15370. /**
  15371. * Add another vector with the current one
  15372. * @param otherVector defines the other vector
  15373. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  15374. */
  15375. add(otherVector: Vector2): Vector2;
  15376. /**
  15377. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  15378. * @param otherVector defines the other vector
  15379. * @param result defines the target vector
  15380. * @returns the unmodified current Vector2
  15381. */
  15382. addToRef(otherVector: Vector2, result: Vector2): Vector2;
  15383. /**
  15384. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  15385. * @param otherVector defines the other vector
  15386. * @returns the current updated Vector2
  15387. */
  15388. addInPlace(otherVector: Vector2): Vector2;
  15389. /**
  15390. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  15391. * @param otherVector defines the other vector
  15392. * @returns a new Vector2
  15393. */
  15394. addVector3(otherVector: Vector3): Vector2;
  15395. /**
  15396. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  15397. * @param otherVector defines the other vector
  15398. * @returns a new Vector2
  15399. */
  15400. subtract(otherVector: Vector2): Vector2;
  15401. /**
  15402. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  15403. * @param otherVector defines the other vector
  15404. * @param result defines the target vector
  15405. * @returns the unmodified current Vector2
  15406. */
  15407. subtractToRef(otherVector: Vector2, result: Vector2): Vector2;
  15408. /**
  15409. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  15410. * @param otherVector defines the other vector
  15411. * @returns the current updated Vector2
  15412. */
  15413. subtractInPlace(otherVector: Vector2): Vector2;
  15414. /**
  15415. * Multiplies in place the current Vector2 coordinates by the given ones
  15416. * @param otherVector defines the other vector
  15417. * @returns the current updated Vector2
  15418. */
  15419. multiplyInPlace(otherVector: Vector2): Vector2;
  15420. /**
  15421. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  15422. * @param otherVector defines the other vector
  15423. * @returns a new Vector2
  15424. */
  15425. multiply(otherVector: Vector2): Vector2;
  15426. /**
  15427. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  15428. * @param otherVector defines the other vector
  15429. * @param result defines the target vector
  15430. * @returns the unmodified current Vector2
  15431. */
  15432. multiplyToRef(otherVector: Vector2, result: Vector2): Vector2;
  15433. /**
  15434. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  15435. * @param x defines the first coordinate
  15436. * @param y defines the second coordinate
  15437. * @returns a new Vector2
  15438. */
  15439. multiplyByFloats(x: number, y: number): Vector2;
  15440. /**
  15441. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  15442. * @param otherVector defines the other vector
  15443. * @returns a new Vector2
  15444. */
  15445. divide(otherVector: Vector2): Vector2;
  15446. /**
  15447. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  15448. * @param otherVector defines the other vector
  15449. * @param result defines the target vector
  15450. * @returns the unmodified current Vector2
  15451. */
  15452. divideToRef(otherVector: Vector2, result: Vector2): Vector2;
  15453. /**
  15454. * Divides the current Vector3 coordinates by the given ones
  15455. * @param otherVector defines the other vector
  15456. * @returns the current updated Vector2
  15457. */
  15458. divideInPlace(otherVector: Vector2): Vector2;
  15459. /**
  15460. * Gets a new Vector2 with current Vector2 negated coordinates
  15461. * @returns a new Vector2
  15462. */
  15463. negate(): Vector2;
  15464. /**
  15465. * Multiply the Vector2 coordinates by scale
  15466. * @param scale defines the scaling factor
  15467. * @returns the current updated Vector2
  15468. */
  15469. scaleInPlace(scale: number): Vector2;
  15470. /**
  15471. * Returns a new Vector2 scaled by "scale" from the current Vector2
  15472. * @param scale defines the scaling factor
  15473. * @returns a new Vector2
  15474. */
  15475. scale(scale: number): Vector2;
  15476. /**
  15477. * Scale the current Vector2 values by a factor to a given Vector2
  15478. * @param scale defines the scale factor
  15479. * @param result defines the Vector2 object where to store the result
  15480. * @returns the unmodified current Vector2
  15481. */
  15482. scaleToRef(scale: number, result: Vector2): Vector2;
  15483. /**
  15484. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  15485. * @param scale defines the scale factor
  15486. * @param result defines the Vector2 object where to store the result
  15487. * @returns the unmodified current Vector2
  15488. */
  15489. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  15490. /**
  15491. * Gets a boolean if two vectors are equals
  15492. * @param otherVector defines the other vector
  15493. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  15494. */
  15495. equals(otherVector: Vector2): boolean;
  15496. /**
  15497. * Gets a boolean if two vectors are equals (using an epsilon value)
  15498. * @param otherVector defines the other vector
  15499. * @param epsilon defines the minimal distance to consider equality
  15500. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  15501. */
  15502. equalsWithEpsilon(otherVector: Vector2, epsilon?: number): boolean;
  15503. /**
  15504. * Gets the length of the vector
  15505. * @returns the vector length (float)
  15506. */
  15507. length(): number;
  15508. /**
  15509. * Gets the vector squared length
  15510. * @returns the vector squared length (float)
  15511. */
  15512. lengthSquared(): number;
  15513. /**
  15514. * Normalize the vector
  15515. * @returns the current updated Vector2
  15516. */
  15517. normalize(): Vector2;
  15518. /**
  15519. * Gets a new Vector2 copied from the Vector2
  15520. * @returns a new Vector2
  15521. */
  15522. clone(): Vector2;
  15523. /**
  15524. * Gets a new Vector2(0, 0)
  15525. * @returns a new Vector2
  15526. */
  15527. static Zero(): Vector2;
  15528. /**
  15529. * Gets a new Vector2(1, 1)
  15530. * @returns a new Vector2
  15531. */
  15532. static One(): Vector2;
  15533. /**
  15534. * Gets a new Vector2 set from the given index element of the given array
  15535. * @param array defines the data source
  15536. * @param offset defines the offset in the data source
  15537. * @returns a new Vector2
  15538. */
  15539. static FromArray(array: ArrayLike<number>, offset?: number): Vector2;
  15540. /**
  15541. * Sets "result" from the given index element of the given array
  15542. * @param array defines the data source
  15543. * @param offset defines the offset in the data source
  15544. * @param result defines the target vector
  15545. */
  15546. static FromArrayToRef(array: ArrayLike<number>, offset: number, result: Vector2): void;
  15547. /**
  15548. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  15549. * @param value1 defines 1st point of control
  15550. * @param value2 defines 2nd point of control
  15551. * @param value3 defines 3rd point of control
  15552. * @param value4 defines 4th point of control
  15553. * @param amount defines the interpolation factor
  15554. * @returns a new Vector2
  15555. */
  15556. static CatmullRom(value1: Vector2, value2: Vector2, value3: Vector2, value4: Vector2, amount: number): Vector2;
  15557. /**
  15558. * 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".
  15559. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  15560. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  15561. * @param value defines the value to clamp
  15562. * @param min defines the lower limit
  15563. * @param max defines the upper limit
  15564. * @returns a new Vector2
  15565. */
  15566. static Clamp(value: Vector2, min: Vector2, max: Vector2): Vector2;
  15567. /**
  15568. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  15569. * @param value1 defines the 1st control point
  15570. * @param tangent1 defines the outgoing tangent
  15571. * @param value2 defines the 2nd control point
  15572. * @param tangent2 defines the incoming tangent
  15573. * @param amount defines the interpolation factor
  15574. * @returns a new Vector2
  15575. */
  15576. static Hermite(value1: Vector2, tangent1: Vector2, value2: Vector2, tangent2: Vector2, amount: number): Vector2;
  15577. /**
  15578. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  15579. * @param start defines the start vector
  15580. * @param end defines the end vector
  15581. * @param amount defines the interpolation factor
  15582. * @returns a new Vector2
  15583. */
  15584. static Lerp(start: Vector2, end: Vector2, amount: number): Vector2;
  15585. /**
  15586. * Gets the dot product of the vector "left" and the vector "right"
  15587. * @param left defines first vector
  15588. * @param right defines second vector
  15589. * @returns the dot product (float)
  15590. */
  15591. static Dot(left: Vector2, right: Vector2): number;
  15592. /**
  15593. * Returns a new Vector2 equal to the normalized given vector
  15594. * @param vector defines the vector to normalize
  15595. * @returns a new Vector2
  15596. */
  15597. static Normalize(vector: Vector2): Vector2;
  15598. /**
  15599. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  15600. * @param left defines 1st vector
  15601. * @param right defines 2nd vector
  15602. * @returns a new Vector2
  15603. */
  15604. static Minimize(left: Vector2, right: Vector2): Vector2;
  15605. /**
  15606. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  15607. * @param left defines 1st vector
  15608. * @param right defines 2nd vector
  15609. * @returns a new Vector2
  15610. */
  15611. static Maximize(left: Vector2, right: Vector2): Vector2;
  15612. /**
  15613. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  15614. * @param vector defines the vector to transform
  15615. * @param transformation defines the matrix to apply
  15616. * @returns a new Vector2
  15617. */
  15618. static Transform(vector: Vector2, transformation: Matrix): Vector2;
  15619. /**
  15620. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  15621. * @param vector defines the vector to transform
  15622. * @param transformation defines the matrix to apply
  15623. * @param result defines the target vector
  15624. */
  15625. static TransformToRef(vector: Vector2, transformation: Matrix, result: Vector2): void;
  15626. /**
  15627. * Determines if a given vector is included in a triangle
  15628. * @param p defines the vector to test
  15629. * @param p0 defines 1st triangle point
  15630. * @param p1 defines 2nd triangle point
  15631. * @param p2 defines 3rd triangle point
  15632. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  15633. */
  15634. static PointInTriangle(p: Vector2, p0: Vector2, p1: Vector2, p2: Vector2): boolean;
  15635. /**
  15636. * Gets the distance between the vectors "value1" and "value2"
  15637. * @param value1 defines first vector
  15638. * @param value2 defines second vector
  15639. * @returns the distance between vectors
  15640. */
  15641. static Distance(value1: Vector2, value2: Vector2): number;
  15642. /**
  15643. * Returns the squared distance between the vectors "value1" and "value2"
  15644. * @param value1 defines first vector
  15645. * @param value2 defines second vector
  15646. * @returns the squared distance between vectors
  15647. */
  15648. static DistanceSquared(value1: Vector2, value2: Vector2): number;
  15649. /**
  15650. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  15651. * @param value1 defines first vector
  15652. * @param value2 defines second vector
  15653. * @returns a new Vector2
  15654. */
  15655. static Center(value1: Vector2, value2: Vector2): Vector2;
  15656. /**
  15657. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  15658. * @param p defines the middle point
  15659. * @param segA defines one point of the segment
  15660. * @param segB defines the other point of the segment
  15661. * @returns the shortest distance
  15662. */
  15663. static DistanceOfPointFromSegment(p: Vector2, segA: Vector2, segB: Vector2): number;
  15664. }
  15665. /**
  15666. * Classed used to store (x,y,z) vector representation
  15667. * A Vector3 is the main object used in 3D geometry
  15668. * It can represent etiher the coordinates of a point the space, either a direction
  15669. * Reminder: Babylon.js uses a left handed forward facing system
  15670. */
  15671. class Vector3 {
  15672. /**
  15673. * Defines the first coordinates (on X axis)
  15674. */
  15675. x: number;
  15676. /**
  15677. * Defines the second coordinates (on Y axis)
  15678. */
  15679. y: number;
  15680. /**
  15681. * Defines the third coordinates (on Z axis)
  15682. */
  15683. z: number;
  15684. /**
  15685. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  15686. * @param x defines the first coordinates (on X axis)
  15687. * @param y defines the second coordinates (on Y axis)
  15688. * @param z defines the third coordinates (on Z axis)
  15689. */
  15690. constructor(
  15691. /**
  15692. * Defines the first coordinates (on X axis)
  15693. */
  15694. x: number,
  15695. /**
  15696. * Defines the second coordinates (on Y axis)
  15697. */
  15698. y: number,
  15699. /**
  15700. * Defines the third coordinates (on Z axis)
  15701. */
  15702. z: number);
  15703. /**
  15704. * Creates a string representation of the Vector3
  15705. * @returns a string with the Vector3 coordinates.
  15706. */
  15707. toString(): string;
  15708. /**
  15709. * Gets the class name
  15710. * @returns the string "Vector3"
  15711. */
  15712. getClassName(): string;
  15713. /**
  15714. * Creates the Vector3 hash code
  15715. * @returns a number which tends to be unique between Vector3 instances
  15716. */
  15717. getHashCode(): number;
  15718. /**
  15719. * Creates an array containing three elements : the coordinates of the Vector3
  15720. * @returns a new array of numbers
  15721. */
  15722. asArray(): number[];
  15723. /**
  15724. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  15725. * @param array defines the destination array
  15726. * @param index defines the offset in the destination array
  15727. * @returns the current Vector3
  15728. */
  15729. toArray(array: FloatArray, index?: number): Vector3;
  15730. /**
  15731. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  15732. * @returns a new Quaternion object, computed from the Vector3 coordinates
  15733. */
  15734. toQuaternion(): Quaternion;
  15735. /**
  15736. * Adds the given vector to the current Vector3
  15737. * @param otherVector defines the second operand
  15738. * @returns the current updated Vector3
  15739. */
  15740. addInPlace(otherVector: Vector3): Vector3;
  15741. /**
  15742. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  15743. * @param otherVector defines the second operand
  15744. * @returns the resulting Vector3
  15745. */
  15746. add(otherVector: Vector3): Vector3;
  15747. /**
  15748. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  15749. * @param otherVector defines the second operand
  15750. * @param result defines the Vector3 object where to store the result
  15751. * @returns the current Vector3
  15752. */
  15753. addToRef(otherVector: Vector3, result: Vector3): Vector3;
  15754. /**
  15755. * Subtract the given vector from the current Vector3
  15756. * @param otherVector defines the second operand
  15757. * @returns the current updated Vector3
  15758. */
  15759. subtractInPlace(otherVector: Vector3): Vector3;
  15760. /**
  15761. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  15762. * @param otherVector defines the second operand
  15763. * @returns the resulting Vector3
  15764. */
  15765. subtract(otherVector: Vector3): Vector3;
  15766. /**
  15767. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  15768. * @param otherVector defines the second operand
  15769. * @param result defines the Vector3 object where to store the result
  15770. * @returns the current Vector3
  15771. */
  15772. subtractToRef(otherVector: Vector3, result: Vector3): Vector3;
  15773. /**
  15774. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  15775. * @param x defines the x coordinate of the operand
  15776. * @param y defines the y coordinate of the operand
  15777. * @param z defines the z coordinate of the operand
  15778. * @returns the resulting Vector3
  15779. */
  15780. subtractFromFloats(x: number, y: number, z: number): Vector3;
  15781. /**
  15782. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  15783. * @param x defines the x coordinate of the operand
  15784. * @param y defines the y coordinate of the operand
  15785. * @param z defines the z coordinate of the operand
  15786. * @param result defines the Vector3 object where to store the result
  15787. * @returns the current Vector3
  15788. */
  15789. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  15790. /**
  15791. * Gets a new Vector3 set with the current Vector3 negated coordinates
  15792. * @returns a new Vector3
  15793. */
  15794. negate(): Vector3;
  15795. /**
  15796. * Multiplies the Vector3 coordinates by the float "scale"
  15797. * @param scale defines the multiplier factor
  15798. * @returns the current updated Vector3
  15799. */
  15800. scaleInPlace(scale: number): Vector3;
  15801. /**
  15802. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  15803. * @param scale defines the multiplier factor
  15804. * @returns a new Vector3
  15805. */
  15806. scale(scale: number): Vector3;
  15807. /**
  15808. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  15809. * @param scale defines the multiplier factor
  15810. * @param result defines the Vector3 object where to store the result
  15811. * @returns the current Vector3
  15812. */
  15813. scaleToRef(scale: number, result: Vector3): Vector3;
  15814. /**
  15815. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  15816. * @param scale defines the scale factor
  15817. * @param result defines the Vector3 object where to store the result
  15818. * @returns the unmodified current Vector3
  15819. */
  15820. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  15821. /**
  15822. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  15823. * @param otherVector defines the second operand
  15824. * @returns true if both vectors are equals
  15825. */
  15826. equals(otherVector: Vector3): boolean;
  15827. /**
  15828. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  15829. * @param otherVector defines the second operand
  15830. * @param epsilon defines the minimal distance to define values as equals
  15831. * @returns true if both vectors are distant less than epsilon
  15832. */
  15833. equalsWithEpsilon(otherVector: Vector3, epsilon?: number): boolean;
  15834. /**
  15835. * Returns true if the current Vector3 coordinates equals the given floats
  15836. * @param x defines the x coordinate of the operand
  15837. * @param y defines the y coordinate of the operand
  15838. * @param z defines the z coordinate of the operand
  15839. * @returns true if both vectors are equals
  15840. */
  15841. equalsToFloats(x: number, y: number, z: number): boolean;
  15842. /**
  15843. * Multiplies the current Vector3 coordinates by the given ones
  15844. * @param otherVector defines the second operand
  15845. * @returns the current updated Vector3
  15846. */
  15847. multiplyInPlace(otherVector: Vector3): Vector3;
  15848. /**
  15849. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  15850. * @param otherVector defines the second operand
  15851. * @returns the new Vector3
  15852. */
  15853. multiply(otherVector: Vector3): Vector3;
  15854. /**
  15855. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  15856. * @param otherVector defines the second operand
  15857. * @param result defines the Vector3 object where to store the result
  15858. * @returns the current Vector3
  15859. */
  15860. multiplyToRef(otherVector: Vector3, result: Vector3): Vector3;
  15861. /**
  15862. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  15863. * @param x defines the x coordinate of the operand
  15864. * @param y defines the y coordinate of the operand
  15865. * @param z defines the z coordinate of the operand
  15866. * @returns the new Vector3
  15867. */
  15868. multiplyByFloats(x: number, y: number, z: number): Vector3;
  15869. /**
  15870. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  15871. * @param otherVector defines the second operand
  15872. * @returns the new Vector3
  15873. */
  15874. divide(otherVector: Vector3): Vector3;
  15875. /**
  15876. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  15877. * @param otherVector defines the second operand
  15878. * @param result defines the Vector3 object where to store the result
  15879. * @returns the current Vector3
  15880. */
  15881. divideToRef(otherVector: Vector3, result: Vector3): Vector3;
  15882. /**
  15883. * Divides the current Vector3 coordinates by the given ones.
  15884. * @param otherVector defines the second operand
  15885. * @returns the current updated Vector3
  15886. */
  15887. divideInPlace(otherVector: Vector3): Vector3;
  15888. /**
  15889. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  15890. * @param other defines the second operand
  15891. * @returns the current updated Vector3
  15892. */
  15893. minimizeInPlace(other: Vector3): Vector3;
  15894. /**
  15895. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  15896. * @param other defines the second operand
  15897. * @returns the current updated Vector3
  15898. */
  15899. maximizeInPlace(other: Vector3): Vector3;
  15900. /**
  15901. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  15902. */
  15903. readonly isNonUniform: boolean;
  15904. /**
  15905. * Gets the length of the Vector3
  15906. * @returns the length of the Vecto3
  15907. */
  15908. length(): number;
  15909. /**
  15910. * Gets the squared length of the Vector3
  15911. * @returns squared length of the Vector3
  15912. */
  15913. lengthSquared(): number;
  15914. /**
  15915. * Normalize the current Vector3.
  15916. * Please note that this is an in place operation.
  15917. * @returns the current updated Vector3
  15918. */
  15919. normalize(): Vector3;
  15920. /**
  15921. * Normalize the current Vector3 to a new vector
  15922. * @returns the new Vector3
  15923. */
  15924. normalizeToNew(): Vector3;
  15925. /**
  15926. * Normalize the current Vector3 to the reference
  15927. * @param reference define the Vector3 to update
  15928. * @returns the updated Vector3
  15929. */
  15930. normalizeToRef(reference: Vector3): Vector3;
  15931. /**
  15932. * Creates a new Vector3 copied from the current Vector3
  15933. * @returns the new Vector3
  15934. */
  15935. clone(): Vector3;
  15936. /**
  15937. * Copies the given vector coordinates to the current Vector3 ones
  15938. * @param source defines the source Vector3
  15939. * @returns the current updated Vector3
  15940. */
  15941. copyFrom(source: Vector3): Vector3;
  15942. /**
  15943. * Copies the given floats to the current Vector3 coordinates
  15944. * @param x defines the x coordinate of the operand
  15945. * @param y defines the y coordinate of the operand
  15946. * @param z defines the z coordinate of the operand
  15947. * @returns the current updated Vector3
  15948. */
  15949. copyFromFloats(x: number, y: number, z: number): Vector3;
  15950. /**
  15951. * Copies the given floats to the current Vector3 coordinates
  15952. * @param x defines the x coordinate of the operand
  15953. * @param y defines the y coordinate of the operand
  15954. * @param z defines the z coordinate of the operand
  15955. * @returns the current updated Vector3
  15956. */
  15957. set(x: number, y: number, z: number): Vector3;
  15958. /**
  15959. * Get the clip factor between two vectors
  15960. * @param vector0 defines the first operand
  15961. * @param vector1 defines the second operand
  15962. * @param axis defines the axis to use
  15963. * @param size defines the size along the axis
  15964. * @returns the clip factor
  15965. */
  15966. static GetClipFactor(vector0: Vector3, vector1: Vector3, axis: Vector3, size: number): number;
  15967. /**
  15968. * Get angle between two vectors
  15969. * @param vector0 angle between vector0 and vector1
  15970. * @param vector1 angle between vector0 and vector1
  15971. * @param normal direction of the normal
  15972. * @return the angle between vector0 and vector1
  15973. */
  15974. static GetAngleBetweenVectors(vector0: Vector3, vector1: Vector3, normal: Vector3): number;
  15975. /**
  15976. * Returns a new Vector3 set from the index "offset" of the given array
  15977. * @param array defines the source array
  15978. * @param offset defines the offset in the source array
  15979. * @returns the new Vector3
  15980. */
  15981. static FromArray(array: ArrayLike<number>, offset?: number): Vector3;
  15982. /**
  15983. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  15984. * This function is deprecated. Use FromArray instead
  15985. * @param array defines the source array
  15986. * @param offset defines the offset in the source array
  15987. * @returns the new Vector3
  15988. */
  15989. static FromFloatArray(array: Float32Array, offset?: number): Vector3;
  15990. /**
  15991. * Sets the given vector "result" with the element values from the index "offset" of the given array
  15992. * @param array defines the source array
  15993. * @param offset defines the offset in the source array
  15994. * @param result defines the Vector3 where to store the result
  15995. */
  15996. static FromArrayToRef(array: ArrayLike<number>, offset: number, result: Vector3): void;
  15997. /**
  15998. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  15999. * This function is deprecated. Use FromArrayToRef instead.
  16000. * @param array defines the source array
  16001. * @param offset defines the offset in the source array
  16002. * @param result defines the Vector3 where to store the result
  16003. */
  16004. static FromFloatArrayToRef(array: Float32Array, offset: number, result: Vector3): void;
  16005. /**
  16006. * Sets the given vector "result" with the given floats.
  16007. * @param x defines the x coordinate of the source
  16008. * @param y defines the y coordinate of the source
  16009. * @param z defines the z coordinate of the source
  16010. * @param result defines the Vector3 where to store the result
  16011. */
  16012. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  16013. /**
  16014. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  16015. * @returns a new empty Vector3
  16016. */
  16017. static Zero(): Vector3;
  16018. /**
  16019. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  16020. * @returns a new unit Vector3
  16021. */
  16022. static One(): Vector3;
  16023. /**
  16024. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  16025. * @returns a new up Vector3
  16026. */
  16027. static Up(): Vector3;
  16028. /**
  16029. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  16030. * @returns a new forward Vector3
  16031. */
  16032. static Forward(): Vector3;
  16033. /**
  16034. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  16035. * @returns a new right Vector3
  16036. */
  16037. static Right(): Vector3;
  16038. /**
  16039. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  16040. * @returns a new left Vector3
  16041. */
  16042. static Left(): Vector3;
  16043. /**
  16044. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  16045. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  16046. * @param vector defines the Vector3 to transform
  16047. * @param transformation defines the transformation matrix
  16048. * @returns the transformed Vector3
  16049. */
  16050. static TransformCoordinates(vector: Vector3, transformation: Matrix): Vector3;
  16051. /**
  16052. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  16053. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  16054. * @param vector defines the Vector3 to transform
  16055. * @param transformation defines the transformation matrix
  16056. * @param result defines the Vector3 where to store the result
  16057. */
  16058. static TransformCoordinatesToRef(vector: Vector3, transformation: Matrix, result: Vector3): void;
  16059. /**
  16060. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  16061. * This method computes tranformed coordinates only, not transformed direction vectors
  16062. * @param x define the x coordinate of the source vector
  16063. * @param y define the y coordinate of the source vector
  16064. * @param z define the z coordinate of the source vector
  16065. * @param transformation defines the transformation matrix
  16066. * @param result defines the Vector3 where to store the result
  16067. */
  16068. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: Matrix, result: Vector3): void;
  16069. /**
  16070. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  16071. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  16072. * @param vector defines the Vector3 to transform
  16073. * @param transformation defines the transformation matrix
  16074. * @returns the new Vector3
  16075. */
  16076. static TransformNormal(vector: Vector3, transformation: Matrix): Vector3;
  16077. /**
  16078. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  16079. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  16080. * @param vector defines the Vector3 to transform
  16081. * @param transformation defines the transformation matrix
  16082. * @param result defines the Vector3 where to store the result
  16083. */
  16084. static TransformNormalToRef(vector: Vector3, transformation: Matrix, result: Vector3): void;
  16085. /**
  16086. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  16087. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  16088. * @param x define the x coordinate of the source vector
  16089. * @param y define the y coordinate of the source vector
  16090. * @param z define the z coordinate of the source vector
  16091. * @param transformation defines the transformation matrix
  16092. * @param result defines the Vector3 where to store the result
  16093. */
  16094. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: Matrix, result: Vector3): void;
  16095. /**
  16096. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  16097. * @param value1 defines the first control point
  16098. * @param value2 defines the second control point
  16099. * @param value3 defines the third control point
  16100. * @param value4 defines the fourth control point
  16101. * @param amount defines the amount on the spline to use
  16102. * @returns the new Vector3
  16103. */
  16104. static CatmullRom(value1: Vector3, value2: Vector3, value3: Vector3, value4: Vector3, amount: number): Vector3;
  16105. /**
  16106. * 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"
  16107. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  16108. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  16109. * @param value defines the current value
  16110. * @param min defines the lower range value
  16111. * @param max defines the upper range value
  16112. * @returns the new Vector3
  16113. */
  16114. static Clamp(value: Vector3, min: Vector3, max: Vector3): Vector3;
  16115. /**
  16116. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  16117. * @param value1 defines the first control point
  16118. * @param tangent1 defines the first tangent vector
  16119. * @param value2 defines the second control point
  16120. * @param tangent2 defines the second tangent vector
  16121. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  16122. * @returns the new Vector3
  16123. */
  16124. static Hermite(value1: Vector3, tangent1: Vector3, value2: Vector3, tangent2: Vector3, amount: number): Vector3;
  16125. /**
  16126. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  16127. * @param start defines the start value
  16128. * @param end defines the end value
  16129. * @param amount max defines amount between both (between 0 and 1)
  16130. * @returns the new Vector3
  16131. */
  16132. static Lerp(start: Vector3, end: Vector3, amount: number): Vector3;
  16133. /**
  16134. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  16135. * @param start defines the start value
  16136. * @param end defines the end value
  16137. * @param amount max defines amount between both (between 0 and 1)
  16138. * @param result defines the Vector3 where to store the result
  16139. */
  16140. static LerpToRef(start: Vector3, end: Vector3, amount: number, result: Vector3): void;
  16141. /**
  16142. * Returns the dot product (float) between the vectors "left" and "right"
  16143. * @param left defines the left operand
  16144. * @param right defines the right operand
  16145. * @returns the dot product
  16146. */
  16147. static Dot(left: Vector3, right: Vector3): number;
  16148. /**
  16149. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  16150. * The cross product is then orthogonal to both "left" and "right"
  16151. * @param left defines the left operand
  16152. * @param right defines the right operand
  16153. * @returns the cross product
  16154. */
  16155. static Cross(left: Vector3, right: Vector3): Vector3;
  16156. /**
  16157. * Sets the given vector "result" with the cross product of "left" and "right"
  16158. * The cross product is then orthogonal to both "left" and "right"
  16159. * @param left defines the left operand
  16160. * @param right defines the right operand
  16161. * @param result defines the Vector3 where to store the result
  16162. */
  16163. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  16164. /**
  16165. * Returns a new Vector3 as the normalization of the given vector
  16166. * @param vector defines the Vector3 to normalize
  16167. * @returns the new Vector3
  16168. */
  16169. static Normalize(vector: Vector3): Vector3;
  16170. /**
  16171. * Sets the given vector "result" with the normalization of the given first vector
  16172. * @param vector defines the Vector3 to normalize
  16173. * @param result defines the Vector3 where to store the result
  16174. */
  16175. static NormalizeToRef(vector: Vector3, result: Vector3): void;
  16176. private static _viewportMatrixCache;
  16177. /**
  16178. * Project a Vector3 onto screen space
  16179. * @param vector defines the Vector3 to project
  16180. * @param world defines the world matrix to use
  16181. * @param transform defines the transform (view x projection) matrix to use
  16182. * @param viewport defines the screen viewport to use
  16183. * @returns the new Vector3
  16184. */
  16185. static Project(vector: Vector3, world: Matrix, transform: Matrix, viewport: Viewport): Vector3;
  16186. /**
  16187. * Unproject from screen space to object space
  16188. * @param source defines the screen space Vector3 to use
  16189. * @param viewportWidth defines the current width of the viewport
  16190. * @param viewportHeight defines the current height of the viewport
  16191. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  16192. * @param transform defines the transform (view x projection) matrix to use
  16193. * @returns the new Vector3
  16194. */
  16195. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: Matrix, transform: Matrix): Vector3;
  16196. /**
  16197. * Unproject from screen space to object space
  16198. * @param source defines the screen space Vector3 to use
  16199. * @param viewportWidth defines the current width of the viewport
  16200. * @param viewportHeight defines the current height of the viewport
  16201. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  16202. * @param view defines the view matrix to use
  16203. * @param projection defines the projection matrix to use
  16204. * @returns the new Vector3
  16205. */
  16206. static Unproject(source: Vector3, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix): Vector3;
  16207. /**
  16208. * Unproject from screen space to object space
  16209. * @param source defines the screen space Vector3 to use
  16210. * @param viewportWidth defines the current width of the viewport
  16211. * @param viewportHeight defines the current height of the viewport
  16212. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  16213. * @param view defines the view matrix to use
  16214. * @param projection defines the projection matrix to use
  16215. * @param result defines the Vector3 where to store the result
  16216. */
  16217. static UnprojectToRef(source: Vector3, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix, result: Vector3): void;
  16218. /**
  16219. * Unproject from screen space to object space
  16220. * @param sourceX defines the screen space x coordinate to use
  16221. * @param sourceY defines the screen space y coordinate to use
  16222. * @param sourceZ defines the screen space z coordinate to use
  16223. * @param viewportWidth defines the current width of the viewport
  16224. * @param viewportHeight defines the current height of the viewport
  16225. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  16226. * @param view defines the view matrix to use
  16227. * @param projection defines the projection matrix to use
  16228. * @param result defines the Vector3 where to store the result
  16229. */
  16230. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix, result: Vector3): void;
  16231. /**
  16232. * Gets the minimal coordinate values between two Vector3
  16233. * @param left defines the first operand
  16234. * @param right defines the second operand
  16235. * @returns the new Vector3
  16236. */
  16237. static Minimize(left: Vector3, right: Vector3): Vector3;
  16238. /**
  16239. * Gets the maximal coordinate values between two Vector3
  16240. * @param left defines the first operand
  16241. * @param right defines the second operand
  16242. * @returns the new Vector3
  16243. */
  16244. static Maximize(left: Vector3, right: Vector3): Vector3;
  16245. /**
  16246. * Returns the distance between the vectors "value1" and "value2"
  16247. * @param value1 defines the first operand
  16248. * @param value2 defines the second operand
  16249. * @returns the distance
  16250. */
  16251. static Distance(value1: Vector3, value2: Vector3): number;
  16252. /**
  16253. * Returns the squared distance between the vectors "value1" and "value2"
  16254. * @param value1 defines the first operand
  16255. * @param value2 defines the second operand
  16256. * @returns the squared distance
  16257. */
  16258. static DistanceSquared(value1: Vector3, value2: Vector3): number;
  16259. /**
  16260. * Returns a new Vector3 located at the center between "value1" and "value2"
  16261. * @param value1 defines the first operand
  16262. * @param value2 defines the second operand
  16263. * @returns the new Vector3
  16264. */
  16265. static Center(value1: Vector3, value2: Vector3): Vector3;
  16266. /**
  16267. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  16268. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  16269. * to something in order to rotate it from its local system to the given target system
  16270. * Note: axis1, axis2 and axis3 are normalized during this operation
  16271. * @param axis1 defines the first axis
  16272. * @param axis2 defines the second axis
  16273. * @param axis3 defines the third axis
  16274. * @returns a new Vector3
  16275. */
  16276. static RotationFromAxis(axis1: Vector3, axis2: Vector3, axis3: Vector3): Vector3;
  16277. /**
  16278. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  16279. * @param axis1 defines the first axis
  16280. * @param axis2 defines the second axis
  16281. * @param axis3 defines the third axis
  16282. * @param ref defines the Vector3 where to store the result
  16283. */
  16284. static RotationFromAxisToRef(axis1: Vector3, axis2: Vector3, axis3: Vector3, ref: Vector3): void;
  16285. }
  16286. class Vector4 {
  16287. x: number;
  16288. y: number;
  16289. z: number;
  16290. w: number;
  16291. /**
  16292. * Creates a Vector4 object from the given floats.
  16293. */
  16294. constructor(x: number, y: number, z: number, w: number);
  16295. /**
  16296. * Returns the string with the Vector4 coordinates.
  16297. */
  16298. toString(): string;
  16299. /**
  16300. * Returns the string "Vector4".
  16301. */
  16302. getClassName(): string;
  16303. /**
  16304. * Returns the Vector4 hash code.
  16305. */
  16306. getHashCode(): number;
  16307. /**
  16308. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  16309. */
  16310. asArray(): number[];
  16311. /**
  16312. * Populates the given array from the given index with the Vector4 coordinates.
  16313. * Returns the Vector4.
  16314. */
  16315. toArray(array: FloatArray, index?: number): Vector4;
  16316. /**
  16317. * Adds the given vector to the current Vector4.
  16318. * Returns the updated Vector4.
  16319. */
  16320. addInPlace(otherVector: Vector4): Vector4;
  16321. /**
  16322. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  16323. */
  16324. add(otherVector: Vector4): Vector4;
  16325. /**
  16326. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  16327. * Returns the current Vector4.
  16328. */
  16329. addToRef(otherVector: Vector4, result: Vector4): Vector4;
  16330. /**
  16331. * Subtract in place the given vector from the current Vector4.
  16332. * Returns the updated Vector4.
  16333. */
  16334. subtractInPlace(otherVector: Vector4): Vector4;
  16335. /**
  16336. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  16337. */
  16338. subtract(otherVector: Vector4): Vector4;
  16339. /**
  16340. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  16341. * Returns the current Vector4.
  16342. */
  16343. subtractToRef(otherVector: Vector4, result: Vector4): Vector4;
  16344. /**
  16345. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  16346. */
  16347. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  16348. /**
  16349. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  16350. * Returns the current Vector4.
  16351. */
  16352. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  16353. /**
  16354. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  16355. */
  16356. negate(): Vector4;
  16357. /**
  16358. * Multiplies the current Vector4 coordinates by scale (float).
  16359. * Returns the updated Vector4.
  16360. */
  16361. scaleInPlace(scale: number): Vector4;
  16362. /**
  16363. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  16364. */
  16365. scale(scale: number): Vector4;
  16366. /**
  16367. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  16368. * Returns the current Vector4.
  16369. */
  16370. scaleToRef(scale: number, result: Vector4): Vector4;
  16371. /**
  16372. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  16373. * @param scale defines the scale factor
  16374. * @param result defines the Vector4 object where to store the result
  16375. * @returns the unmodified current Vector4
  16376. */
  16377. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  16378. /**
  16379. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  16380. */
  16381. equals(otherVector: Vector4): boolean;
  16382. /**
  16383. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  16384. */
  16385. equalsWithEpsilon(otherVector: Vector4, epsilon?: number): boolean;
  16386. /**
  16387. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  16388. */
  16389. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  16390. /**
  16391. * Multiplies in place the current Vector4 by the given one.
  16392. * Returns the updated Vector4.
  16393. */
  16394. multiplyInPlace(otherVector: Vector4): Vector4;
  16395. /**
  16396. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  16397. */
  16398. multiply(otherVector: Vector4): Vector4;
  16399. /**
  16400. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  16401. * Returns the current Vector4.
  16402. */
  16403. multiplyToRef(otherVector: Vector4, result: Vector4): Vector4;
  16404. /**
  16405. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  16406. */
  16407. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  16408. /**
  16409. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  16410. */
  16411. divide(otherVector: Vector4): Vector4;
  16412. /**
  16413. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  16414. * Returns the current Vector4.
  16415. */
  16416. divideToRef(otherVector: Vector4, result: Vector4): Vector4;
  16417. /**
  16418. * Divides the current Vector3 coordinates by the given ones.
  16419. * @returns the updated Vector3.
  16420. */
  16421. divideInPlace(otherVector: Vector4): Vector4;
  16422. /**
  16423. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  16424. * @param other defines the second operand
  16425. * @returns the current updated Vector4
  16426. */
  16427. minimizeInPlace(other: Vector4): Vector4;
  16428. /**
  16429. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  16430. * @param other defines the second operand
  16431. * @returns the current updated Vector4
  16432. */
  16433. maximizeInPlace(other: Vector4): Vector4;
  16434. /**
  16435. * Returns the Vector4 length (float).
  16436. */
  16437. length(): number;
  16438. /**
  16439. * Returns the Vector4 squared length (float).
  16440. */
  16441. lengthSquared(): number;
  16442. /**
  16443. * Normalizes in place the Vector4.
  16444. * Returns the updated Vector4.
  16445. */
  16446. normalize(): Vector4;
  16447. /**
  16448. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  16449. */
  16450. toVector3(): Vector3;
  16451. /**
  16452. * Returns a new Vector4 copied from the current one.
  16453. */
  16454. clone(): Vector4;
  16455. /**
  16456. * Updates the current Vector4 with the given one coordinates.
  16457. * Returns the updated Vector4.
  16458. */
  16459. copyFrom(source: Vector4): Vector4;
  16460. /**
  16461. * Updates the current Vector4 coordinates with the given floats.
  16462. * Returns the updated Vector4.
  16463. */
  16464. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  16465. /**
  16466. * Updates the current Vector4 coordinates with the given floats.
  16467. * Returns the updated Vector4.
  16468. */
  16469. set(x: number, y: number, z: number, w: number): Vector4;
  16470. /**
  16471. * Returns a new Vector4 set from the starting index of the given array.
  16472. */
  16473. static FromArray(array: ArrayLike<number>, offset?: number): Vector4;
  16474. /**
  16475. * Updates the given vector "result" from the starting index of the given array.
  16476. */
  16477. static FromArrayToRef(array: ArrayLike<number>, offset: number, result: Vector4): void;
  16478. /**
  16479. * Updates the given vector "result" from the starting index of the given Float32Array.
  16480. */
  16481. static FromFloatArrayToRef(array: Float32Array, offset: number, result: Vector4): void;
  16482. /**
  16483. * Updates the given vector "result" coordinates from the given floats.
  16484. */
  16485. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  16486. /**
  16487. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  16488. */
  16489. static Zero(): Vector4;
  16490. /**
  16491. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  16492. */
  16493. static One(): Vector4;
  16494. /**
  16495. * Returns a new normalized Vector4 from the given one.
  16496. */
  16497. static Normalize(vector: Vector4): Vector4;
  16498. /**
  16499. * Updates the given vector "result" from the normalization of the given one.
  16500. */
  16501. static NormalizeToRef(vector: Vector4, result: Vector4): void;
  16502. static Minimize(left: Vector4, right: Vector4): Vector4;
  16503. static Maximize(left: Vector4, right: Vector4): Vector4;
  16504. /**
  16505. * Returns the distance (float) between the vectors "value1" and "value2".
  16506. */
  16507. static Distance(value1: Vector4, value2: Vector4): number;
  16508. /**
  16509. * Returns the squared distance (float) between the vectors "value1" and "value2".
  16510. */
  16511. static DistanceSquared(value1: Vector4, value2: Vector4): number;
  16512. /**
  16513. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  16514. */
  16515. static Center(value1: Vector4, value2: Vector4): Vector4;
  16516. /**
  16517. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  16518. * This methods computes transformed normalized direction vectors only.
  16519. */
  16520. static TransformNormal(vector: Vector4, transformation: Matrix): Vector4;
  16521. /**
  16522. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  16523. * This methods computes transformed normalized direction vectors only.
  16524. */
  16525. static TransformNormalToRef(vector: Vector4, transformation: Matrix, result: Vector4): void;
  16526. /**
  16527. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  16528. * This methods computes transformed normalized direction vectors only.
  16529. */
  16530. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: Matrix, result: Vector4): void;
  16531. }
  16532. interface ISize {
  16533. width: number;
  16534. height: number;
  16535. }
  16536. class Size implements ISize {
  16537. width: number;
  16538. height: number;
  16539. /**
  16540. * Creates a Size object from the given width and height (floats).
  16541. */
  16542. constructor(width: number, height: number);
  16543. toString(): string;
  16544. /**
  16545. * Returns the string "Size"
  16546. */
  16547. getClassName(): string;
  16548. /**
  16549. * Returns the Size hash code.
  16550. */
  16551. getHashCode(): number;
  16552. /**
  16553. * Updates the current size from the given one.
  16554. * Returns the updated Size.
  16555. */
  16556. copyFrom(src: Size): void;
  16557. /**
  16558. * Updates in place the current Size from the given floats.
  16559. * Returns the updated Size.
  16560. */
  16561. copyFromFloats(width: number, height: number): Size;
  16562. /**
  16563. * Updates in place the current Size from the given floats.
  16564. * Returns the updated Size.
  16565. */
  16566. set(width: number, height: number): Size;
  16567. /**
  16568. * Returns a new Size set with the multiplication result of the current Size and the given floats.
  16569. */
  16570. multiplyByFloats(w: number, h: number): Size;
  16571. /**
  16572. * Returns a new Size copied from the given one.
  16573. */
  16574. clone(): Size;
  16575. /**
  16576. * Boolean : True if the current Size and the given one width and height are strictly equal.
  16577. */
  16578. equals(other: Size): boolean;
  16579. /**
  16580. * Returns the surface of the Size : width * height (float).
  16581. */
  16582. readonly surface: number;
  16583. /**
  16584. * Returns a new Size set to (0.0, 0.0)
  16585. */
  16586. static Zero(): Size;
  16587. /**
  16588. * Returns a new Size set as the addition result of the current Size and the given one.
  16589. */
  16590. add(otherSize: Size): Size;
  16591. /**
  16592. * Returns a new Size set as the subtraction result of the given one from the current Size.
  16593. */
  16594. subtract(otherSize: Size): Size;
  16595. /**
  16596. * Returns a new Size set at the linear interpolation "amount" between "start" and "end".
  16597. */
  16598. static Lerp(start: Size, end: Size, amount: number): Size;
  16599. }
  16600. /**
  16601. * Class used to store quaternion data
  16602. * @see https://en.wikipedia.org/wiki/Quaternion
  16603. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  16604. */
  16605. class Quaternion {
  16606. /** defines the first component (0 by default) */
  16607. x: number;
  16608. /** defines the second component (0 by default) */
  16609. y: number;
  16610. /** defines the third component (0 by default) */
  16611. z: number;
  16612. /** defines the fourth component (1.0 by default) */
  16613. w: number;
  16614. /**
  16615. * Creates a new Quaternion from the given floats
  16616. * @param x defines the first component (0 by default)
  16617. * @param y defines the second component (0 by default)
  16618. * @param z defines the third component (0 by default)
  16619. * @param w defines the fourth component (1.0 by default)
  16620. */
  16621. constructor(
  16622. /** defines the first component (0 by default) */
  16623. x?: number,
  16624. /** defines the second component (0 by default) */
  16625. y?: number,
  16626. /** defines the third component (0 by default) */
  16627. z?: number,
  16628. /** defines the fourth component (1.0 by default) */
  16629. w?: number);
  16630. /**
  16631. * Gets a string representation for the current quaternion
  16632. * @returns a string with the Quaternion coordinates
  16633. */
  16634. toString(): string;
  16635. /**
  16636. * Gets the class name of the quaternion
  16637. * @returns the string "Quaternion"
  16638. */
  16639. getClassName(): string;
  16640. /**
  16641. * Gets a hash code for this quaternion
  16642. * @returns the quaternion hash code
  16643. */
  16644. getHashCode(): number;
  16645. /**
  16646. * Copy the quaternion to an array
  16647. * @returns a new array populated with 4 elements from the quaternion coordinates
  16648. */
  16649. asArray(): number[];
  16650. /**
  16651. * Check if two quaternions are equals
  16652. * @param otherQuaternion defines the second operand
  16653. * @return true if the current quaternion and the given one coordinates are strictly equals
  16654. */
  16655. equals(otherQuaternion: Quaternion): boolean;
  16656. /**
  16657. * Clone the current quaternion
  16658. * @returns a new quaternion copied from the current one
  16659. */
  16660. clone(): Quaternion;
  16661. /**
  16662. * Copy a quaternion to the current one
  16663. * @param other defines the other quaternion
  16664. * @returns the updated current quaternion
  16665. */
  16666. copyFrom(other: Quaternion): Quaternion;
  16667. /**
  16668. * Updates the current quaternion with the given float coordinates
  16669. * @param x defines the x coordinate
  16670. * @param y defines the y coordinate
  16671. * @param z defines the z coordinate
  16672. * @param w defines the w coordinate
  16673. * @returns the updated current quaternion
  16674. */
  16675. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  16676. /**
  16677. * Updates the current quaternion from the given float coordinates
  16678. * @param x defines the x coordinate
  16679. * @param y defines the y coordinate
  16680. * @param z defines the z coordinate
  16681. * @param w defines the w coordinate
  16682. * @returns the updated current quaternion
  16683. */
  16684. set(x: number, y: number, z: number, w: number): Quaternion;
  16685. /**
  16686. * Adds two quaternions
  16687. * @param other defines the second operand
  16688. * @returns a new quaternion as the addition result of the given one and the current quaternion
  16689. */
  16690. add(other: Quaternion): Quaternion;
  16691. /**
  16692. * Add a quaternion to the current one
  16693. * @param other defines the quaternion to add
  16694. * @returns the current quaternion
  16695. */
  16696. addInPlace(other: Quaternion): Quaternion;
  16697. /**
  16698. * Subtract two quaternions
  16699. * @param other defines the second operand
  16700. * @returns a new quaternion as the subtraction result of the given one from the current one
  16701. */
  16702. subtract(other: Quaternion): Quaternion;
  16703. /**
  16704. * Multiplies the current quaternion by a scale factor
  16705. * @param value defines the scale factor
  16706. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  16707. */
  16708. scale(value: number): Quaternion;
  16709. /**
  16710. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  16711. * @param scale defines the scale factor
  16712. * @param result defines the Quaternion object where to store the result
  16713. * @returns the unmodified current quaternion
  16714. */
  16715. scaleToRef(scale: number, result: Quaternion): Quaternion;
  16716. /**
  16717. * Multiplies in place the current quaternion by a scale factor
  16718. * @param value defines the scale factor
  16719. * @returns the current modified quaternion
  16720. */
  16721. scaleInPlace(value: number): Quaternion;
  16722. /**
  16723. * Scale the current quaternion values by a factor and add the result to a given quaternion
  16724. * @param scale defines the scale factor
  16725. * @param result defines the Quaternion object where to store the result
  16726. * @returns the unmodified current quaternion
  16727. */
  16728. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  16729. /**
  16730. * Multiplies two quaternions
  16731. * @param q1 defines the second operand
  16732. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  16733. */
  16734. multiply(q1: Quaternion): Quaternion;
  16735. /**
  16736. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  16737. * @param q1 defines the second operand
  16738. * @param result defines the target quaternion
  16739. * @returns the current quaternion
  16740. */
  16741. multiplyToRef(q1: Quaternion, result: Quaternion): Quaternion;
  16742. /**
  16743. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  16744. * @param q1 defines the second operand
  16745. * @returns the currentupdated quaternion
  16746. */
  16747. multiplyInPlace(q1: Quaternion): Quaternion;
  16748. /**
  16749. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  16750. * @param ref defines the target quaternion
  16751. * @returns the current quaternion
  16752. */
  16753. conjugateToRef(ref: Quaternion): Quaternion;
  16754. /**
  16755. * Conjugates in place (1-q) the current quaternion
  16756. * @returns the current updated quaternion
  16757. */
  16758. conjugateInPlace(): Quaternion;
  16759. /**
  16760. * Conjugates in place (1-q) the current quaternion
  16761. * @returns a new quaternion
  16762. */
  16763. conjugate(): Quaternion;
  16764. /**
  16765. * Gets length of current quaternion
  16766. * @returns the quaternion length (float)
  16767. */
  16768. length(): number;
  16769. /**
  16770. * Normalize in place the current quaternion
  16771. * @returns the current updated quaternion
  16772. */
  16773. normalize(): Quaternion;
  16774. /**
  16775. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  16776. * @param order is a reserved parameter and is ignore for now
  16777. * @returns a new Vector3 containing the Euler angles
  16778. */
  16779. toEulerAngles(order?: string): Vector3;
  16780. /**
  16781. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  16782. * @param result defines the vector which will be filled with the Euler angles
  16783. * @param order is a reserved parameter and is ignore for now
  16784. * @returns the current unchanged quaternion
  16785. */
  16786. toEulerAnglesToRef(result: Vector3, order?: string): Quaternion;
  16787. /**
  16788. * Updates the given rotation matrix with the current quaternion values
  16789. * @param result defines the target matrix
  16790. * @returns the current unchanged quaternion
  16791. */
  16792. toRotationMatrix(result: Matrix): Quaternion;
  16793. /**
  16794. * Updates the current quaternion from the given rotation matrix values
  16795. * @param matrix defines the source matrix
  16796. * @returns the current updated quaternion
  16797. */
  16798. fromRotationMatrix(matrix: Matrix): Quaternion;
  16799. /**
  16800. * Creates a new quaternion from a rotation matrix
  16801. * @param matrix defines the source matrix
  16802. * @returns a new quaternion created from the given rotation matrix values
  16803. */
  16804. static FromRotationMatrix(matrix: Matrix): Quaternion;
  16805. /**
  16806. * Updates the given quaternion with the given rotation matrix values
  16807. * @param matrix defines the source matrix
  16808. * @param result defines the target quaternion
  16809. */
  16810. static FromRotationMatrixToRef(matrix: Matrix, result: Quaternion): void;
  16811. /**
  16812. * Returns the dot product (float) between the quaternions "left" and "right"
  16813. * @param left defines the left operand
  16814. * @param right defines the right operand
  16815. * @returns the dot product
  16816. */
  16817. static Dot(left: Quaternion, right: Quaternion): number;
  16818. /**
  16819. * Checks if the two quaternions are close to each other
  16820. * @param quat0 defines the first quaternion to check
  16821. * @param quat1 defines the second quaternion to check
  16822. * @returns true if the two quaternions are close to each other
  16823. */
  16824. static AreClose(quat0: Quaternion, quat1: Quaternion): boolean;
  16825. /**
  16826. * Creates an empty quaternion
  16827. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  16828. */
  16829. static Zero(): Quaternion;
  16830. /**
  16831. * Inverse a given quaternion
  16832. * @param q defines the source quaternion
  16833. * @returns a new quaternion as the inverted current quaternion
  16834. */
  16835. static Inverse(q: Quaternion): Quaternion;
  16836. /**
  16837. * Creates an identity quaternion
  16838. * @returns the identity quaternion
  16839. */
  16840. static Identity(): Quaternion;
  16841. /**
  16842. * Gets a boolean indicating if the given quaternion is identity
  16843. * @param quaternion defines the quaternion to check
  16844. * @returns true if the quaternion is identity
  16845. */
  16846. static IsIdentity(quaternion: Quaternion): boolean;
  16847. /**
  16848. * Creates a quaternion from a rotation around an axis
  16849. * @param axis defines the axis to use
  16850. * @param angle defines the angle to use
  16851. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  16852. */
  16853. static RotationAxis(axis: Vector3, angle: number): Quaternion;
  16854. /**
  16855. * Creates a rotation around an axis and stores it into the given quaternion
  16856. * @param axis defines the axis to use
  16857. * @param angle defines the angle to use
  16858. * @param result defines the target quaternion
  16859. * @returns the target quaternion
  16860. */
  16861. static RotationAxisToRef(axis: Vector3, angle: number, result: Quaternion): Quaternion;
  16862. /**
  16863. * Creates a new quaternion from data stored into an array
  16864. * @param array defines the data source
  16865. * @param offset defines the offset in the source array where the data starts
  16866. * @returns a new quaternion
  16867. */
  16868. static FromArray(array: ArrayLike<number>, offset?: number): Quaternion;
  16869. /**
  16870. * Creates a new quaternion from the given Euler float angles (y, x, z)
  16871. * @param yaw defines the rotation around Y axis
  16872. * @param pitch defines the rotation around X axis
  16873. * @param roll defines the rotation around Z axis
  16874. * @returns the new quaternion
  16875. */
  16876. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  16877. /**
  16878. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  16879. * @param yaw defines the rotation around Y axis
  16880. * @param pitch defines the rotation around X axis
  16881. * @param roll defines the rotation around Z axis
  16882. * @param result defines the target quaternion
  16883. */
  16884. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  16885. /**
  16886. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  16887. * @param alpha defines the rotation around first axis
  16888. * @param beta defines the rotation around second axis
  16889. * @param gamma defines the rotation around third axis
  16890. * @returns the new quaternion
  16891. */
  16892. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  16893. /**
  16894. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  16895. * @param alpha defines the rotation around first axis
  16896. * @param beta defines the rotation around second axis
  16897. * @param gamma defines the rotation around third axis
  16898. * @param result defines the target quaternion
  16899. */
  16900. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  16901. /**
  16902. * 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)
  16903. * @param axis1 defines the first axis
  16904. * @param axis2 defines the second axis
  16905. * @param axis3 defines the third axis
  16906. * @returns the new quaternion
  16907. */
  16908. static RotationQuaternionFromAxis(axis1: Vector3, axis2: Vector3, axis3: Vector3): Quaternion;
  16909. /**
  16910. * 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
  16911. * @param axis1 defines the first axis
  16912. * @param axis2 defines the second axis
  16913. * @param axis3 defines the third axis
  16914. * @param ref defines the target quaternion
  16915. */
  16916. static RotationQuaternionFromAxisToRef(axis1: Vector3, axis2: Vector3, axis3: Vector3, ref: Quaternion): void;
  16917. /**
  16918. * Interpolates between two quaternions
  16919. * @param left defines first quaternion
  16920. * @param right defines second quaternion
  16921. * @param amount defines the gradient to use
  16922. * @returns the new interpolated quaternion
  16923. */
  16924. static Slerp(left: Quaternion, right: Quaternion, amount: number): Quaternion;
  16925. /**
  16926. * Interpolates between two quaternions and stores it into a target quaternion
  16927. * @param left defines first quaternion
  16928. * @param right defines second quaternion
  16929. * @param amount defines the gradient to use
  16930. * @param result defines the target quaternion
  16931. */
  16932. static SlerpToRef(left: Quaternion, right: Quaternion, amount: number, result: Quaternion): void;
  16933. /**
  16934. * Interpolate between two quaternions using Hermite interpolation
  16935. * @param value1 defines first quaternion
  16936. * @param tangent1 defines the incoming tangent
  16937. * @param value2 defines second quaternion
  16938. * @param tangent2 defines the outgoing tangent
  16939. * @param amount defines the target quaternion
  16940. * @returns the new interpolated quaternion
  16941. */
  16942. static Hermite(value1: Quaternion, tangent1: Quaternion, value2: Quaternion, tangent2: Quaternion, amount: number): Quaternion;
  16943. }
  16944. /**
  16945. * Class used to store matrix data (4x4)
  16946. */
  16947. class Matrix {
  16948. private static _tempQuaternion;
  16949. private static _xAxis;
  16950. private static _yAxis;
  16951. private static _zAxis;
  16952. private static _updateFlagSeed;
  16953. private static _identityReadOnly;
  16954. private _isIdentity;
  16955. private _isIdentityDirty;
  16956. /**
  16957. * Gets the update flag of the matrix which is an unique number for the matrix.
  16958. * It will be incremented every time the matrix data change.
  16959. * You can use it to speed the comparison between two versions of the same matrix.
  16960. */
  16961. updateFlag: number;
  16962. /**
  16963. * Gets or sets the internal data of the matrix
  16964. */
  16965. m: Float32Array;
  16966. /** @hidden */
  16967. _markAsUpdated(): void;
  16968. /**
  16969. * Creates an empty matrix (filled with zeros)
  16970. */
  16971. constructor();
  16972. /**
  16973. * Check if the current matrix is indentity
  16974. * @param considerAsTextureMatrix defines if the current matrix must be considered as a texture matrix (3x2)
  16975. * @returns true is the matrix is the identity matrix
  16976. */
  16977. isIdentity(considerAsTextureMatrix?: boolean): boolean;
  16978. /**
  16979. * Gets the determinant of the matrix
  16980. * @returns the matrix determinant
  16981. */
  16982. determinant(): number;
  16983. /**
  16984. * Returns the matrix as a Float32Array
  16985. * @returns the matrix underlying array
  16986. */
  16987. toArray(): Float32Array;
  16988. /**
  16989. * Returns the matrix as a Float32Array
  16990. * @returns the matrix underlying array.
  16991. */
  16992. asArray(): Float32Array;
  16993. /**
  16994. * Inverts the current matrix in place
  16995. * @returns the current inverted matrix
  16996. */
  16997. invert(): Matrix;
  16998. /**
  16999. * Sets all the matrix elements to zero
  17000. * @returns the current matrix
  17001. */
  17002. reset(): Matrix;
  17003. /**
  17004. * Adds the current matrix with a second one
  17005. * @param other defines the matrix to add
  17006. * @returns a new matrix as the addition of the current matrix and the given one
  17007. */
  17008. add(other: Matrix): Matrix;
  17009. /**
  17010. * Sets the given matrix "result" to the addition of the current matrix and the given one
  17011. * @param other defines the matrix to add
  17012. * @param result defines the target matrix
  17013. * @returns the current matrix
  17014. */
  17015. addToRef(other: Matrix, result: Matrix): Matrix;
  17016. /**
  17017. * Adds in place the given matrix to the current matrix
  17018. * @param other defines the second operand
  17019. * @returns the current updated matrix
  17020. */
  17021. addToSelf(other: Matrix): Matrix;
  17022. /**
  17023. * Sets the given matrix to the current inverted Matrix
  17024. * @param other defines the target matrix
  17025. * @returns the unmodified current matrix
  17026. */
  17027. invertToRef(other: Matrix): Matrix;
  17028. /**
  17029. * Inserts the translation vector (using 3 floats) in the current matrix
  17030. * @param x defines the 1st component of the translation
  17031. * @param y defines the 2nd component of the translation
  17032. * @param z defines the 3rd component of the translation
  17033. * @returns the current updated matrix
  17034. */
  17035. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  17036. /**
  17037. * Inserts the translation vector in the current matrix
  17038. * @param vector3 defines the translation to insert
  17039. * @returns the current updated matrix
  17040. */
  17041. setTranslation(vector3: Vector3): Matrix;
  17042. /**
  17043. * Gets the translation value of the current matrix
  17044. * @returns a new Vector3 as the extracted translation from the matrix
  17045. */
  17046. getTranslation(): Vector3;
  17047. /**
  17048. * Fill a Vector3 with the extracted translation from the matrix
  17049. * @param result defines the Vector3 where to store the translation
  17050. * @returns the current matrix
  17051. */
  17052. getTranslationToRef(result: Vector3): Matrix;
  17053. /**
  17054. * Remove rotation and scaling part from the matrix
  17055. * @returns the updated matrix
  17056. */
  17057. removeRotationAndScaling(): Matrix;
  17058. /**
  17059. * Multiply two matrices
  17060. * @param other defines the second operand
  17061. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  17062. */
  17063. multiply(other: Matrix): Matrix;
  17064. /**
  17065. * Copy the current matrix from the given one
  17066. * @param other defines the source matrix
  17067. * @returns the current updated matrix
  17068. */
  17069. copyFrom(other: Matrix): Matrix;
  17070. /**
  17071. * Populates the given array from the starting index with the current matrix values
  17072. * @param array defines the target array
  17073. * @param offset defines the offset in the target array where to start storing values
  17074. * @returns the current matrix
  17075. */
  17076. copyToArray(array: Float32Array, offset?: number): Matrix;
  17077. /**
  17078. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  17079. * @param other defines the second operand
  17080. * @param result defines the matrix where to store the multiplication
  17081. * @returns the current matrix
  17082. */
  17083. multiplyToRef(other: Matrix, result: Matrix): Matrix;
  17084. /**
  17085. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  17086. * @param other defines the second operand
  17087. * @param result defines the array where to store the multiplication
  17088. * @param offset defines the offset in the target array where to start storing values
  17089. * @returns the current matrix
  17090. */
  17091. multiplyToArray(other: Matrix, result: Float32Array, offset: number): Matrix;
  17092. /**
  17093. * Check equality between this matrix and a second one
  17094. * @param value defines the second matrix to compare
  17095. * @returns true is the current matrix and the given one values are strictly equal
  17096. */
  17097. equals(value: Matrix): boolean;
  17098. /**
  17099. * Clone the current matrix
  17100. * @returns a new matrix from the current matrix
  17101. */
  17102. clone(): Matrix;
  17103. /**
  17104. * Returns the name of the current matrix class
  17105. * @returns the string "Matrix"
  17106. */
  17107. getClassName(): string;
  17108. /**
  17109. * Gets the hash code of the current matrix
  17110. * @returns the hash code
  17111. */
  17112. getHashCode(): number;
  17113. /**
  17114. * Decomposes the current Matrix into a translation, rotation and scaling components
  17115. * @param scale defines the scale vector3 given as a reference to update
  17116. * @param rotation defines the rotation quaternion given as a reference to update
  17117. * @param translation defines the translation vector3 given as a reference to update
  17118. * @returns true if operation was successful
  17119. */
  17120. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  17121. /**
  17122. * Gets specific row of the matrix
  17123. * @param index defines the number of the row to get
  17124. * @returns the index-th row of the current matrix as a new Vector4
  17125. */
  17126. getRow(index: number): Nullable<Vector4>;
  17127. /**
  17128. * Sets the index-th row of the current matrix to the vector4 values
  17129. * @param index defines the number of the row to set
  17130. * @param row defines the target vector4
  17131. * @returns the updated current matrix
  17132. */
  17133. setRow(index: number, row: Vector4): Matrix;
  17134. /**
  17135. * Compute the transpose of the matrix
  17136. * @returns the new transposed matrix
  17137. */
  17138. transpose(): Matrix;
  17139. /**
  17140. * Compute the transpose of the matrix and store it in a given matrix
  17141. * @param result defines the target matrix
  17142. * @returns the current matrix
  17143. */
  17144. transposeToRef(result: Matrix): Matrix;
  17145. /**
  17146. * Sets the index-th row of the current matrix with the given 4 x float values
  17147. * @param index defines the row index
  17148. * @param x defines the x component to set
  17149. * @param y defines the y component to set
  17150. * @param z defines the z component to set
  17151. * @param w defines the w component to set
  17152. * @returns the updated current matrix
  17153. */
  17154. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  17155. /**
  17156. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  17157. * @param scale defines the scale factor
  17158. * @returns a new matrix
  17159. */
  17160. scale(scale: number): Matrix;
  17161. /**
  17162. * Scale the current matrix values by a factor to a given result matrix
  17163. * @param scale defines the scale factor
  17164. * @param result defines the matrix to store the result
  17165. * @returns the current matrix
  17166. */
  17167. scaleToRef(scale: number, result: Matrix): Matrix;
  17168. /**
  17169. * Scale the current matrix values by a factor and add the result to a given matrix
  17170. * @param scale defines the scale factor
  17171. * @param result defines the Matrix to store the result
  17172. * @returns the current matrix
  17173. */
  17174. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  17175. /**
  17176. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  17177. * @param ref matrix to store the result
  17178. */
  17179. toNormalMatrix(ref: Matrix): void;
  17180. /**
  17181. * Gets only rotation part of the current matrix
  17182. * @returns a new matrix sets to the extracted rotation matrix from the current one
  17183. */
  17184. getRotationMatrix(): Matrix;
  17185. /**
  17186. * Extracts the rotation matrix from the current one and sets it as the given "result"
  17187. * @param result defines the target matrix to store data to
  17188. * @returns the current matrix
  17189. */
  17190. getRotationMatrixToRef(result: Matrix): Matrix;
  17191. /**
  17192. * Creates a matrix from an array
  17193. * @param array defines the source array
  17194. * @param offset defines an offset in the source array
  17195. * @returns a new Matrix set from the starting index of the given array
  17196. */
  17197. static FromArray(array: ArrayLike<number>, offset?: number): Matrix;
  17198. /**
  17199. * Copy the content of an array into a given matrix
  17200. * @param array defines the source array
  17201. * @param offset defines an offset in the source array
  17202. * @param result defines the target matrix
  17203. */
  17204. static FromArrayToRef(array: ArrayLike<number>, offset: number, result: Matrix): void;
  17205. /**
  17206. * Stores an array into a matrix after having multiplied each component by a given factor
  17207. * @param array defines the source array
  17208. * @param offset defines the offset in the source array
  17209. * @param scale defines the scaling factor
  17210. * @param result defines the target matrix
  17211. */
  17212. static FromFloat32ArrayToRefScaled(array: Float32Array, offset: number, scale: number, result: Matrix): void;
  17213. /**
  17214. * Stores a list of values (16) inside a given matrix
  17215. * @param initialM11 defines 1st value of 1st row
  17216. * @param initialM12 defines 2nd value of 1st row
  17217. * @param initialM13 defines 3rd value of 1st row
  17218. * @param initialM14 defines 4th value of 1st row
  17219. * @param initialM21 defines 1st value of 2nd row
  17220. * @param initialM22 defines 2nd value of 2nd row
  17221. * @param initialM23 defines 3rd value of 2nd row
  17222. * @param initialM24 defines 4th value of 2nd row
  17223. * @param initialM31 defines 1st value of 3rd row
  17224. * @param initialM32 defines 2nd value of 3rd row
  17225. * @param initialM33 defines 3rd value of 3rd row
  17226. * @param initialM34 defines 4th value of 3rd row
  17227. * @param initialM41 defines 1st value of 4th row
  17228. * @param initialM42 defines 2nd value of 4th row
  17229. * @param initialM43 defines 3rd value of 4th row
  17230. * @param initialM44 defines 4th value of 4th row
  17231. * @param result defines the target matrix
  17232. */
  17233. 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;
  17234. /**
  17235. * Gets an identity matrix that must not be updated
  17236. */
  17237. static readonly IdentityReadOnly: Matrix;
  17238. /**
  17239. * Creates new matrix from a list of values (16)
  17240. * @param initialM11 defines 1st value of 1st row
  17241. * @param initialM12 defines 2nd value of 1st row
  17242. * @param initialM13 defines 3rd value of 1st row
  17243. * @param initialM14 defines 4th value of 1st row
  17244. * @param initialM21 defines 1st value of 2nd row
  17245. * @param initialM22 defines 2nd value of 2nd row
  17246. * @param initialM23 defines 3rd value of 2nd row
  17247. * @param initialM24 defines 4th value of 2nd row
  17248. * @param initialM31 defines 1st value of 3rd row
  17249. * @param initialM32 defines 2nd value of 3rd row
  17250. * @param initialM33 defines 3rd value of 3rd row
  17251. * @param initialM34 defines 4th value of 3rd row
  17252. * @param initialM41 defines 1st value of 4th row
  17253. * @param initialM42 defines 2nd value of 4th row
  17254. * @param initialM43 defines 3rd value of 4th row
  17255. * @param initialM44 defines 4th value of 4th row
  17256. * @returns the new matrix
  17257. */
  17258. 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;
  17259. /**
  17260. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  17261. * @param scale defines the scale vector3
  17262. * @param rotation defines the rotation quaternion
  17263. * @param translation defines the translation vector3
  17264. * @returns a new matrix
  17265. */
  17266. static Compose(scale: Vector3, rotation: Quaternion, translation: Vector3): Matrix;
  17267. /**
  17268. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  17269. * @param scale defines the scale vector3
  17270. * @param rotation defines the rotation quaternion
  17271. * @param translation defines the translation vector3
  17272. * @param result defines the target matrix
  17273. */
  17274. static ComposeToRef(scale: Vector3, rotation: Quaternion, translation: Vector3, result: Matrix): void;
  17275. /**
  17276. * Creates a new identity matrix
  17277. * @returns a new identity matrix
  17278. */
  17279. static Identity(): Matrix;
  17280. /**
  17281. * Creates a new identity matrix and stores the result in a given matrix
  17282. * @param result defines the target matrix
  17283. */
  17284. static IdentityToRef(result: Matrix): void;
  17285. /**
  17286. * Creates a new zero matrix
  17287. * @returns a new zero matrix
  17288. */
  17289. static Zero(): Matrix;
  17290. /**
  17291. * Creates a new rotation matrix for "angle" radians around the X axis
  17292. * @param angle defines the angle (in radians) to use
  17293. * @return the new matrix
  17294. */
  17295. static RotationX(angle: number): Matrix;
  17296. /**
  17297. * Creates a new matrix as the invert of a given matrix
  17298. * @param source defines the source matrix
  17299. * @returns the new matrix
  17300. */
  17301. static Invert(source: Matrix): Matrix;
  17302. /**
  17303. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  17304. * @param angle defines the angle (in radians) to use
  17305. * @param result defines the target matrix
  17306. */
  17307. static RotationXToRef(angle: number, result: Matrix): void;
  17308. /**
  17309. * Creates a new rotation matrix for "angle" radians around the Y axis
  17310. * @param angle defines the angle (in radians) to use
  17311. * @return the new matrix
  17312. */
  17313. static RotationY(angle: number): Matrix;
  17314. /**
  17315. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  17316. * @param angle defines the angle (in radians) to use
  17317. * @param result defines the target matrix
  17318. */
  17319. static RotationYToRef(angle: number, result: Matrix): void;
  17320. /**
  17321. * Creates a new rotation matrix for "angle" radians around the Z axis
  17322. * @param angle defines the angle (in radians) to use
  17323. * @return the new matrix
  17324. */
  17325. static RotationZ(angle: number): Matrix;
  17326. /**
  17327. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  17328. * @param angle defines the angle (in radians) to use
  17329. * @param result defines the target matrix
  17330. */
  17331. static RotationZToRef(angle: number, result: Matrix): void;
  17332. /**
  17333. * Creates a new rotation matrix for "angle" radians around the given axis
  17334. * @param axis defines the axis to use
  17335. * @param angle defines the angle (in radians) to use
  17336. * @return the new matrix
  17337. */
  17338. static RotationAxis(axis: Vector3, angle: number): Matrix;
  17339. /**
  17340. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  17341. * @param axis defines the axis to use
  17342. * @param angle defines the angle (in radians) to use
  17343. * @param result defines the target matrix
  17344. */
  17345. static RotationAxisToRef(axis: Vector3, angle: number, result: Matrix): void;
  17346. /**
  17347. * Creates a rotation matrix
  17348. * @param yaw defines the yaw angle in radians (Y axis)
  17349. * @param pitch defines the pitch angle in radians (X axis)
  17350. * @param roll defines the roll angle in radians (X axis)
  17351. * @returns the new rotation matrix
  17352. */
  17353. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  17354. /**
  17355. * Creates a rotation matrix and stores it in a given matrix
  17356. * @param yaw defines the yaw angle in radians (Y axis)
  17357. * @param pitch defines the pitch angle in radians (X axis)
  17358. * @param roll defines the roll angle in radians (X axis)
  17359. * @param result defines the target matrix
  17360. */
  17361. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  17362. /**
  17363. * Creates a scaling matrix
  17364. * @param x defines the scale factor on X axis
  17365. * @param y defines the scale factor on Y axis
  17366. * @param z defines the scale factor on Z axis
  17367. * @returns the new matrix
  17368. */
  17369. static Scaling(x: number, y: number, z: number): Matrix;
  17370. /**
  17371. * Creates a scaling matrix and stores it in a given matrix
  17372. * @param x defines the scale factor on X axis
  17373. * @param y defines the scale factor on Y axis
  17374. * @param z defines the scale factor on Z axis
  17375. * @param result defines the target matrix
  17376. */
  17377. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  17378. /**
  17379. * Creates a translation matrix
  17380. * @param x defines the translation on X axis
  17381. * @param y defines the translation on Y axis
  17382. * @param z defines the translationon Z axis
  17383. * @returns the new matrix
  17384. */
  17385. static Translation(x: number, y: number, z: number): Matrix;
  17386. /**
  17387. * Creates a translation matrix and stores it in a given matrix
  17388. * @param x defines the translation on X axis
  17389. * @param y defines the translation on Y axis
  17390. * @param z defines the translationon Z axis
  17391. * @param result defines the target matrix
  17392. */
  17393. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  17394. /**
  17395. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  17396. * @param startValue defines the start value
  17397. * @param endValue defines the end value
  17398. * @param gradient defines the gradient factor
  17399. * @returns the new matrix
  17400. */
  17401. static Lerp(startValue: Matrix, endValue: Matrix, gradient: number): Matrix;
  17402. /**
  17403. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  17404. * @param startValue defines the start value
  17405. * @param endValue defines the end value
  17406. * @param gradient defines the gradient factor
  17407. * @param result defines the Matrix object where to store data
  17408. */
  17409. static LerpToRef(startValue: Matrix, endValue: Matrix, gradient: number, result: Matrix): void;
  17410. /**
  17411. * Builds a new matrix whose values are computed by:
  17412. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  17413. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  17414. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  17415. * @param startValue defines the first matrix
  17416. * @param endValue defines the second matrix
  17417. * @param gradient defines the gradient between the two matrices
  17418. * @returns the new matrix
  17419. */
  17420. static DecomposeLerp(startValue: Matrix, endValue: Matrix, gradient: number): Matrix;
  17421. /**
  17422. * Update a matrix to values which are computed by:
  17423. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  17424. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  17425. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  17426. * @param startValue defines the first matrix
  17427. * @param endValue defines the second matrix
  17428. * @param gradient defines the gradient between the two matrices
  17429. * @param result defines the target matrix
  17430. */
  17431. static DecomposeLerpToRef(startValue: Matrix, endValue: Matrix, gradient: number, result: Matrix): void;
  17432. /**
  17433. * 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"
  17434. * This function works in left handed mode
  17435. * @param eye defines the final position of the entity
  17436. * @param target defines where the entity should look at
  17437. * @param up defines the up vector for the entity
  17438. * @returns the new matrix
  17439. */
  17440. static LookAtLH(eye: Vector3, target: Vector3, up: Vector3): Matrix;
  17441. /**
  17442. * 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".
  17443. * This function works in left handed mode
  17444. * @param eye defines the final position of the entity
  17445. * @param target defines where the entity should look at
  17446. * @param up defines the up vector for the entity
  17447. * @param result defines the target matrix
  17448. */
  17449. static LookAtLHToRef(eye: Vector3, target: Vector3, up: Vector3, result: Matrix): void;
  17450. /**
  17451. * 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"
  17452. * This function works in right handed mode
  17453. * @param eye defines the final position of the entity
  17454. * @param target defines where the entity should look at
  17455. * @param up defines the up vector for the entity
  17456. * @returns the new matrix
  17457. */
  17458. static LookAtRH(eye: Vector3, target: Vector3, up: Vector3): Matrix;
  17459. /**
  17460. * 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".
  17461. * This function works in right handed mode
  17462. * @param eye defines the final position of the entity
  17463. * @param target defines where the entity should look at
  17464. * @param up defines the up vector for the entity
  17465. * @param result defines the target matrix
  17466. */
  17467. static LookAtRHToRef(eye: Vector3, target: Vector3, up: Vector3, result: Matrix): void;
  17468. /**
  17469. * Create a left-handed orthographic projection matrix
  17470. * @param width defines the viewport width
  17471. * @param height defines the viewport height
  17472. * @param znear defines the near clip plane
  17473. * @param zfar defines the far clip plane
  17474. * @returns a new matrix as a left-handed orthographic projection matrix
  17475. */
  17476. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  17477. /**
  17478. * Store a left-handed orthographic projection to a given matrix
  17479. * @param width defines the viewport width
  17480. * @param height defines the viewport height
  17481. * @param znear defines the near clip plane
  17482. * @param zfar defines the far clip plane
  17483. * @param result defines the target matrix
  17484. */
  17485. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  17486. /**
  17487. * Create a left-handed orthographic projection matrix
  17488. * @param left defines the viewport left coordinate
  17489. * @param right defines the viewport right coordinate
  17490. * @param bottom defines the viewport bottom coordinate
  17491. * @param top defines the viewport top coordinate
  17492. * @param znear defines the near clip plane
  17493. * @param zfar defines the far clip plane
  17494. * @returns a new matrix as a left-handed orthographic projection matrix
  17495. */
  17496. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  17497. /**
  17498. * Stores a left-handed orthographic projection into a given matrix
  17499. * @param left defines the viewport left coordinate
  17500. * @param right defines the viewport right coordinate
  17501. * @param bottom defines the viewport bottom coordinate
  17502. * @param top defines the viewport top coordinate
  17503. * @param znear defines the near clip plane
  17504. * @param zfar defines the far clip plane
  17505. * @param result defines the target matrix
  17506. */
  17507. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  17508. /**
  17509. * Creates a right-handed orthographic projection matrix
  17510. * @param left defines the viewport left coordinate
  17511. * @param right defines the viewport right coordinate
  17512. * @param bottom defines the viewport bottom coordinate
  17513. * @param top defines the viewport top coordinate
  17514. * @param znear defines the near clip plane
  17515. * @param zfar defines the far clip plane
  17516. * @returns a new matrix as a right-handed orthographic projection matrix
  17517. */
  17518. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  17519. /**
  17520. * Stores a right-handed orthographic projection into a given matrix
  17521. * @param left defines the viewport left coordinate
  17522. * @param right defines the viewport right coordinate
  17523. * @param bottom defines the viewport bottom coordinate
  17524. * @param top defines the viewport top coordinate
  17525. * @param znear defines the near clip plane
  17526. * @param zfar defines the far clip plane
  17527. * @param result defines the target matrix
  17528. */
  17529. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  17530. /**
  17531. * Creates a left-handed perspective projection matrix
  17532. * @param width defines the viewport width
  17533. * @param height defines the viewport height
  17534. * @param znear defines the near clip plane
  17535. * @param zfar defines the far clip plane
  17536. * @returns a new matrix as a left-handed perspective projection matrix
  17537. */
  17538. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  17539. /**
  17540. * Creates a left-handed perspective projection matrix
  17541. * @param fov defines the horizontal field of view
  17542. * @param aspect defines the aspect ratio
  17543. * @param znear defines the near clip plane
  17544. * @param zfar defines the far clip plane
  17545. * @returns a new matrix as a left-handed perspective projection matrix
  17546. */
  17547. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  17548. /**
  17549. * Stores a left-handed perspective projection into a given matrix
  17550. * @param fov defines the horizontal field of view
  17551. * @param aspect defines the aspect ratio
  17552. * @param znear defines the near clip plane
  17553. * @param zfar defines the far clip plane
  17554. * @param result defines the target matrix
  17555. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  17556. */
  17557. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  17558. /**
  17559. * Creates a right-handed perspective projection matrix
  17560. * @param fov defines the horizontal field of view
  17561. * @param aspect defines the aspect ratio
  17562. * @param znear defines the near clip plane
  17563. * @param zfar defines the far clip plane
  17564. * @returns a new matrix as a right-handed perspective projection matrix
  17565. */
  17566. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  17567. /**
  17568. * Stores a right-handed perspective projection into a given matrix
  17569. * @param fov defines the horizontal field of view
  17570. * @param aspect defines the aspect ratio
  17571. * @param znear defines the near clip plane
  17572. * @param zfar defines the far clip plane
  17573. * @param result defines the target matrix
  17574. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  17575. */
  17576. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  17577. /**
  17578. * Stores a perspective projection for WebVR info a given matrix
  17579. * @param fov defines the field of view
  17580. * @param znear defines the near clip plane
  17581. * @param zfar defines the far clip plane
  17582. * @param result defines the target matrix
  17583. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  17584. */
  17585. static PerspectiveFovWebVRToRef(fov: {
  17586. upDegrees: number;
  17587. downDegrees: number;
  17588. leftDegrees: number;
  17589. rightDegrees: number;
  17590. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  17591. /**
  17592. * Computes a complete transformation matrix
  17593. * @param viewport defines the viewport to use
  17594. * @param world defines the world matrix
  17595. * @param view defines the view matrix
  17596. * @param projection defines the projection matrix
  17597. * @param zmin defines the near clip plane
  17598. * @param zmax defines the far clip plane
  17599. * @returns the transformation matrix
  17600. */
  17601. static GetFinalMatrix(viewport: Viewport, world: Matrix, view: Matrix, projection: Matrix, zmin: number, zmax: number): Matrix;
  17602. /**
  17603. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  17604. * @param matrix defines the matrix to use
  17605. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  17606. */
  17607. static GetAsMatrix2x2(matrix: Matrix): Float32Array;
  17608. /**
  17609. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  17610. * @param matrix defines the matrix to use
  17611. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  17612. */
  17613. static GetAsMatrix3x3(matrix: Matrix): Float32Array;
  17614. /**
  17615. * Compute the transpose of a given matrix
  17616. * @param matrix defines the matrix to transpose
  17617. * @returns the new matrix
  17618. */
  17619. static Transpose(matrix: Matrix): Matrix;
  17620. /**
  17621. * Compute the transpose of a matrix and store it in a target matrix
  17622. * @param matrix defines the matrix to transpose
  17623. * @param result defines the target matrix
  17624. */
  17625. static TransposeToRef(matrix: Matrix, result: Matrix): void;
  17626. /**
  17627. * Computes a reflection matrix from a plane
  17628. * @param plane defines the reflection plane
  17629. * @returns a new matrix
  17630. */
  17631. static Reflection(plane: Plane): Matrix;
  17632. /**
  17633. * Computes a reflection matrix from a plane
  17634. * @param plane defines the reflection plane
  17635. * @param result defines the target matrix
  17636. */
  17637. static ReflectionToRef(plane: Plane, result: Matrix): void;
  17638. /**
  17639. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  17640. * @param xaxis defines the value of the 1st axis
  17641. * @param yaxis defines the value of the 2nd axis
  17642. * @param zaxis defines the value of the 3rd axis
  17643. * @param result defines the target matrix
  17644. */
  17645. static FromXYZAxesToRef(xaxis: Vector3, yaxis: Vector3, zaxis: Vector3, result: Matrix): void;
  17646. /**
  17647. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  17648. * @param quat defines the quaternion to use
  17649. * @param result defines the target matrix
  17650. */
  17651. static FromQuaternionToRef(quat: Quaternion, result: Matrix): void;
  17652. }
  17653. class Plane {
  17654. normal: Vector3;
  17655. d: number;
  17656. /**
  17657. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  17658. */
  17659. constructor(a: number, b: number, c: number, d: number);
  17660. /**
  17661. * Returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  17662. */
  17663. asArray(): number[];
  17664. /**
  17665. * Returns a new plane copied from the current Plane.
  17666. */
  17667. clone(): Plane;
  17668. /**
  17669. * Returns the string "Plane".
  17670. */
  17671. getClassName(): string;
  17672. /**
  17673. * Returns the Plane hash code.
  17674. */
  17675. getHashCode(): number;
  17676. /**
  17677. * Normalize the current Plane in place.
  17678. * Returns the updated Plane.
  17679. */
  17680. normalize(): Plane;
  17681. /**
  17682. * Returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  17683. */
  17684. transform(transformation: Matrix): Plane;
  17685. /**
  17686. * Returns the dot product (float) of the point coordinates and the plane normal.
  17687. */
  17688. dotCoordinate(point: Vector3): number;
  17689. /**
  17690. * Updates the current Plane from the plane defined by the three given points.
  17691. * Returns the updated Plane.
  17692. */
  17693. copyFromPoints(point1: Vector3, point2: Vector3, point3: Vector3): Plane;
  17694. /**
  17695. * Boolean : True is the vector "direction" is the same side than the plane normal.
  17696. */
  17697. isFrontFacingTo(direction: Vector3, epsilon: number): boolean;
  17698. /**
  17699. * Returns the signed distance (float) from the given point to the Plane.
  17700. */
  17701. signedDistanceTo(point: Vector3): number;
  17702. /**
  17703. * Returns a new Plane from the given array.
  17704. */
  17705. static FromArray(array: ArrayLike<number>): Plane;
  17706. /**
  17707. * Returns a new Plane defined by the three given points.
  17708. */
  17709. static FromPoints(point1: Vector3, point2: Vector3, point3: Vector3): Plane;
  17710. /**
  17711. * Returns a new Plane the normal vector to this plane at the given origin point.
  17712. * Note : the vector "normal" is updated because normalized.
  17713. */
  17714. static FromPositionAndNormal(origin: Vector3, normal: Vector3): Plane;
  17715. /**
  17716. * Returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  17717. */
  17718. static SignedDistanceToPlaneFromPositionAndNormal(origin: Vector3, normal: Vector3, point: Vector3): number;
  17719. }
  17720. class Viewport {
  17721. x: number;
  17722. y: number;
  17723. width: number;
  17724. height: number;
  17725. /**
  17726. * Creates a Viewport object located at (x, y) and sized (width, height).
  17727. */
  17728. constructor(x: number, y: number, width: number, height: number);
  17729. toGlobal(renderWidthOrEngine: number | Engine, renderHeight: number): Viewport;
  17730. /**
  17731. * Returns a new Viewport copied from the current one.
  17732. */
  17733. clone(): Viewport;
  17734. }
  17735. class Frustum {
  17736. /**
  17737. * Returns a new array of 6 Frustum planes computed by the given transformation matrix.
  17738. */
  17739. static GetPlanes(transform: Matrix): Plane[];
  17740. static GetNearPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  17741. static GetFarPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  17742. static GetLeftPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  17743. static GetRightPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  17744. static GetTopPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  17745. static GetBottomPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  17746. /**
  17747. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  17748. */
  17749. static GetPlanesToRef(transform: Matrix, frustumPlanes: Plane[]): void;
  17750. }
  17751. /** Defines supported spaces */
  17752. enum Space {
  17753. /** Local (object) space */
  17754. LOCAL = 0,
  17755. /** World space */
  17756. WORLD = 1,
  17757. /** Bone space */
  17758. BONE = 2,
  17759. }
  17760. /** Defines the 3 main axes */
  17761. class Axis {
  17762. /** X axis */
  17763. static X: Vector3;
  17764. /** Y axis */
  17765. static Y: Vector3;
  17766. /** Z axis */
  17767. static Z: Vector3;
  17768. }
  17769. class BezierCurve {
  17770. /**
  17771. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats.
  17772. */
  17773. static interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  17774. }
  17775. /**
  17776. * Defines potential orientation for back face culling
  17777. */
  17778. enum Orientation {
  17779. /**
  17780. * Clockwise
  17781. */
  17782. CW = 0,
  17783. /** Counter clockwise */
  17784. CCW = 1,
  17785. }
  17786. /**
  17787. * Defines angle representation
  17788. */
  17789. class Angle {
  17790. private _radians;
  17791. /**
  17792. * Creates an Angle object of "radians" radians (float).
  17793. */
  17794. constructor(radians: number);
  17795. /**
  17796. * Get value in degrees
  17797. * @returns the Angle value in degrees (float)
  17798. */
  17799. degrees(): number;
  17800. /**
  17801. * Get value in radians
  17802. * @returns the Angle value in radians (float)
  17803. */
  17804. radians(): number;
  17805. /**
  17806. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  17807. * @param a defines first vector
  17808. * @param b defines second vector
  17809. * @returns a new Angle
  17810. */
  17811. static BetweenTwoPoints(a: Vector2, b: Vector2): Angle;
  17812. /**
  17813. * Gets a new Angle object from the given float in radians
  17814. * @param radians defines the angle value in radians
  17815. * @returns a new Angle
  17816. */
  17817. static FromRadians(radians: number): Angle;
  17818. /**
  17819. * Gets a new Angle object from the given float in degrees
  17820. * @param degrees defines the angle value in degrees
  17821. * @returns a new Angle
  17822. */
  17823. static FromDegrees(degrees: number): Angle;
  17824. }
  17825. class Arc2 {
  17826. startPoint: Vector2;
  17827. midPoint: Vector2;
  17828. endPoint: Vector2;
  17829. centerPoint: Vector2;
  17830. radius: number;
  17831. angle: Angle;
  17832. startAngle: Angle;
  17833. orientation: Orientation;
  17834. /**
  17835. * Creates an Arc object from the three given points : start, middle and end.
  17836. */
  17837. constructor(startPoint: Vector2, midPoint: Vector2, endPoint: Vector2);
  17838. }
  17839. class Path2 {
  17840. private _points;
  17841. private _length;
  17842. closed: boolean;
  17843. /**
  17844. * Creates a Path2 object from the starting 2D coordinates x and y.
  17845. */
  17846. constructor(x: number, y: number);
  17847. /**
  17848. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  17849. * Returns the updated Path2.
  17850. */
  17851. addLineTo(x: number, y: number): Path2;
  17852. /**
  17853. * 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.
  17854. * Returns the updated Path2.
  17855. */
  17856. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  17857. /**
  17858. * Closes the Path2.
  17859. * Returns the Path2.
  17860. */
  17861. close(): Path2;
  17862. /**
  17863. * Returns the Path2 total length (float).
  17864. */
  17865. length(): number;
  17866. /**
  17867. * Returns the Path2 internal array of points.
  17868. */
  17869. getPoints(): Vector2[];
  17870. /**
  17871. * Returns a new Vector2 located at a percentage of the Path2 total length on this path.
  17872. */
  17873. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  17874. /**
  17875. * Returns a new Path2 starting at the coordinates (x, y).
  17876. */
  17877. static StartingAt(x: number, y: number): Path2;
  17878. }
  17879. class Path3D {
  17880. path: Vector3[];
  17881. private _curve;
  17882. private _distances;
  17883. private _tangents;
  17884. private _normals;
  17885. private _binormals;
  17886. private _raw;
  17887. /**
  17888. * new Path3D(path, normal, raw)
  17889. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  17890. * please read the description in the tutorial : http://doc.babylonjs.com/tutorials/How_to_use_Path3D
  17891. * path : an array of Vector3, the curve axis of the Path3D
  17892. * normal (optional) : Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  17893. * raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  17894. */
  17895. constructor(path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  17896. /**
  17897. * Returns the Path3D array of successive Vector3 designing its curve.
  17898. */
  17899. getCurve(): Vector3[];
  17900. /**
  17901. * Returns an array populated with tangent vectors on each Path3D curve point.
  17902. */
  17903. getTangents(): Vector3[];
  17904. /**
  17905. * Returns an array populated with normal vectors on each Path3D curve point.
  17906. */
  17907. getNormals(): Vector3[];
  17908. /**
  17909. * Returns an array populated with binormal vectors on each Path3D curve point.
  17910. */
  17911. getBinormals(): Vector3[];
  17912. /**
  17913. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  17914. */
  17915. getDistances(): number[];
  17916. /**
  17917. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  17918. * Returns the same object updated.
  17919. */
  17920. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  17921. private _compute(firstNormal);
  17922. private _getFirstNonNullVector(index);
  17923. private _getLastNonNullVector(index);
  17924. private _normalVector(v0, vt, va);
  17925. }
  17926. class Curve3 {
  17927. private _points;
  17928. private _length;
  17929. /**
  17930. * Returns a Curve3 object along a Quadratic Bezier curve : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#quadratic-bezier-curve
  17931. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  17932. * @param v1 (Vector3) the control point
  17933. * @param v2 (Vector3) the end point of the Quadratic Bezier
  17934. * @param nbPoints (integer) the wanted number of points in the curve
  17935. */
  17936. static CreateQuadraticBezier(v0: Vector3, v1: Vector3, v2: Vector3, nbPoints: number): Curve3;
  17937. /**
  17938. * Returns a Curve3 object along a Cubic Bezier curve : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#cubic-bezier-curve
  17939. * @param v0 (Vector3) the origin point of the Cubic Bezier
  17940. * @param v1 (Vector3) the first control point
  17941. * @param v2 (Vector3) the second control point
  17942. * @param v3 (Vector3) the end point of the Cubic Bezier
  17943. * @param nbPoints (integer) the wanted number of points in the curve
  17944. */
  17945. static CreateCubicBezier(v0: Vector3, v1: Vector3, v2: Vector3, v3: Vector3, nbPoints: number): Curve3;
  17946. /**
  17947. * Returns a Curve3 object along a Hermite Spline curve : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#hermite-spline
  17948. * @param p1 (Vector3) the origin point of the Hermite Spline
  17949. * @param t1 (Vector3) the tangent vector at the origin point
  17950. * @param p2 (Vector3) the end point of the Hermite Spline
  17951. * @param t2 (Vector3) the tangent vector at the end point
  17952. * @param nbPoints (integer) the wanted number of points in the curve
  17953. */
  17954. static CreateHermiteSpline(p1: Vector3, t1: Vector3, p2: Vector3, t2: Vector3, nbPoints: number): Curve3;
  17955. /**
  17956. * Returns a Curve3 object along a CatmullRom Spline curve :
  17957. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  17958. * @param nbPoints (integer) the wanted number of points between each curve control points
  17959. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  17960. */
  17961. static CreateCatmullRomSpline(points: Vector3[], nbPoints: number, closed?: boolean): Curve3;
  17962. /**
  17963. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  17964. * A Curve3 is designed from a series of successive Vector3.
  17965. * Tuto : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#curve3-object
  17966. */
  17967. constructor(points: Vector3[]);
  17968. /**
  17969. * Returns the Curve3 stored array of successive Vector3
  17970. */
  17971. getPoints(): Vector3[];
  17972. /**
  17973. * Returns the computed length (float) of the curve.
  17974. */
  17975. length(): number;
  17976. /**
  17977. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  17978. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  17979. * curveA and curveB keep unchanged.
  17980. */
  17981. continue(curve: Curve3): Curve3;
  17982. private _computeLength(path);
  17983. }
  17984. class PositionNormalVertex {
  17985. position: Vector3;
  17986. normal: Vector3;
  17987. constructor(position?: Vector3, normal?: Vector3);
  17988. clone(): PositionNormalVertex;
  17989. }
  17990. class PositionNormalTextureVertex {
  17991. position: Vector3;
  17992. normal: Vector3;
  17993. uv: Vector2;
  17994. constructor(position?: Vector3, normal?: Vector3, uv?: Vector2);
  17995. clone(): PositionNormalTextureVertex;
  17996. }
  17997. class Tmp {
  17998. static Color3: Color3[];
  17999. static Vector2: Vector2[];
  18000. static Vector3: Vector3[];
  18001. static Vector4: Vector4[];
  18002. static Quaternion: Quaternion[];
  18003. static Matrix: Matrix[];
  18004. }
  18005. }
  18006. declare module BABYLON {
  18007. class SphericalPolynomial {
  18008. x: Vector3;
  18009. y: Vector3;
  18010. z: Vector3;
  18011. xx: Vector3;
  18012. yy: Vector3;
  18013. zz: Vector3;
  18014. xy: Vector3;
  18015. yz: Vector3;
  18016. zx: Vector3;
  18017. addAmbient(color: Color3): void;
  18018. static getSphericalPolynomialFromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  18019. scale(scale: number): void;
  18020. }
  18021. class SphericalHarmonics {
  18022. L00: Vector3;
  18023. L1_1: Vector3;
  18024. L10: Vector3;
  18025. L11: Vector3;
  18026. L2_2: Vector3;
  18027. L2_1: Vector3;
  18028. L20: Vector3;
  18029. L21: Vector3;
  18030. L22: Vector3;
  18031. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  18032. scale(scale: number): void;
  18033. convertIncidentRadianceToIrradiance(): void;
  18034. convertIrradianceToLambertianRadiance(): void;
  18035. static getsphericalHarmonicsFromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  18036. }
  18037. }
  18038. declare module BABYLON {
  18039. /**
  18040. * Defines a target to use with MorphTargetManager
  18041. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  18042. */
  18043. class MorphTarget implements IAnimatable {
  18044. /** defines the name of the target */
  18045. name: string;
  18046. /**
  18047. * Gets or sets the list of animations
  18048. */
  18049. animations: Animation[];
  18050. private _scene;
  18051. private _positions;
  18052. private _normals;
  18053. private _tangents;
  18054. private _influence;
  18055. /**
  18056. * Observable raised when the influence changes
  18057. */
  18058. onInfluenceChanged: Observable<boolean>;
  18059. /**
  18060. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  18061. */
  18062. influence: number;
  18063. private _animationPropertiesOverride;
  18064. /**
  18065. * Gets or sets the animation properties override
  18066. */
  18067. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  18068. /**
  18069. * Creates a new MorphTarget
  18070. * @param name defines the name of the target
  18071. * @param influence defines the influence to use
  18072. */
  18073. constructor(
  18074. /** defines the name of the target */
  18075. name: string, influence?: number, scene?: Nullable<Scene>);
  18076. /**
  18077. * Gets a boolean defining if the target contains position data
  18078. */
  18079. readonly hasPositions: boolean;
  18080. /**
  18081. * Gets a boolean defining if the target contains normal data
  18082. */
  18083. readonly hasNormals: boolean;
  18084. /**
  18085. * Gets a boolean defining if the target contains tangent data
  18086. */
  18087. readonly hasTangents: boolean;
  18088. /**
  18089. * Affects position data to this target
  18090. * @param data defines the position data to use
  18091. */
  18092. setPositions(data: Nullable<FloatArray>): void;
  18093. /**
  18094. * Gets the position data stored in this target
  18095. * @returns a FloatArray containing the position data (or null if not present)
  18096. */
  18097. getPositions(): Nullable<FloatArray>;
  18098. /**
  18099. * Affects normal data to this target
  18100. * @param data defines the normal data to use
  18101. */
  18102. setNormals(data: Nullable<FloatArray>): void;
  18103. /**
  18104. * Gets the normal data stored in this target
  18105. * @returns a FloatArray containing the normal data (or null if not present)
  18106. */
  18107. getNormals(): Nullable<FloatArray>;
  18108. /**
  18109. * Affects tangent data to this target
  18110. * @param data defines the tangent data to use
  18111. */
  18112. setTangents(data: Nullable<FloatArray>): void;
  18113. /**
  18114. * Gets the tangent data stored in this target
  18115. * @returns a FloatArray containing the tangent data (or null if not present)
  18116. */
  18117. getTangents(): Nullable<FloatArray>;
  18118. /**
  18119. * Serializes the current target into a Serialization object
  18120. * @returns the serialized object
  18121. */
  18122. serialize(): any;
  18123. /**
  18124. * Creates a new target from serialized data
  18125. * @param serializationObject defines the serialized data to use
  18126. * @returns a new MorphTarget
  18127. */
  18128. static Parse(serializationObject: any): MorphTarget;
  18129. /**
  18130. * Creates a MorphTarget from mesh data
  18131. * @param mesh defines the source mesh
  18132. * @param name defines the name to use for the new target
  18133. * @param influence defines the influence to attach to the target
  18134. * @returns a new MorphTarget
  18135. */
  18136. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  18137. }
  18138. }
  18139. declare module BABYLON {
  18140. /**
  18141. * This class is used to deform meshes using morphing between different targets
  18142. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  18143. */
  18144. class MorphTargetManager {
  18145. private _targets;
  18146. private _targetObservable;
  18147. private _activeTargets;
  18148. private _scene;
  18149. private _influences;
  18150. private _supportsNormals;
  18151. private _supportsTangents;
  18152. private _vertexCount;
  18153. private _uniqueId;
  18154. private _tempInfluences;
  18155. /**
  18156. * Creates a new MorphTargetManager
  18157. * @param scene defines the current scene
  18158. */
  18159. constructor(scene?: Nullable<Scene>);
  18160. /**
  18161. * Gets the unique ID of this manager
  18162. */
  18163. readonly uniqueId: number;
  18164. /**
  18165. * Gets the number of vertices handled by this manager
  18166. */
  18167. readonly vertexCount: number;
  18168. /**
  18169. * Gets a boolean indicating if this manager supports morphing of normals
  18170. */
  18171. readonly supportsNormals: boolean;
  18172. /**
  18173. * Gets a boolean indicating if this manager supports morphing of tangents
  18174. */
  18175. readonly supportsTangents: boolean;
  18176. /**
  18177. * Gets the number of targets stored in this manager
  18178. */
  18179. readonly numTargets: number;
  18180. /**
  18181. * Gets the number of influencers (ie. the number of targets with influences > 0)
  18182. */
  18183. readonly numInfluencers: number;
  18184. /**
  18185. * Gets the list of influences (one per target)
  18186. */
  18187. readonly influences: Float32Array;
  18188. /**
  18189. * Gets the active target at specified index. An active target is a target with an influence > 0
  18190. * @param index defines the index to check
  18191. * @returns the requested target
  18192. */
  18193. getActiveTarget(index: number): MorphTarget;
  18194. /**
  18195. * Gets the target at specified index
  18196. * @param index defines the index to check
  18197. * @returns the requested target
  18198. */
  18199. getTarget(index: number): MorphTarget;
  18200. /**
  18201. * Add a new target to this manager
  18202. * @param target defines the target to add
  18203. */
  18204. addTarget(target: MorphTarget): void;
  18205. /**
  18206. * Removes a target from the manager
  18207. * @param target defines the target to remove
  18208. */
  18209. removeTarget(target: MorphTarget): void;
  18210. /**
  18211. * Serializes the current manager into a Serialization object
  18212. * @returns the serialized object
  18213. */
  18214. serialize(): any;
  18215. private _syncActiveTargets(needUpdate);
  18216. /**
  18217. * Syncrhonize the targets with all the meshes using this morph target manager
  18218. */
  18219. synchronize(): void;
  18220. /**
  18221. * Creates a new MorphTargetManager from serialized data
  18222. * @param serializationObject defines the serialized data
  18223. * @param scene defines the hosting scene
  18224. * @returns the new MorphTargetManager
  18225. */
  18226. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  18227. }
  18228. }
  18229. declare module BABYLON {
  18230. /**
  18231. * Class used to store all common mesh properties
  18232. */
  18233. class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  18234. /** No occlusion */
  18235. static OCCLUSION_TYPE_NONE: number;
  18236. /** Occlusion set to optimisitic */
  18237. static OCCLUSION_TYPE_OPTIMISTIC: number;
  18238. /** Occlusion set to strict */
  18239. static OCCLUSION_TYPE_STRICT: number;
  18240. /** Use an accurante occlusion algorithm */
  18241. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  18242. /** Use a conservative occlusion algorithm */
  18243. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  18244. /**
  18245. * No billboard
  18246. */
  18247. static readonly BILLBOARDMODE_NONE: number;
  18248. /** Billboard on X axis */
  18249. static readonly BILLBOARDMODE_X: number;
  18250. /** Billboard on Y axis */
  18251. static readonly BILLBOARDMODE_Y: number;
  18252. /** Billboard on Z axis */
  18253. static readonly BILLBOARDMODE_Z: number;
  18254. /** Billboard on all axes */
  18255. static readonly BILLBOARDMODE_ALL: number;
  18256. private _facetPositions;
  18257. private _facetNormals;
  18258. private _facetPartitioning;
  18259. private _facetNb;
  18260. private _partitioningSubdivisions;
  18261. private _partitioningBBoxRatio;
  18262. private _facetDataEnabled;
  18263. private _facetParameters;
  18264. private _bbSize;
  18265. private _subDiv;
  18266. private _facetDepthSort;
  18267. private _facetDepthSortEnabled;
  18268. private _depthSortedIndices;
  18269. private _depthSortedFacets;
  18270. private _facetDepthSortFunction;
  18271. private _facetDepthSortFrom;
  18272. private _facetDepthSortOrigin;
  18273. private _invertedMatrix;
  18274. /**
  18275. * Gets the number of facets in the mesh
  18276. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  18277. */
  18278. readonly facetNb: number;
  18279. /**
  18280. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  18281. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  18282. */
  18283. partitioningSubdivisions: number;
  18284. /**
  18285. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  18286. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  18287. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  18288. */
  18289. partitioningBBoxRatio: number;
  18290. /**
  18291. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  18292. * Works only for updatable meshes.
  18293. * Doesn't work with multi-materials
  18294. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  18295. */
  18296. mustDepthSortFacets: boolean;
  18297. /**
  18298. * The location (Vector3) where the facet depth sort must be computed from.
  18299. * By default, the active camera position.
  18300. * Used only when facet depth sort is enabled
  18301. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  18302. */
  18303. facetDepthSortFrom: Vector3;
  18304. /**
  18305. * gets a boolean indicating if facetData is enabled
  18306. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  18307. */
  18308. readonly isFacetDataEnabled: boolean;
  18309. /** @hidden */
  18310. _updateNonUniformScalingState(value: boolean): boolean;
  18311. /**
  18312. * An event triggered when this mesh collides with another one
  18313. */
  18314. onCollideObservable: Observable<AbstractMesh>;
  18315. private _onCollideObserver;
  18316. /** Set a function to call when this mesh collides with another one */
  18317. onCollide: () => void;
  18318. /**
  18319. * An event triggered when the collision's position changes
  18320. */
  18321. onCollisionPositionChangeObservable: Observable<Vector3>;
  18322. private _onCollisionPositionChangeObserver;
  18323. /** Set a function to call when the collision's position changes */
  18324. onCollisionPositionChange: () => void;
  18325. /**
  18326. * An event triggered when material is changed
  18327. */
  18328. onMaterialChangedObservable: Observable<AbstractMesh>;
  18329. /**
  18330. * Gets or sets the orientation for POV movement & rotation
  18331. */
  18332. definedFacingForward: boolean;
  18333. /**
  18334. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  18335. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  18336. * * 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.
  18337. * @see http://doc.babylonjs.com/features/occlusionquery
  18338. */
  18339. occlusionQueryAlgorithmType: number;
  18340. /**
  18341. * 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:
  18342. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  18343. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  18344. * * 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.
  18345. * @see http://doc.babylonjs.com/features/occlusionquery
  18346. */
  18347. occlusionType: number;
  18348. /**
  18349. * 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.
  18350. * The default value is -1 which means don't break the query and wait till the result
  18351. * @see http://doc.babylonjs.com/features/occlusionquery
  18352. */
  18353. occlusionRetryCount: number;
  18354. private _occlusionInternalRetryCounter;
  18355. protected _isOccluded: boolean;
  18356. /**
  18357. * 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
  18358. * @see http://doc.babylonjs.com/features/occlusionquery
  18359. */
  18360. isOccluded: boolean;
  18361. private _isOcclusionQueryInProgress;
  18362. /**
  18363. * Flag to check the progress status of the query
  18364. * @see http://doc.babylonjs.com/features/occlusionquery
  18365. */
  18366. readonly isOcclusionQueryInProgress: boolean;
  18367. private _occlusionQuery;
  18368. private _visibility;
  18369. /**
  18370. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  18371. */
  18372. /**
  18373. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  18374. */
  18375. visibility: number;
  18376. /** Gets or sets the alpha index used to sort transparent meshes
  18377. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  18378. */
  18379. alphaIndex: number;
  18380. /**
  18381. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  18382. */
  18383. isVisible: boolean;
  18384. /**
  18385. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  18386. */
  18387. isPickable: boolean;
  18388. /**
  18389. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  18390. */
  18391. showBoundingBox: boolean;
  18392. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  18393. showSubMeshesBoundingBox: boolean;
  18394. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  18395. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  18396. */
  18397. isBlocker: boolean;
  18398. /**
  18399. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  18400. */
  18401. enablePointerMoveEvents: boolean;
  18402. /**
  18403. * Specifies the rendering group id for this mesh (0 by default)
  18404. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  18405. */
  18406. renderingGroupId: number;
  18407. private _material;
  18408. /** Gets or sets current material */
  18409. material: Nullable<Material>;
  18410. private _receiveShadows;
  18411. /**
  18412. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  18413. * @see http://doc.babylonjs.com/babylon101/shadows
  18414. */
  18415. receiveShadows: boolean;
  18416. /**
  18417. * Gets or sets a boolean indicating if the outline must be rendered as well
  18418. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  18419. */
  18420. renderOutline: boolean;
  18421. /** Defines color to use when rendering outline */
  18422. outlineColor: Color3;
  18423. /** Define width to use when rendering outline */
  18424. outlineWidth: number;
  18425. /**
  18426. * Gets or sets a boolean indicating if the overlay must be rendered as well
  18427. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  18428. */
  18429. renderOverlay: boolean;
  18430. /** Defines color to use when rendering overlay */
  18431. overlayColor: Color3;
  18432. /** Defines alpha to use when rendering overlay */
  18433. overlayAlpha: number;
  18434. private _hasVertexAlpha;
  18435. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  18436. hasVertexAlpha: boolean;
  18437. private _useVertexColors;
  18438. /** 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) */
  18439. useVertexColors: boolean;
  18440. private _computeBonesUsingShaders;
  18441. /**
  18442. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  18443. */
  18444. computeBonesUsingShaders: boolean;
  18445. private _numBoneInfluencers;
  18446. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  18447. numBoneInfluencers: number;
  18448. private _applyFog;
  18449. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  18450. applyFog: boolean;
  18451. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  18452. useOctreeForRenderingSelection: boolean;
  18453. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  18454. useOctreeForPicking: boolean;
  18455. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  18456. useOctreeForCollisions: boolean;
  18457. private _layerMask;
  18458. /**
  18459. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  18460. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  18461. */
  18462. layerMask: number;
  18463. /**
  18464. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  18465. */
  18466. alwaysSelectAsActiveMesh: boolean;
  18467. /**
  18468. * Gets or sets the current action manager
  18469. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18470. */
  18471. actionManager: Nullable<ActionManager>;
  18472. /**
  18473. * Gets or sets impostor used for physic simulation
  18474. * @see http://doc.babylonjs.com/features/physics_engine
  18475. */
  18476. physicsImpostor: Nullable<PhysicsImpostor>;
  18477. private _checkCollisions;
  18478. private _collisionMask;
  18479. private _collisionGroup;
  18480. /**
  18481. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  18482. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  18483. */
  18484. ellipsoid: Vector3;
  18485. /**
  18486. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  18487. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  18488. */
  18489. ellipsoidOffset: Vector3;
  18490. private _collider;
  18491. private _oldPositionForCollisions;
  18492. private _diffPositionForCollisions;
  18493. /**
  18494. * Gets or sets a collision mask used to mask collisions (default is -1).
  18495. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  18496. */
  18497. collisionMask: number;
  18498. /**
  18499. * Gets or sets the current collision group mask (-1 by default).
  18500. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  18501. */
  18502. collisionGroup: number;
  18503. /**
  18504. * Defines edge width used when edgesRenderer is enabled
  18505. * @see https://www.babylonjs-playground.com/#10OJSG#13
  18506. */
  18507. edgesWidth: number;
  18508. /**
  18509. * Defines edge color used when edgesRenderer is enabled
  18510. * @see https://www.babylonjs-playground.com/#10OJSG#13
  18511. */
  18512. edgesColor: Color4;
  18513. /** @hidden */
  18514. _edgesRenderer: Nullable<EdgesRenderer>;
  18515. private _collisionsTransformMatrix;
  18516. private _collisionsScalingMatrix;
  18517. /** @hidden */
  18518. _masterMesh: Nullable<AbstractMesh>;
  18519. /** @hidden */
  18520. _boundingInfo: Nullable<BoundingInfo>;
  18521. /** @hidden */
  18522. _renderId: number;
  18523. /**
  18524. * Gets or sets the list of subMeshes
  18525. * @see http://doc.babylonjs.com/how_to/multi_materials
  18526. */
  18527. subMeshes: SubMesh[];
  18528. /** @hidden */
  18529. _submeshesOctree: Octree<SubMesh>;
  18530. /** @hidden */
  18531. _intersectionsInProgress: AbstractMesh[];
  18532. /** @hidden */
  18533. _unIndexed: boolean;
  18534. /** @hidden */
  18535. _lightSources: Light[];
  18536. /** @hidden */
  18537. readonly _positions: Nullable<Vector3[]>;
  18538. /** @hidden */
  18539. _waitingActions: any;
  18540. /** @hidden */
  18541. _waitingFreezeWorldMatrix: Nullable<boolean>;
  18542. private _skeleton;
  18543. /** @hidden */
  18544. _bonesTransformMatrices: Nullable<Float32Array>;
  18545. /**
  18546. * Gets or sets a skeleton to apply skining transformations
  18547. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  18548. */
  18549. skeleton: Nullable<Skeleton>;
  18550. /**
  18551. * Creates a new AbstractMesh
  18552. * @param name defines the name of the mesh
  18553. * @param scene defines the hosting scene
  18554. */
  18555. constructor(name: string, scene?: Nullable<Scene>);
  18556. /**
  18557. * Returns the string "AbstractMesh"
  18558. * @returns "AbstractMesh"
  18559. */
  18560. getClassName(): string;
  18561. /**
  18562. * Gets a string representation of the current mesh
  18563. * @param fullDetails defines a boolean indicating if full details must be included
  18564. * @returns a string representation of the current mesh
  18565. */
  18566. toString(fullDetails?: boolean): string;
  18567. /** @hidden */
  18568. _rebuild(): void;
  18569. /** @hidden */
  18570. _resyncLightSources(): void;
  18571. /** @hidden */
  18572. _resyncLighSource(light: Light): void;
  18573. /** @hidden */
  18574. _unBindEffect(): void;
  18575. /** @hidden */
  18576. _removeLightSource(light: Light): void;
  18577. private _markSubMeshesAsDirty(func);
  18578. /** @hidden */
  18579. _markSubMeshesAsLightDirty(): void;
  18580. /** @hidden */
  18581. _markSubMeshesAsAttributesDirty(): void;
  18582. /** @hidden */
  18583. _markSubMeshesAsMiscDirty(): void;
  18584. /**
  18585. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  18586. */
  18587. scaling: Vector3;
  18588. /**
  18589. * Disables the mesh edge rendering mode
  18590. * @returns the currentAbstractMesh
  18591. */
  18592. disableEdgesRendering(): AbstractMesh;
  18593. /**
  18594. * Enables the edge rendering mode on the mesh.
  18595. * This mode makes the mesh edges visible
  18596. * @param epsilon defines the maximal distance between two angles to detect a face
  18597. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  18598. * @returns the currentAbstractMesh
  18599. * @see https://www.babylonjs-playground.com/#19O9TU#0
  18600. */
  18601. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  18602. /**
  18603. * Gets the edgesRenderer associated with the mesh
  18604. */
  18605. readonly edgesRenderer: Nullable<EdgesRenderer>;
  18606. /**
  18607. * Returns true if the mesh is blocked. Implemented by child classes
  18608. */
  18609. readonly isBlocked: boolean;
  18610. /**
  18611. * Returns the mesh itself by default. Implemented by child classes
  18612. * @param camera defines the camera to use to pick the right LOD level
  18613. * @returns the currentAbstractMesh
  18614. */
  18615. getLOD(camera: Camera): AbstractMesh;
  18616. /**
  18617. * Returns 0 by default. Implemented by child classes
  18618. * @returns an integer
  18619. */
  18620. getTotalVertices(): number;
  18621. /**
  18622. * Returns null by default. Implemented by child classes
  18623. * @returns null
  18624. */
  18625. getIndices(): Nullable<IndicesArray>;
  18626. /**
  18627. * Returns the array of the requested vertex data kind. Implemented by child classes
  18628. * @param kind defines the vertex data kind to use
  18629. * @returns null
  18630. */
  18631. getVerticesData(kind: string): Nullable<FloatArray>;
  18632. /**
  18633. * Sets the vertex data of the mesh geometry for the requested `kind`.
  18634. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  18635. * Note that a new underlying VertexBuffer object is created each call.
  18636. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  18637. * @param kind defines vertex data kind:
  18638. * * BABYLON.VertexBuffer.PositionKind
  18639. * * BABYLON.VertexBuffer.UVKind
  18640. * * BABYLON.VertexBuffer.UV2Kind
  18641. * * BABYLON.VertexBuffer.UV3Kind
  18642. * * BABYLON.VertexBuffer.UV4Kind
  18643. * * BABYLON.VertexBuffer.UV5Kind
  18644. * * BABYLON.VertexBuffer.UV6Kind
  18645. * * BABYLON.VertexBuffer.ColorKind
  18646. * * BABYLON.VertexBuffer.MatricesIndicesKind
  18647. * * BABYLON.VertexBuffer.MatricesIndicesExtraKind
  18648. * * BABYLON.VertexBuffer.MatricesWeightsKind
  18649. * * BABYLON.VertexBuffer.MatricesWeightsExtraKind
  18650. * @param data defines the data source
  18651. * @param updatable defines if the data must be flagged as updatable (or static)
  18652. * @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
  18653. * @returns the current mesh
  18654. */
  18655. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  18656. /**
  18657. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  18658. * If the mesh has no geometry, it is simply returned as it is.
  18659. * @param kind defines vertex data kind:
  18660. * * BABYLON.VertexBuffer.PositionKind
  18661. * * BABYLON.VertexBuffer.UVKind
  18662. * * BABYLON.VertexBuffer.UV2Kind
  18663. * * BABYLON.VertexBuffer.UV3Kind
  18664. * * BABYLON.VertexBuffer.UV4Kind
  18665. * * BABYLON.VertexBuffer.UV5Kind
  18666. * * BABYLON.VertexBuffer.UV6Kind
  18667. * * BABYLON.VertexBuffer.ColorKind
  18668. * * BABYLON.VertexBuffer.MatricesIndicesKind
  18669. * * BABYLON.VertexBuffer.MatricesIndicesExtraKind
  18670. * * BABYLON.VertexBuffer.MatricesWeightsKind
  18671. * * BABYLON.VertexBuffer.MatricesWeightsExtraKind
  18672. * @param data defines the data source
  18673. * @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
  18674. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  18675. * @returns the current mesh
  18676. */
  18677. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  18678. /**
  18679. * Sets the mesh indices,
  18680. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  18681. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  18682. * @param totalVertices Defines the total number of vertices
  18683. * @returns the current mesh
  18684. */
  18685. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  18686. /**
  18687. * Gets a boolean indicating if specific vertex data is present
  18688. * @param kind defines the vertex data kind to use
  18689. * @returns true is data kind is present
  18690. */
  18691. isVerticesDataPresent(kind: string): boolean;
  18692. /**
  18693. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  18694. * @returns a BoundingInfo
  18695. */
  18696. getBoundingInfo(): BoundingInfo;
  18697. /**
  18698. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  18699. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box
  18700. * @returns the current mesh
  18701. */
  18702. normalizeToUnitCube(includeDescendants?: boolean): AbstractMesh;
  18703. /**
  18704. * Overwrite the current bounding info
  18705. * @param boundingInfo defines the new bounding info
  18706. * @returns the current mesh
  18707. */
  18708. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  18709. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  18710. readonly useBones: boolean;
  18711. /** @hidden */
  18712. _preActivate(): void;
  18713. /** @hidden */
  18714. _preActivateForIntermediateRendering(renderId: number): void;
  18715. /** @hidden */
  18716. _activate(renderId: number): void;
  18717. /**
  18718. * Gets the current world matrix
  18719. * @returns a Matrix
  18720. */
  18721. getWorldMatrix(): Matrix;
  18722. /** @hidden */
  18723. _getWorldMatrixDeterminant(): number;
  18724. /**
  18725. * Perform relative position change from the point of view of behind the front of the mesh.
  18726. * This is performed taking into account the meshes current rotation, so you do not have to care.
  18727. * Supports definition of mesh facing forward or backward
  18728. * @param amountRight defines the distance on the right axis
  18729. * @param amountUp defines the distance on the up axis
  18730. * @param amountForward defines the distance on the forward axis
  18731. * @returns the current mesh
  18732. */
  18733. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  18734. /**
  18735. * Calculate relative position change from the point of view of behind the front of the mesh.
  18736. * This is performed taking into account the meshes current rotation, so you do not have to care.
  18737. * Supports definition of mesh facing forward or backward
  18738. * @param amountRight defines the distance on the right axis
  18739. * @param amountUp defines the distance on the up axis
  18740. * @param amountForward defines the distance on the forward axis
  18741. * @returns the new displacement vector
  18742. */
  18743. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  18744. /**
  18745. * Perform relative rotation change from the point of view of behind the front of the mesh.
  18746. * Supports definition of mesh facing forward or backward
  18747. * @param flipBack defines the flip
  18748. * @param twirlClockwise defines the twirl
  18749. * @param tiltRight defines the tilt
  18750. * @returns the current mesh
  18751. */
  18752. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  18753. /**
  18754. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  18755. * Supports definition of mesh facing forward or backward.
  18756. * @param flipBack defines the flip
  18757. * @param twirlClockwise defines the twirl
  18758. * @param tiltRight defines the tilt
  18759. * @returns the new rotation vector
  18760. */
  18761. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  18762. /**
  18763. * Return the minimum and maximum world vectors of the entire hierarchy under current mesh
  18764. * @param includeDescendants Include bounding info from descendants as well (true by default)
  18765. * @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
  18766. * @returns the new bounding vectors
  18767. */
  18768. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  18769. min: Vector3;
  18770. max: Vector3;
  18771. };
  18772. /** @hidden */
  18773. _updateBoundingInfo(): AbstractMesh;
  18774. /** @hidden */
  18775. _updateSubMeshesBoundingInfo(matrix: Matrix): AbstractMesh;
  18776. /** @hidden */
  18777. protected _afterComputeWorldMatrix(): void;
  18778. /**
  18779. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  18780. * A mesh is in the frustum if its bounding box intersects the frustum
  18781. * @param frustumPlanes defines the frustum to test
  18782. * @returns true if the mesh is in the frustum planes
  18783. */
  18784. isInFrustum(frustumPlanes: Plane[]): boolean;
  18785. /**
  18786. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  18787. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  18788. * @param frustumPlanes defines the frustum to test
  18789. * @returns true if the mesh is completely in the frustum planes
  18790. */
  18791. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  18792. /**
  18793. * True if the mesh intersects another mesh or a SolidParticle object
  18794. * @param mesh defines a target mesh or SolidParticle to test
  18795. * @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)
  18796. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  18797. * @returns true if there is an intersection
  18798. */
  18799. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  18800. /**
  18801. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  18802. * @param point defines the point to test
  18803. * @returns true if there is an intersection
  18804. */
  18805. intersectsPoint(point: Vector3): boolean;
  18806. /**
  18807. * Gets the current physics impostor
  18808. * @see http://doc.babylonjs.com/features/physics_engine
  18809. * @returns a physics impostor or null
  18810. */
  18811. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  18812. /**
  18813. * Gets the position of the current mesh in camera space
  18814. * @param camera defines the camera to use
  18815. * @returns a position
  18816. */
  18817. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  18818. /**
  18819. * Returns the distance from the mesh to the active camera
  18820. * @param camera defines the camera to use
  18821. * @returns the distance
  18822. */
  18823. getDistanceToCamera(camera?: Nullable<Camera>): number;
  18824. /**
  18825. * Apply a physic impulse to the mesh
  18826. * @param force defines the force to apply
  18827. * @param contactPoint defines where to apply the force
  18828. * @returns the current mesh
  18829. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  18830. */
  18831. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  18832. /**
  18833. * Creates a physic joint between two meshes
  18834. * @param otherMesh defines the other mesh to use
  18835. * @param pivot1 defines the pivot to use on this mesh
  18836. * @param pivot2 defines the pivot to use on the other mesh
  18837. * @param options defines additional options (can be plugin dependent)
  18838. * @returns the current mesh
  18839. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  18840. */
  18841. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  18842. /**
  18843. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  18844. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  18845. */
  18846. checkCollisions: boolean;
  18847. /**
  18848. * Gets Collider object used to compute collisions (not physics)
  18849. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  18850. */
  18851. readonly collider: Collider;
  18852. /**
  18853. * Move the mesh using collision engine
  18854. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  18855. * @param displacement defines the requested displacement vector
  18856. * @returns the current mesh
  18857. */
  18858. moveWithCollisions(displacement: Vector3): AbstractMesh;
  18859. private _onCollisionPositionChange;
  18860. /**
  18861. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  18862. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  18863. * @param maxCapacity defines the maximum size of each block (64 by default)
  18864. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  18865. * @returns the new octree
  18866. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  18867. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  18868. */
  18869. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  18870. /** @hidden */
  18871. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  18872. /** @hidden */
  18873. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  18874. /** @hidden */
  18875. _checkCollision(collider: Collider): AbstractMesh;
  18876. /** @hidden */
  18877. _generatePointsArray(): boolean;
  18878. /**
  18879. * Checks if the passed Ray intersects with the mesh
  18880. * @param ray defines the ray to use
  18881. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  18882. * @returns the picking info
  18883. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  18884. */
  18885. intersects(ray: Ray, fastCheck?: boolean): PickingInfo;
  18886. /**
  18887. * Clones the current mesh
  18888. * @param name defines the mesh name
  18889. * @param newParent defines the new mesh parent
  18890. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  18891. * @returns the new mesh
  18892. */
  18893. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  18894. /**
  18895. * Disposes all the submeshes of the current meshnp
  18896. * @returns the current mesh
  18897. */
  18898. releaseSubMeshes(): AbstractMesh;
  18899. /**
  18900. * Releases resources associated with this abstract mesh.
  18901. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  18902. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  18903. */
  18904. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  18905. /**
  18906. * Adds the passed mesh as a child to the current mesh
  18907. * @param mesh defines the child mesh
  18908. * @returns the current mesh
  18909. */
  18910. addChild(mesh: AbstractMesh): AbstractMesh;
  18911. /**
  18912. * Removes the passed mesh from the current mesh children list
  18913. * @param mesh defines the child mesh
  18914. * @returns the current mesh
  18915. */
  18916. removeChild(mesh: AbstractMesh): AbstractMesh;
  18917. /** @hidden */
  18918. private _initFacetData();
  18919. /**
  18920. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  18921. * This method can be called within the render loop.
  18922. * 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
  18923. * @returns the current mesh
  18924. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  18925. */
  18926. updateFacetData(): AbstractMesh;
  18927. /**
  18928. * Returns the facetLocalNormals array.
  18929. * The normals are expressed in the mesh local spac
  18930. * @returns an array of Vector3
  18931. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  18932. */
  18933. getFacetLocalNormals(): Vector3[];
  18934. /**
  18935. * Returns the facetLocalPositions array.
  18936. * The facet positions are expressed in the mesh local space
  18937. * @returns an array of Vector3
  18938. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  18939. */
  18940. getFacetLocalPositions(): Vector3[];
  18941. /**
  18942. * Returns the facetLocalPartioning array
  18943. * @returns an array of array of numbers
  18944. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  18945. */
  18946. getFacetLocalPartitioning(): number[][];
  18947. /**
  18948. * Returns the i-th facet position in the world system.
  18949. * This method allocates a new Vector3 per call
  18950. * @param i defines the facet index
  18951. * @returns a new Vector3
  18952. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  18953. */
  18954. getFacetPosition(i: number): Vector3;
  18955. /**
  18956. * Sets the reference Vector3 with the i-th facet position in the world system
  18957. * @param i defines the facet index
  18958. * @param ref defines the target vector
  18959. * @returns the current mesh
  18960. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  18961. */
  18962. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  18963. /**
  18964. * Returns the i-th facet normal in the world system.
  18965. * This method allocates a new Vector3 per call
  18966. * @param i defines the facet index
  18967. * @returns a new Vector3
  18968. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  18969. */
  18970. getFacetNormal(i: number): Vector3;
  18971. /**
  18972. * Sets the reference Vector3 with the i-th facet normal in the world system
  18973. * @param i defines the facet index
  18974. * @param ref defines the target vector
  18975. * @returns the current mesh
  18976. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  18977. */
  18978. getFacetNormalToRef(i: number, ref: Vector3): this;
  18979. /**
  18980. * 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)
  18981. * @param x defines x coordinate
  18982. * @param y defines y coordinate
  18983. * @param z defines z coordinate
  18984. * @returns the array of facet indexes
  18985. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  18986. */
  18987. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  18988. /**
  18989. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  18990. * @param projected sets as the (x,y,z) world projection on the facet
  18991. * @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
  18992. * @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
  18993. * @param x defines x coordinate
  18994. * @param y defines y coordinate
  18995. * @param z defines z coordinate
  18996. * @returns the face index if found (or null instead)
  18997. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  18998. */
  18999. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  19000. /**
  19001. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  19002. * @param projected sets as the (x,y,z) local projection on the facet
  19003. * @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
  19004. * @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
  19005. * @param x defines x coordinate
  19006. * @param y defines y coordinate
  19007. * @param z defines z coordinate
  19008. * @returns the face index if found (or null instead)
  19009. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  19010. */
  19011. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  19012. /**
  19013. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  19014. * @returns the parameters
  19015. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  19016. */
  19017. getFacetDataParameters(): any;
  19018. /**
  19019. * Disables the feature FacetData and frees the related memory
  19020. * @returns the current mesh
  19021. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  19022. */
  19023. disableFacetData(): AbstractMesh;
  19024. /**
  19025. * Updates the AbstractMesh indices array
  19026. * @param indices defines the data source
  19027. * @returns the current mesh
  19028. */
  19029. updateIndices(indices: IndicesArray): AbstractMesh;
  19030. /**
  19031. * Creates new normals data for the mesh
  19032. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  19033. * @returns the current mesh
  19034. */
  19035. createNormals(updatable: boolean): AbstractMesh;
  19036. /**
  19037. * Align the mesh with a normal
  19038. * @param normal defines the normal to use
  19039. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  19040. * @returns the current mesh
  19041. */
  19042. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  19043. /** @hidden */
  19044. protected _checkOcclusionQuery(): void;
  19045. }
  19046. }
  19047. declare module BABYLON {
  19048. class Buffer {
  19049. private _engine;
  19050. private _buffer;
  19051. /** @hidden */
  19052. _data: Nullable<DataArray>;
  19053. private _updatable;
  19054. private _instanced;
  19055. /**
  19056. * Gets the byte stride.
  19057. */
  19058. readonly byteStride: number;
  19059. /**
  19060. * Constructor
  19061. * @param engine the engine
  19062. * @param data the data to use for this buffer
  19063. * @param updatable whether the data is updatable
  19064. * @param stride the stride (optional)
  19065. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  19066. * @param instanced whether the buffer is instanced (optional)
  19067. * @param useBytes set to true if the stride in in bytes (optional)
  19068. */
  19069. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  19070. /**
  19071. * Create a new {BABYLON.VertexBuffer} based on the current buffer
  19072. * @param kind defines the vertex buffer kind (position, normal, etc.)
  19073. * @param offset defines offset in the buffer (0 by default)
  19074. * @param size defines the size in floats of attributes (position is 3 for instance)
  19075. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  19076. * @param instanced defines if the vertex buffer contains indexed data
  19077. * @param useBytes defines if the offset and stride are in bytes
  19078. * @returns the new vertex buffer
  19079. */
  19080. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  19081. isUpdatable(): boolean;
  19082. getData(): Nullable<DataArray>;
  19083. getBuffer(): Nullable<WebGLBuffer>;
  19084. /**
  19085. * Gets the stride in float32 units (i.e. byte stride / 4).
  19086. * May not be an integer if the byte stride is not divisible by 4.
  19087. * DEPRECATED. Use byteStride instead.
  19088. * @returns the stride in float32 units
  19089. */
  19090. getStrideSize(): number;
  19091. create(data?: Nullable<DataArray>): void;
  19092. _rebuild(): void;
  19093. update(data: DataArray): void;
  19094. /**
  19095. * Updates the data directly.
  19096. * @param data the new data
  19097. * @param offset the new offset
  19098. * @param vertexCount the vertex count (optional)
  19099. * @param useBytes set to true if the offset is in bytes
  19100. */
  19101. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  19102. dispose(): void;
  19103. }
  19104. }
  19105. declare module BABYLON {
  19106. class CSG {
  19107. private polygons;
  19108. matrix: Matrix;
  19109. position: Vector3;
  19110. rotation: Vector3;
  19111. rotationQuaternion: Nullable<Quaternion>;
  19112. scaling: Vector3;
  19113. static FromMesh(mesh: Mesh): CSG;
  19114. private static FromPolygons(polygons);
  19115. clone(): CSG;
  19116. union(csg: CSG): CSG;
  19117. unionInPlace(csg: CSG): void;
  19118. subtract(csg: CSG): CSG;
  19119. subtractInPlace(csg: CSG): void;
  19120. intersect(csg: CSG): CSG;
  19121. intersectInPlace(csg: CSG): void;
  19122. inverse(): CSG;
  19123. inverseInPlace(): void;
  19124. copyTransformAttributes(csg: CSG): CSG;
  19125. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  19126. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  19127. }
  19128. }
  19129. declare module BABYLON {
  19130. /**
  19131. * Class used to store geometry data (vertex buffers + index buffer)
  19132. */
  19133. class Geometry implements IGetSetVerticesData {
  19134. /**
  19135. * Gets or sets the unique ID of the geometry
  19136. */
  19137. id: string;
  19138. /**
  19139. * Gets the delay loading state of the geometry (none by default which means not delayed)
  19140. */
  19141. delayLoadState: number;
  19142. /**
  19143. * Gets the file containing the data to load when running in delay load state
  19144. */
  19145. delayLoadingFile: Nullable<string>;
  19146. /**
  19147. * Callback called when the geometry is updated
  19148. */
  19149. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  19150. private _scene;
  19151. private _engine;
  19152. private _meshes;
  19153. private _totalVertices;
  19154. /** @hidden */
  19155. _indices: IndicesArray;
  19156. /** @hidden */
  19157. _vertexBuffers: {
  19158. [key: string]: VertexBuffer;
  19159. };
  19160. private _isDisposed;
  19161. private _extend;
  19162. private _boundingBias;
  19163. /** @hidden */
  19164. _delayInfo: Array<string>;
  19165. private _indexBuffer;
  19166. private _indexBufferIsUpdatable;
  19167. /** @hidden */
  19168. _boundingInfo: Nullable<BoundingInfo>;
  19169. /** @hidden */
  19170. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  19171. /** @hidden */
  19172. _softwareSkinningRenderId: number;
  19173. private _vertexArrayObjects;
  19174. private _updatable;
  19175. /** @hidden */
  19176. _positions: Nullable<Vector3[]>;
  19177. /**
  19178. * 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
  19179. */
  19180. /**
  19181. * 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
  19182. */
  19183. boundingBias: Vector2;
  19184. /**
  19185. * Static function used to attach a new empty geometry to a mesh
  19186. * @param mesh defines the mesh to attach the geometry to
  19187. * @returns the new {BABYLON.Geometry}
  19188. */
  19189. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  19190. /**
  19191. * Creates a new geometry
  19192. * @param id defines the unique ID
  19193. * @param scene defines the hosting scene
  19194. * @param vertexData defines the {BABYLON.VertexData} used to get geometry data
  19195. * @param updatable defines if geometry must be updatable (false by default)
  19196. * @param mesh defines the mesh that will be associated with the geometry
  19197. */
  19198. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  19199. /**
  19200. * Gets the current extend of the geometry
  19201. */
  19202. readonly extend: {
  19203. minimum: Vector3;
  19204. maximum: Vector3;
  19205. };
  19206. /**
  19207. * Gets the hosting scene
  19208. * @returns the hosting {BABYLON.Scene}
  19209. */
  19210. getScene(): Scene;
  19211. /**
  19212. * Gets the hosting engine
  19213. * @returns the hosting {BABYLON.Engine}
  19214. */
  19215. getEngine(): Engine;
  19216. /**
  19217. * Defines if the geometry is ready to use
  19218. * @returns true if the geometry is ready to be used
  19219. */
  19220. isReady(): boolean;
  19221. /**
  19222. * Gets a value indicating that the geometry should not be serialized
  19223. */
  19224. readonly doNotSerialize: boolean;
  19225. /** @hidden */
  19226. _rebuild(): void;
  19227. /**
  19228. * Affects all gemetry data in one call
  19229. * @param vertexData defines the geometry data
  19230. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  19231. */
  19232. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  19233. /**
  19234. * Set specific vertex data
  19235. * @param kind defines the data kind (Position, normal, etc...)
  19236. * @param data defines the vertex data to use
  19237. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  19238. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  19239. */
  19240. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  19241. /**
  19242. * Removes a specific vertex data
  19243. * @param kind defines the data kind (Position, normal, etc...)
  19244. */
  19245. removeVerticesData(kind: string): void;
  19246. /**
  19247. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  19248. * @param buffer defines the vertex buffer to use
  19249. * @param totalVertices defines the total number of vertices for position kind (could be null)
  19250. */
  19251. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  19252. /**
  19253. * Update a specific vertex buffer
  19254. * This function will directly update the underlying WebGLBuffer according to the passed numeric array or Float32Array
  19255. * It will do nothing if the buffer is not updatable
  19256. * @param kind defines the data kind (Position, normal, etc...)
  19257. * @param data defines the data to use
  19258. * @param offset defines the offset in the target buffer where to store the data
  19259. * @param useBytes set to true if the offset is in bytes
  19260. */
  19261. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  19262. /**
  19263. * Update a specific vertex buffer
  19264. * This function will create a new buffer if the current one is not updatable
  19265. * @param kind defines the data kind (Position, normal, etc...)
  19266. * @param data defines the data to use
  19267. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  19268. */
  19269. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  19270. private _updateBoundingInfo(updateExtends, data);
  19271. /** @hidden */
  19272. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<WebGLBuffer>): void;
  19273. /**
  19274. * Gets total number of vertices
  19275. * @returns the total number of vertices
  19276. */
  19277. getTotalVertices(): number;
  19278. /**
  19279. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  19280. * @param kind defines the data kind (Position, normal, etc...)
  19281. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  19282. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  19283. * @returns a float array containing vertex data
  19284. */
  19285. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  19286. /**
  19287. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  19288. * @param kind defines the data kind (Position, normal, etc...)
  19289. * @returns true if the vertex buffer with the specified kind is updatable
  19290. */
  19291. isVertexBufferUpdatable(kind: string): boolean;
  19292. /**
  19293. * Gets a specific vertex buffer
  19294. * @param kind defines the data kind (Position, normal, etc...)
  19295. * @returns a {BABYLON.VertexBuffer}
  19296. */
  19297. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  19298. /**
  19299. * Returns all vertex buffers
  19300. * @return an object holding all vertex buffers indexed by kind
  19301. */
  19302. getVertexBuffers(): Nullable<{
  19303. [key: string]: VertexBuffer;
  19304. }>;
  19305. /**
  19306. * Gets a boolean indicating if specific vertex buffer is present
  19307. * @param kind defines the data kind (Position, normal, etc...)
  19308. * @returns true if data is present
  19309. */
  19310. isVerticesDataPresent(kind: string): boolean;
  19311. /**
  19312. * Gets a list of all attached data kinds (Position, normal, etc...)
  19313. * @returns a list of string containing all kinds
  19314. */
  19315. getVerticesDataKinds(): string[];
  19316. /**
  19317. * Update index buffer
  19318. * @param indices defines the indices to store in the index buffer
  19319. * @param offset defines the offset in the target buffer where to store the data
  19320. */
  19321. updateIndices(indices: IndicesArray, offset?: number): void;
  19322. /**
  19323. * Creates a new index buffer
  19324. * @param indices defines the indices to store in the index buffer
  19325. * @param totalVertices defines the total number of vertices (could be null)
  19326. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  19327. */
  19328. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  19329. /**
  19330. * Return the total number of indices
  19331. * @returns the total number of indices
  19332. */
  19333. getTotalIndices(): number;
  19334. /**
  19335. * Gets the index buffer array
  19336. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  19337. * @returns the index buffer array
  19338. */
  19339. getIndices(copyWhenShared?: boolean): Nullable<IndicesArray>;
  19340. /**
  19341. * Gets the index buffer
  19342. * @return the index buffer
  19343. */
  19344. getIndexBuffer(): Nullable<WebGLBuffer>;
  19345. /** @hidden */
  19346. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  19347. /**
  19348. * Release the associated resources for a specific mesh
  19349. * @param mesh defines the source mesh
  19350. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  19351. */
  19352. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  19353. /**
  19354. * Apply current geometry to a given mesh
  19355. * @param mesh defines the mesh to apply geometry to
  19356. */
  19357. applyToMesh(mesh: Mesh): void;
  19358. private _updateExtend(data?);
  19359. private _applyToMesh(mesh);
  19360. private notifyUpdate(kind?);
  19361. /**
  19362. * Load the geometry if it was flagged as delay loaded
  19363. * @param scene defines the hosting scene
  19364. * @param onLoaded defines a callback called when the geometry is loaded
  19365. */
  19366. load(scene: Scene, onLoaded?: () => void): void;
  19367. private _queueLoad(scene, onLoaded?);
  19368. /**
  19369. * Invert the geometry to move from a right handed system to a left handed one.
  19370. */
  19371. toLeftHanded(): void;
  19372. /** @hidden */
  19373. _resetPointsArrayCache(): void;
  19374. /** @hidden */
  19375. _generatePointsArray(): boolean;
  19376. /**
  19377. * Gets a value indicating if the geometry is disposed
  19378. * @returns true if the geometry was disposed
  19379. */
  19380. isDisposed(): boolean;
  19381. private _disposeVertexArrayObjects();
  19382. /**
  19383. * Free all associated resources
  19384. */
  19385. dispose(): void;
  19386. /**
  19387. * Clone the current geometry into a new geometry
  19388. * @param id defines the unique ID of the new geometry
  19389. * @returns a new geometry object
  19390. */
  19391. copy(id: string): Geometry;
  19392. /**
  19393. * Serialize the current geometry info (and not the vertices data) into a JSON object
  19394. * @return a JSON representation of the current geometry data (without the vertices data)
  19395. */
  19396. serialize(): any;
  19397. private toNumberArray(origin);
  19398. /**
  19399. * Serialize all vertices data into a JSON oject
  19400. * @returns a JSON representation of the current geometry data
  19401. */
  19402. serializeVerticeData(): any;
  19403. /**
  19404. * Extracts a clone of a mesh geometry
  19405. * @param mesh defines the source mesh
  19406. * @param id defines the unique ID of the new geometry object
  19407. * @returns the new geometry object
  19408. */
  19409. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  19410. /**
  19411. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  19412. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  19413. * Be aware Math.random() could cause collisions, but:
  19414. * "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"
  19415. * @returns a string containing a new GUID
  19416. */
  19417. static RandomId(): string;
  19418. /** @hidden */
  19419. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  19420. private static _CleanMatricesWeights(parsedGeometry, mesh);
  19421. /**
  19422. * Create a new geometry from persisted data (Using .babylon file format)
  19423. * @param parsedVertexData defines the persisted data
  19424. * @param scene defines the hosting scene
  19425. * @param rootUrl defines the root url to use to load assets (like delayed data)
  19426. * @returns the new geometry object
  19427. */
  19428. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  19429. }
  19430. /**
  19431. * Abstract class used to provide common services for all typed geometries
  19432. * @hidden
  19433. */
  19434. class _PrimitiveGeometry extends Geometry {
  19435. private _canBeRegenerated;
  19436. private _beingRegenerated;
  19437. /**
  19438. * Creates a new typed geometry
  19439. * @param id defines the unique ID of the geometry
  19440. * @param scene defines the hosting scene
  19441. * @param _canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  19442. * @param mesh defines the hosting mesh (can be null)
  19443. */
  19444. constructor(id: string, scene: Scene, _canBeRegenerated?: boolean, mesh?: Nullable<Mesh>);
  19445. /**
  19446. * Gets a value indicating if the geometry supports being regenerated with new parameters (false by default)
  19447. * @returns true if the geometry can be regenerated
  19448. */
  19449. canBeRegenerated(): boolean;
  19450. /**
  19451. * If the geometry supports regeneration, the function will recreates the geometry with updated parameter values
  19452. */
  19453. regenerate(): void;
  19454. /**
  19455. * Clone the geometry
  19456. * @param id defines the unique ID of the new geometry
  19457. * @returns the new geometry
  19458. */
  19459. asNewGeometry(id: string): Geometry;
  19460. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  19461. setVerticesData(kind: string, data: FloatArray, updatable?: boolean): void;
  19462. /** @hidden */
  19463. _regenerateVertexData(): VertexData;
  19464. copy(id: string): Geometry;
  19465. serialize(): any;
  19466. }
  19467. /**
  19468. * Creates a ribbon geometry
  19469. * @description See http://doc.babylonjs.com/how_to/ribbon_tutorial, http://doc.babylonjs.com/resources/maths_make_ribbons
  19470. */
  19471. class RibbonGeometry extends _PrimitiveGeometry {
  19472. /**
  19473. * Defines the array of paths to use
  19474. */
  19475. pathArray: Vector3[][];
  19476. /**
  19477. * Defines if the last and first points of each path in your pathArray must be joined
  19478. */
  19479. closeArray: boolean;
  19480. /**
  19481. * Defines if the last and first points of each path in your pathArray must be joined
  19482. */
  19483. closePath: boolean;
  19484. /**
  19485. * Defines the offset between points
  19486. */
  19487. offset: number;
  19488. /**
  19489. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  19490. */
  19491. side: number;
  19492. /**
  19493. * Creates a ribbon geometry
  19494. * @param id defines the unique ID of the geometry
  19495. * @param scene defines the hosting scene
  19496. * @param pathArray defines the array of paths to use
  19497. * @param closeArray defines if the last path and the first path must be joined
  19498. * @param closePath defines if the last and first points of each path in your pathArray must be joined
  19499. * @param offset defines the offset between points
  19500. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  19501. * @param mesh defines the hosting mesh (can be null)
  19502. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  19503. */
  19504. constructor(id: string, scene: Scene,
  19505. /**
  19506. * Defines the array of paths to use
  19507. */
  19508. pathArray: Vector3[][],
  19509. /**
  19510. * Defines if the last and first points of each path in your pathArray must be joined
  19511. */
  19512. closeArray: boolean,
  19513. /**
  19514. * Defines if the last and first points of each path in your pathArray must be joined
  19515. */
  19516. closePath: boolean,
  19517. /**
  19518. * Defines the offset between points
  19519. */
  19520. offset: number, canBeRegenerated?: boolean, mesh?: Mesh,
  19521. /**
  19522. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  19523. */
  19524. side?: number);
  19525. /** @hidden */
  19526. _regenerateVertexData(): VertexData;
  19527. copy(id: string): Geometry;
  19528. }
  19529. /**
  19530. * Creates a box geometry
  19531. * @description see http://doc.babylonjs.com/how_to/set_shapes#box
  19532. */
  19533. class BoxGeometry extends _PrimitiveGeometry {
  19534. /**
  19535. * Defines the zise of the box (width, height and depth are the same)
  19536. */
  19537. size: number;
  19538. /**
  19539. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  19540. */
  19541. side: number;
  19542. /**
  19543. * Creates a box geometry
  19544. * @param id defines the unique ID of the geometry
  19545. * @param scene defines the hosting scene
  19546. * @param size defines the zise of the box (width, height and depth are the same)
  19547. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  19548. * @param mesh defines the hosting mesh (can be null)
  19549. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  19550. */
  19551. constructor(id: string, scene: Scene,
  19552. /**
  19553. * Defines the zise of the box (width, height and depth are the same)
  19554. */
  19555. size: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  19556. /**
  19557. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  19558. */
  19559. side?: number);
  19560. _regenerateVertexData(): VertexData;
  19561. copy(id: string): Geometry;
  19562. serialize(): any;
  19563. static Parse(parsedBox: any, scene: Scene): Nullable<BoxGeometry>;
  19564. }
  19565. /**
  19566. * Creates a sphere geometry
  19567. * @description see http://doc.babylonjs.com/how_to/set_shapes#sphere
  19568. */
  19569. class SphereGeometry extends _PrimitiveGeometry {
  19570. /**
  19571. * Defines the number of segments to use to create the sphere
  19572. */
  19573. segments: number;
  19574. /**
  19575. * Defines the diameter of the sphere
  19576. */
  19577. diameter: number;
  19578. /**
  19579. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  19580. */
  19581. side: number;
  19582. /**
  19583. * Create a new sphere geometry
  19584. * @param id defines the unique ID of the geometry
  19585. * @param scene defines the hosting scene
  19586. * @param segments defines the number of segments to use to create the sphere
  19587. * @param diameter defines the diameter of the sphere
  19588. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  19589. * @param mesh defines the hosting mesh (can be null)
  19590. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  19591. */
  19592. constructor(id: string, scene: Scene,
  19593. /**
  19594. * Defines the number of segments to use to create the sphere
  19595. */
  19596. segments: number,
  19597. /**
  19598. * Defines the diameter of the sphere
  19599. */
  19600. diameter: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  19601. /**
  19602. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  19603. */
  19604. side?: number);
  19605. _regenerateVertexData(): VertexData;
  19606. copy(id: string): Geometry;
  19607. serialize(): any;
  19608. static Parse(parsedSphere: any, scene: Scene): Nullable<SphereGeometry>;
  19609. }
  19610. /**
  19611. * Creates a disc geometry
  19612. * @description see http://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  19613. */
  19614. class DiscGeometry extends _PrimitiveGeometry {
  19615. /**
  19616. * Defines the radius of the disc
  19617. */
  19618. radius: number;
  19619. /**
  19620. * Defines the tesselation factor to apply to the disc
  19621. */
  19622. tessellation: number;
  19623. /**
  19624. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  19625. */
  19626. side: number;
  19627. /**
  19628. * Creates a new disc geometry
  19629. * @param id defines the unique ID of the geometry
  19630. * @param scene defines the hosting scene
  19631. * @param radius defines the radius of the disc
  19632. * @param tessellation defines the tesselation factor to apply to the disc
  19633. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  19634. * @param mesh defines the hosting mesh (can be null)
  19635. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  19636. */
  19637. constructor(id: string, scene: Scene,
  19638. /**
  19639. * Defines the radius of the disc
  19640. */
  19641. radius: number,
  19642. /**
  19643. * Defines the tesselation factor to apply to the disc
  19644. */
  19645. tessellation: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  19646. /**
  19647. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  19648. */
  19649. side?: number);
  19650. _regenerateVertexData(): VertexData;
  19651. copy(id: string): Geometry;
  19652. }
  19653. /**
  19654. * Creates a new cylinder geometry
  19655. * @description see http://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  19656. */
  19657. class CylinderGeometry extends _PrimitiveGeometry {
  19658. /**
  19659. * Defines the height of the cylinder
  19660. */
  19661. height: number;
  19662. /**
  19663. * Defines the diameter of the cylinder's top cap
  19664. */
  19665. diameterTop: number;
  19666. /**
  19667. * Defines the diameter of the cylinder's bottom cap
  19668. */
  19669. diameterBottom: number;
  19670. /**
  19671. * Defines the tessellation factor to apply to the cylinder
  19672. */
  19673. tessellation: number;
  19674. /**
  19675. * Defines the number of subdivisions to apply to the cylinder (1 by default)
  19676. */
  19677. subdivisions: number;
  19678. /**
  19679. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  19680. */
  19681. side: number;
  19682. /**
  19683. * Creates a new cylinder geometry
  19684. * @param id defines the unique ID of the geometry
  19685. * @param scene defines the hosting scene
  19686. * @param height defines the height of the cylinder
  19687. * @param diameterTop defines the diameter of the cylinder's top cap
  19688. * @param diameterBottom defines the diameter of the cylinder's bottom cap
  19689. * @param tessellation defines the tessellation factor to apply to the cylinder (number of radial sides)
  19690. * @param subdivisions defines the number of subdivisions to apply to the cylinder (number of rings) (1 by default)
  19691. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  19692. * @param mesh defines the hosting mesh (can be null)
  19693. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  19694. */
  19695. constructor(id: string, scene: Scene,
  19696. /**
  19697. * Defines the height of the cylinder
  19698. */
  19699. height: number,
  19700. /**
  19701. * Defines the diameter of the cylinder's top cap
  19702. */
  19703. diameterTop: number,
  19704. /**
  19705. * Defines the diameter of the cylinder's bottom cap
  19706. */
  19707. diameterBottom: number,
  19708. /**
  19709. * Defines the tessellation factor to apply to the cylinder
  19710. */
  19711. tessellation: number,
  19712. /**
  19713. * Defines the number of subdivisions to apply to the cylinder (1 by default)
  19714. */
  19715. subdivisions?: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  19716. /**
  19717. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  19718. */
  19719. side?: number);
  19720. _regenerateVertexData(): VertexData;
  19721. copy(id: string): Geometry;
  19722. serialize(): any;
  19723. static Parse(parsedCylinder: any, scene: Scene): Nullable<CylinderGeometry>;
  19724. }
  19725. /**
  19726. * Creates a new torus geometry
  19727. * @description see http://doc.babylonjs.com/how_to/set_shapes#torus
  19728. */
  19729. class TorusGeometry extends _PrimitiveGeometry {
  19730. /**
  19731. * Defines the diameter of the torus
  19732. */
  19733. diameter: number;
  19734. /**
  19735. * Defines the thickness of the torus (ie. internal diameter)
  19736. */
  19737. thickness: number;
  19738. /**
  19739. * Defines the tesselation factor to apply to the torus
  19740. */
  19741. tessellation: number;
  19742. /**
  19743. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  19744. */
  19745. side: number;
  19746. /**
  19747. * Creates a new torus geometry
  19748. * @param id defines the unique ID of the geometry
  19749. * @param scene defines the hosting scene
  19750. * @param diameter defines the diameter of the torus
  19751. * @param thickness defines the thickness of the torus (ie. internal diameter)
  19752. * @param tessellation defines the tesselation factor to apply to the torus (number of segments along the circle)
  19753. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  19754. * @param mesh defines the hosting mesh (can be null)
  19755. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  19756. */
  19757. constructor(id: string, scene: Scene,
  19758. /**
  19759. * Defines the diameter of the torus
  19760. */
  19761. diameter: number,
  19762. /**
  19763. * Defines the thickness of the torus (ie. internal diameter)
  19764. */
  19765. thickness: number,
  19766. /**
  19767. * Defines the tesselation factor to apply to the torus
  19768. */
  19769. tessellation: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  19770. /**
  19771. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  19772. */
  19773. side?: number);
  19774. _regenerateVertexData(): VertexData;
  19775. copy(id: string): Geometry;
  19776. serialize(): any;
  19777. static Parse(parsedTorus: any, scene: Scene): Nullable<TorusGeometry>;
  19778. }
  19779. /**
  19780. * Creates a new ground geometry
  19781. * @description see http://doc.babylonjs.com/how_to/set_shapes#ground
  19782. */
  19783. class GroundGeometry extends _PrimitiveGeometry {
  19784. /**
  19785. * Defines the width of the ground
  19786. */
  19787. width: number;
  19788. /**
  19789. * Defines the height of the ground
  19790. */
  19791. height: number;
  19792. /**
  19793. * Defines the subdivisions to apply to the ground
  19794. */
  19795. subdivisions: number;
  19796. /**
  19797. * Creates a new ground geometry
  19798. * @param id defines the unique ID of the geometry
  19799. * @param scene defines the hosting scene
  19800. * @param width defines the width of the ground
  19801. * @param height defines the height of the ground
  19802. * @param subdivisions defines the subdivisions to apply to the ground
  19803. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  19804. * @param mesh defines the hosting mesh (can be null)
  19805. */
  19806. constructor(id: string, scene: Scene,
  19807. /**
  19808. * Defines the width of the ground
  19809. */
  19810. width: number,
  19811. /**
  19812. * Defines the height of the ground
  19813. */
  19814. height: number,
  19815. /**
  19816. * Defines the subdivisions to apply to the ground
  19817. */
  19818. subdivisions: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>);
  19819. _regenerateVertexData(): VertexData;
  19820. copy(id: string): Geometry;
  19821. serialize(): any;
  19822. static Parse(parsedGround: any, scene: Scene): Nullable<GroundGeometry>;
  19823. }
  19824. /**
  19825. * Creates a tiled ground geometry
  19826. * @description see http://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  19827. */
  19828. class TiledGroundGeometry extends _PrimitiveGeometry {
  19829. /**
  19830. * Defines the minimum value on X axis
  19831. */
  19832. xmin: number;
  19833. /**
  19834. * Defines the minimum value on Z axis
  19835. */
  19836. zmin: number;
  19837. /**
  19838. * Defines the maximum value on X axis
  19839. */
  19840. xmax: number;
  19841. /**
  19842. * Defines the maximum value on Z axis
  19843. */
  19844. zmax: number;
  19845. /**
  19846. * Defines the subdivisions to apply to the ground
  19847. */
  19848. subdivisions: {
  19849. w: number;
  19850. h: number;
  19851. };
  19852. /**
  19853. * Defines the precision to use when computing the tiles
  19854. */
  19855. precision: {
  19856. w: number;
  19857. h: number;
  19858. };
  19859. /**
  19860. * Creates a tiled ground geometry
  19861. * @param id defines the unique ID of the geometry
  19862. * @param scene defines the hosting scene
  19863. * @param xmin defines the minimum value on X axis
  19864. * @param zmin defines the minimum value on Z axis
  19865. * @param xmax defines the maximum value on X axis
  19866. * @param zmax defines the maximum value on Z axis
  19867. * @param subdivisions defines the subdivisions to apply to the ground (number of subdivisions (tiles) on the height and the width of the map)
  19868. * @param precision defines the precision to use when computing the tiles
  19869. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  19870. * @param mesh defines the hosting mesh (can be null)
  19871. */
  19872. constructor(id: string, scene: Scene,
  19873. /**
  19874. * Defines the minimum value on X axis
  19875. */
  19876. xmin: number,
  19877. /**
  19878. * Defines the minimum value on Z axis
  19879. */
  19880. zmin: number,
  19881. /**
  19882. * Defines the maximum value on X axis
  19883. */
  19884. xmax: number,
  19885. /**
  19886. * Defines the maximum value on Z axis
  19887. */
  19888. zmax: number,
  19889. /**
  19890. * Defines the subdivisions to apply to the ground
  19891. */
  19892. subdivisions: {
  19893. w: number;
  19894. h: number;
  19895. },
  19896. /**
  19897. * Defines the precision to use when computing the tiles
  19898. */
  19899. precision: {
  19900. w: number;
  19901. h: number;
  19902. }, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>);
  19903. _regenerateVertexData(): VertexData;
  19904. copy(id: string): Geometry;
  19905. }
  19906. /**
  19907. * Creates a plane geometry
  19908. * @description see http://doc.babylonjs.com/how_to/set_shapes#plane
  19909. */
  19910. class PlaneGeometry extends _PrimitiveGeometry {
  19911. /**
  19912. * Defines the size of the plane (width === height)
  19913. */
  19914. size: number;
  19915. /**
  19916. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  19917. */
  19918. side: number;
  19919. /**
  19920. * Creates a plane geometry
  19921. * @param id defines the unique ID of the geometry
  19922. * @param scene defines the hosting scene
  19923. * @param size defines the size of the plane (width === height)
  19924. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  19925. * @param mesh defines the hosting mesh (can be null)
  19926. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  19927. */
  19928. constructor(id: string, scene: Scene,
  19929. /**
  19930. * Defines the size of the plane (width === height)
  19931. */
  19932. size: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  19933. /**
  19934. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  19935. */
  19936. side?: number);
  19937. _regenerateVertexData(): VertexData;
  19938. copy(id: string): Geometry;
  19939. serialize(): any;
  19940. static Parse(parsedPlane: any, scene: Scene): Nullable<PlaneGeometry>;
  19941. }
  19942. /**
  19943. * Creates a torus knot geometry
  19944. * @description see http://doc.babylonjs.com/how_to/set_shapes#torus-knot
  19945. */
  19946. class TorusKnotGeometry extends _PrimitiveGeometry {
  19947. /**
  19948. * Defines the radius of the torus knot
  19949. */
  19950. radius: number;
  19951. /**
  19952. * Defines the thickness of the torus knot tube
  19953. */
  19954. tube: number;
  19955. /**
  19956. * Defines the number of radial segments
  19957. */
  19958. radialSegments: number;
  19959. /**
  19960. * Defines the number of tubular segments
  19961. */
  19962. tubularSegments: number;
  19963. /**
  19964. * Defines the first number of windings
  19965. */
  19966. p: number;
  19967. /**
  19968. * Defines the second number of windings
  19969. */
  19970. q: number;
  19971. /**
  19972. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  19973. */
  19974. side: number;
  19975. /**
  19976. * Creates a torus knot geometry
  19977. * @param id defines the unique ID of the geometry
  19978. * @param scene defines the hosting scene
  19979. * @param radius defines the radius of the torus knot
  19980. * @param tube defines the thickness of the torus knot tube
  19981. * @param radialSegments defines the number of radial segments
  19982. * @param tubularSegments defines the number of tubular segments
  19983. * @param p defines the first number of windings
  19984. * @param q defines the second number of windings
  19985. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  19986. * @param mesh defines the hosting mesh (can be null)
  19987. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  19988. */
  19989. constructor(id: string, scene: Scene,
  19990. /**
  19991. * Defines the radius of the torus knot
  19992. */
  19993. radius: number,
  19994. /**
  19995. * Defines the thickness of the torus knot tube
  19996. */
  19997. tube: number,
  19998. /**
  19999. * Defines the number of radial segments
  20000. */
  20001. radialSegments: number,
  20002. /**
  20003. * Defines the number of tubular segments
  20004. */
  20005. tubularSegments: number,
  20006. /**
  20007. * Defines the first number of windings
  20008. */
  20009. p: number,
  20010. /**
  20011. * Defines the second number of windings
  20012. */
  20013. q: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  20014. /**
  20015. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  20016. */
  20017. side?: number);
  20018. _regenerateVertexData(): VertexData;
  20019. copy(id: string): Geometry;
  20020. serialize(): any;
  20021. static Parse(parsedTorusKnot: any, scene: Scene): Nullable<TorusKnotGeometry>;
  20022. }
  20023. }
  20024. declare module BABYLON {
  20025. class GroundMesh extends Mesh {
  20026. generateOctree: boolean;
  20027. private _heightQuads;
  20028. _subdivisionsX: number;
  20029. _subdivisionsY: number;
  20030. _width: number;
  20031. _height: number;
  20032. _minX: number;
  20033. _maxX: number;
  20034. _minZ: number;
  20035. _maxZ: number;
  20036. constructor(name: string, scene: Scene);
  20037. getClassName(): string;
  20038. readonly subdivisions: number;
  20039. readonly subdivisionsX: number;
  20040. readonly subdivisionsY: number;
  20041. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  20042. /**
  20043. * Returns a height (y) value in the Worl system :
  20044. * the ground altitude at the coordinates (x, z) expressed in the World system.
  20045. * Returns the ground y position if (x, z) are outside the ground surface.
  20046. */
  20047. getHeightAtCoordinates(x: number, z: number): number;
  20048. /**
  20049. * Returns a normalized vector (Vector3) orthogonal to the ground
  20050. * at the ground coordinates (x, z) expressed in the World system.
  20051. * Returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  20052. */
  20053. getNormalAtCoordinates(x: number, z: number): Vector3;
  20054. /**
  20055. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  20056. * at the ground coordinates (x, z) expressed in the World system.
  20057. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  20058. * Returns the GroundMesh.
  20059. */
  20060. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  20061. /**
  20062. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  20063. * if the ground has been updated.
  20064. * This can be used in the render loop.
  20065. * Returns the GroundMesh.
  20066. */
  20067. updateCoordinateHeights(): GroundMesh;
  20068. private _getFacetAt(x, z);
  20069. private _initHeightQuads();
  20070. private _computeHeightQuads();
  20071. serialize(serializationObject: any): void;
  20072. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  20073. }
  20074. }
  20075. declare module BABYLON {
  20076. /**
  20077. * Creates an instance based on a source mesh.
  20078. */
  20079. class InstancedMesh extends AbstractMesh {
  20080. private _sourceMesh;
  20081. private _currentLOD;
  20082. constructor(name: string, source: Mesh);
  20083. /**
  20084. * Returns the string "InstancedMesh".
  20085. */
  20086. getClassName(): string;
  20087. readonly receiveShadows: boolean;
  20088. readonly material: Nullable<Material>;
  20089. readonly visibility: number;
  20090. readonly skeleton: Nullable<Skeleton>;
  20091. renderingGroupId: number;
  20092. /**
  20093. * Returns the total number of vertices (integer).
  20094. */
  20095. getTotalVertices(): number;
  20096. readonly sourceMesh: Mesh;
  20097. /**
  20098. * Is this node ready to be used/rendered
  20099. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  20100. * @return {boolean} is it ready
  20101. */
  20102. isReady(completeCheck?: boolean): boolean;
  20103. /**
  20104. * Returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  20105. */
  20106. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  20107. /**
  20108. * Sets the vertex data of the mesh geometry for the requested `kind`.
  20109. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  20110. * The `data` are either a numeric array either a Float32Array.
  20111. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  20112. * 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).
  20113. * Note that a new underlying VertexBuffer object is created each call.
  20114. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  20115. *
  20116. * Possible `kind` values :
  20117. * - BABYLON.VertexBuffer.PositionKind
  20118. * - BABYLON.VertexBuffer.UVKind
  20119. * - BABYLON.VertexBuffer.UV2Kind
  20120. * - BABYLON.VertexBuffer.UV3Kind
  20121. * - BABYLON.VertexBuffer.UV4Kind
  20122. * - BABYLON.VertexBuffer.UV5Kind
  20123. * - BABYLON.VertexBuffer.UV6Kind
  20124. * - BABYLON.VertexBuffer.ColorKind
  20125. * - BABYLON.VertexBuffer.MatricesIndicesKind
  20126. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  20127. * - BABYLON.VertexBuffer.MatricesWeightsKind
  20128. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  20129. *
  20130. * Returns the Mesh.
  20131. */
  20132. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  20133. /**
  20134. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  20135. * If the mesh has no geometry, it is simply returned as it is.
  20136. * The `data` are either a numeric array either a Float32Array.
  20137. * No new underlying VertexBuffer object is created.
  20138. * 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.
  20139. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  20140. *
  20141. * Possible `kind` values :
  20142. * - BABYLON.VertexBuffer.PositionKind
  20143. * - BABYLON.VertexBuffer.UVKind
  20144. * - BABYLON.VertexBuffer.UV2Kind
  20145. * - BABYLON.VertexBuffer.UV3Kind
  20146. * - BABYLON.VertexBuffer.UV4Kind
  20147. * - BABYLON.VertexBuffer.UV5Kind
  20148. * - BABYLON.VertexBuffer.UV6Kind
  20149. * - BABYLON.VertexBuffer.ColorKind
  20150. * - BABYLON.VertexBuffer.MatricesIndicesKind
  20151. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  20152. * - BABYLON.VertexBuffer.MatricesWeightsKind
  20153. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  20154. *
  20155. * Returns the Mesh.
  20156. */
  20157. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  20158. /**
  20159. * Sets the mesh indices.
  20160. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  20161. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  20162. * This method creates a new index buffer each call.
  20163. * Returns the Mesh.
  20164. */
  20165. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  20166. /**
  20167. * Boolean : True if the mesh owns the requested kind of data.
  20168. */
  20169. isVerticesDataPresent(kind: string): boolean;
  20170. /**
  20171. * Returns an array of indices (IndicesArray).
  20172. */
  20173. getIndices(): Nullable<IndicesArray>;
  20174. readonly _positions: Nullable<Vector3[]>;
  20175. /**
  20176. * Sets a new updated BoundingInfo to the mesh.
  20177. * Returns the mesh.
  20178. */
  20179. refreshBoundingInfo(): InstancedMesh;
  20180. _preActivate(): InstancedMesh;
  20181. _activate(renderId: number): InstancedMesh;
  20182. /**
  20183. * Returns the current associated LOD AbstractMesh.
  20184. */
  20185. getLOD(camera: Camera): AbstractMesh;
  20186. _syncSubMeshes(): InstancedMesh;
  20187. _generatePointsArray(): boolean;
  20188. /**
  20189. * Creates a new InstancedMesh from the current mesh.
  20190. * - name (string) : the cloned mesh name
  20191. * - newParent (optional Node) : the optional Node to parent the clone to.
  20192. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  20193. *
  20194. * Returns the clone.
  20195. */
  20196. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  20197. /**
  20198. * Disposes the InstancedMesh.
  20199. * Returns nothing.
  20200. */
  20201. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  20202. }
  20203. }
  20204. declare module BABYLON {
  20205. class LinesMesh extends Mesh {
  20206. useVertexColor: boolean | undefined;
  20207. useVertexAlpha: boolean | undefined;
  20208. color: Color3;
  20209. alpha: number;
  20210. /**
  20211. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  20212. * This margin is expressed in world space coordinates, so its value may vary.
  20213. * Default value is 0.1
  20214. * @returns the intersection Threshold value.
  20215. */
  20216. /**
  20217. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  20218. * This margin is expressed in world space coordinates, so its value may vary.
  20219. * @param value the new threshold to apply
  20220. */
  20221. intersectionThreshold: number;
  20222. private _intersectionThreshold;
  20223. private _colorShader;
  20224. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean, useVertexColor?: boolean | undefined, useVertexAlpha?: boolean | undefined);
  20225. /**
  20226. * Returns the string "LineMesh"
  20227. */
  20228. getClassName(): string;
  20229. material: Material;
  20230. readonly checkCollisions: boolean;
  20231. createInstance(name: string): InstancedMesh;
  20232. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  20233. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  20234. dispose(doNotRecurse?: boolean): void;
  20235. /**
  20236. * Returns a new LineMesh object cloned from the current one.
  20237. */
  20238. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  20239. }
  20240. }
  20241. declare module BABYLON {
  20242. /**
  20243. * @hidden
  20244. **/
  20245. class _InstancesBatch {
  20246. mustReturn: boolean;
  20247. visibleInstances: Nullable<InstancedMesh[]>[];
  20248. renderSelf: boolean[];
  20249. }
  20250. class Mesh extends AbstractMesh implements IGetSetVerticesData {
  20251. static _FRONTSIDE: number;
  20252. static _BACKSIDE: number;
  20253. static _DOUBLESIDE: number;
  20254. static _DEFAULTSIDE: number;
  20255. static _NO_CAP: number;
  20256. static _CAP_START: number;
  20257. static _CAP_END: number;
  20258. static _CAP_ALL: number;
  20259. /**
  20260. * Mesh side orientation : usually the external or front surface
  20261. */
  20262. static readonly FRONTSIDE: number;
  20263. /**
  20264. * Mesh side orientation : usually the internal or back surface
  20265. */
  20266. static readonly BACKSIDE: number;
  20267. /**
  20268. * Mesh side orientation : both internal and external or front and back surfaces
  20269. */
  20270. static readonly DOUBLESIDE: number;
  20271. /**
  20272. * Mesh side orientation : by default, `FRONTSIDE`
  20273. */
  20274. static readonly DEFAULTSIDE: number;
  20275. /**
  20276. * Mesh cap setting : no cap
  20277. */
  20278. static readonly NO_CAP: number;
  20279. /**
  20280. * Mesh cap setting : one cap at the beginning of the mesh
  20281. */
  20282. static readonly CAP_START: number;
  20283. /**
  20284. * Mesh cap setting : one cap at the end of the mesh
  20285. */
  20286. static readonly CAP_END: number;
  20287. /**
  20288. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  20289. */
  20290. static readonly CAP_ALL: number;
  20291. /**
  20292. * An event triggered before rendering the mesh
  20293. */
  20294. onBeforeRenderObservable: Observable<Mesh>;
  20295. /**
  20296. * An event triggered after rendering the mesh
  20297. */
  20298. onAfterRenderObservable: Observable<Mesh>;
  20299. /**
  20300. * An event triggered before drawing the mesh
  20301. */
  20302. onBeforeDrawObservable: Observable<Mesh>;
  20303. private _onBeforeDrawObserver;
  20304. onBeforeDraw: () => void;
  20305. delayLoadState: number;
  20306. instances: InstancedMesh[];
  20307. delayLoadingFile: string;
  20308. _binaryInfo: any;
  20309. private _LODLevels;
  20310. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Mesh) => void;
  20311. private _morphTargetManager;
  20312. morphTargetManager: Nullable<MorphTargetManager>;
  20313. _geometry: Nullable<Geometry>;
  20314. _delayInfo: Array<string>;
  20315. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  20316. _visibleInstances: any;
  20317. private _renderIdForInstances;
  20318. private _batchCache;
  20319. private _instancesBufferSize;
  20320. private _instancesBuffer;
  20321. private _instancesData;
  20322. private _overridenInstanceCount;
  20323. private _effectiveMaterial;
  20324. _shouldGenerateFlatShading: boolean;
  20325. private _preActivateId;
  20326. _originalBuilderSideOrientation: number;
  20327. overrideMaterialSideOrientation: Nullable<number>;
  20328. private _areNormalsFrozen;
  20329. private _sourcePositions;
  20330. private _sourceNormals;
  20331. private _source;
  20332. readonly source: Nullable<Mesh>;
  20333. isUnIndexed: boolean;
  20334. /**
  20335. * @constructor
  20336. * @param {string} name The value used by scene.getMeshByName() to do a lookup.
  20337. * @param {Scene} scene The scene to add this mesh to.
  20338. * @param {Node} parent The parent of this mesh, if it has one
  20339. * @param {Mesh} source An optional Mesh from which geometry is shared, cloned.
  20340. * @param {boolean} doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  20341. * When false, achieved by calling a clone(), also passing False.
  20342. * This will make creation of children, recursive.
  20343. * @param {boolean} clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  20344. */
  20345. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  20346. /**
  20347. * Returns the string "Mesh".
  20348. */
  20349. getClassName(): string;
  20350. /**
  20351. * Returns a string.
  20352. * @param {boolean} fullDetails - support for multiple levels of logging within scene loading
  20353. */
  20354. toString(fullDetails?: boolean): string;
  20355. _unBindEffect(): void;
  20356. /**
  20357. * True if the mesh has some Levels Of Details (LOD).
  20358. * Returns a boolean.
  20359. */
  20360. readonly hasLODLevels: boolean;
  20361. /**
  20362. * Gets the list of {BABYLON.MeshLODLevel} associated with the current mesh
  20363. * @returns an array of {BABYLON.MeshLODLevel}
  20364. */
  20365. getLODLevels(): MeshLODLevel[];
  20366. private _sortLODLevels();
  20367. /**
  20368. * Add a mesh as LOD level triggered at the given distance.
  20369. * tuto : http://doc.babylonjs.com/tutorials/How_to_use_LOD
  20370. * @param {number} distance The distance from the center of the object to show this level
  20371. * @param {Mesh} mesh The mesh to be added as LOD level
  20372. * @return {Mesh} This mesh (for chaining)
  20373. */
  20374. addLODLevel(distance: number, mesh: Mesh): Mesh;
  20375. /**
  20376. * Returns the LOD level mesh at the passed distance or null if not found.
  20377. * It is related to the method `addLODLevel(distance, mesh)`.
  20378. * tuto : http://doc.babylonjs.com/tutorials/How_to_use_LOD
  20379. * Returns an object Mesh or `null`.
  20380. */
  20381. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  20382. /**
  20383. * Remove a mesh from the LOD array
  20384. * tuto : http://doc.babylonjs.com/tutorials/How_to_use_LOD
  20385. * @param {Mesh} mesh The mesh to be removed.
  20386. * @return {Mesh} This mesh (for chaining)
  20387. */
  20388. removeLODLevel(mesh: Mesh): Mesh;
  20389. /**
  20390. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  20391. * tuto : http://doc.babylonjs.com/tutorials/How_to_use_LOD
  20392. */
  20393. getLOD(camera: Camera, boundingSphere?: BoundingSphere): AbstractMesh;
  20394. /**
  20395. * Returns the mesh internal Geometry object.
  20396. */
  20397. readonly geometry: Nullable<Geometry>;
  20398. /**
  20399. * Returns a positive integer : the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  20400. */
  20401. getTotalVertices(): number;
  20402. /**
  20403. * Returns an array of integers or floats, or a Float32Array, depending on the requested `kind` (positions, indices, normals, etc).
  20404. * 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.
  20405. * You can force the copy with forceCopy === true
  20406. * Returns null if the mesh has no geometry or no vertex buffer.
  20407. * Possible `kind` values :
  20408. * - BABYLON.VertexBuffer.PositionKind
  20409. * - BABYLON.VertexBuffer.UVKind
  20410. * - BABYLON.VertexBuffer.UV2Kind
  20411. * - BABYLON.VertexBuffer.UV3Kind
  20412. * - BABYLON.VertexBuffer.UV4Kind
  20413. * - BABYLON.VertexBuffer.UV5Kind
  20414. * - BABYLON.VertexBuffer.UV6Kind
  20415. * - BABYLON.VertexBuffer.ColorKind
  20416. * - BABYLON.VertexBuffer.MatricesIndicesKind
  20417. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  20418. * - BABYLON.VertexBuffer.MatricesWeightsKind
  20419. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  20420. */
  20421. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  20422. /**
  20423. * Returns the mesh VertexBuffer object from the requested `kind` : positions, indices, normals, etc.
  20424. * Returns `null` if the mesh has no geometry.
  20425. * Possible `kind` values :
  20426. * - BABYLON.VertexBuffer.PositionKind
  20427. * - BABYLON.VertexBuffer.UVKind
  20428. * - BABYLON.VertexBuffer.UV2Kind
  20429. * - BABYLON.VertexBuffer.UV3Kind
  20430. * - BABYLON.VertexBuffer.UV4Kind
  20431. * - BABYLON.VertexBuffer.UV5Kind
  20432. * - BABYLON.VertexBuffer.UV6Kind
  20433. * - BABYLON.VertexBuffer.ColorKind
  20434. * - BABYLON.VertexBuffer.MatricesIndicesKind
  20435. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  20436. * - BABYLON.VertexBuffer.MatricesWeightsKind
  20437. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  20438. */
  20439. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  20440. isVerticesDataPresent(kind: string): boolean;
  20441. /**
  20442. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  20443. * Possible `kind` values :
  20444. * - BABYLON.VertexBuffer.PositionKind
  20445. * - BABYLON.VertexBuffer.UVKind
  20446. * - BABYLON.VertexBuffer.UV2Kind
  20447. * - BABYLON.VertexBuffer.UV3Kind
  20448. * - BABYLON.VertexBuffer.UV4Kind
  20449. * - BABYLON.VertexBuffer.UV5Kind
  20450. * - BABYLON.VertexBuffer.UV6Kind
  20451. * - BABYLON.VertexBuffer.ColorKind
  20452. * - BABYLON.VertexBuffer.MatricesIndicesKind
  20453. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  20454. * - BABYLON.VertexBuffer.MatricesWeightsKind
  20455. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  20456. */
  20457. isVertexBufferUpdatable(kind: string): boolean;
  20458. /**
  20459. * Returns a string : the list of existing `kinds` of Vertex Data for this mesh.
  20460. * Possible `kind` values :
  20461. * - BABYLON.VertexBuffer.PositionKind
  20462. * - BABYLON.VertexBuffer.UVKind
  20463. * - BABYLON.VertexBuffer.UV2Kind
  20464. * - BABYLON.VertexBuffer.UV3Kind
  20465. * - BABYLON.VertexBuffer.UV4Kind
  20466. * - BABYLON.VertexBuffer.UV5Kind
  20467. * - BABYLON.VertexBuffer.UV6Kind
  20468. * - BABYLON.VertexBuffer.ColorKind
  20469. * - BABYLON.VertexBuffer.MatricesIndicesKind
  20470. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  20471. * - BABYLON.VertexBuffer.MatricesWeightsKind
  20472. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  20473. */
  20474. getVerticesDataKinds(): string[];
  20475. /**
  20476. * Returns a positive integer : the total number of indices in this mesh geometry.
  20477. * Returns zero if the mesh has no geometry.
  20478. */
  20479. getTotalIndices(): number;
  20480. /**
  20481. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  20482. * 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.
  20483. * Returns an empty array if the mesh has no geometry.
  20484. */
  20485. getIndices(copyWhenShared?: boolean): Nullable<IndicesArray>;
  20486. readonly isBlocked: boolean;
  20487. /**
  20488. * Determine if the current mesh is ready to be rendered
  20489. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  20490. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  20491. * @returns true if all associated assets are ready (material, textures, shaders)
  20492. */
  20493. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  20494. /**
  20495. * Boolean : true if the normals aren't to be recomputed on next mesh `positions` array update.
  20496. * This property is pertinent only for updatable parametric shapes.
  20497. */
  20498. readonly areNormalsFrozen: boolean;
  20499. /**
  20500. * This function affects parametric shapes on vertex position update only : ribbons, tubes, etc.
  20501. * It has no effect at all on other shapes.
  20502. * It prevents the mesh normals from being recomputed on next `positions` array update.
  20503. * Returns the Mesh.
  20504. */
  20505. freezeNormals(): Mesh;
  20506. /**
  20507. * This function affects parametric shapes on vertex position update only : ribbons, tubes, etc.
  20508. * It has no effect at all on other shapes.
  20509. * It reactivates the mesh normals computation if it was previously frozen.
  20510. * Returns the Mesh.
  20511. */
  20512. unfreezeNormals(): Mesh;
  20513. /**
  20514. * Overrides instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  20515. */
  20516. overridenInstanceCount: number;
  20517. _preActivate(): Mesh;
  20518. _preActivateForIntermediateRendering(renderId: number): Mesh;
  20519. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  20520. /**
  20521. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  20522. * This means the mesh underlying bounding box and sphere are recomputed.
  20523. * Returns the Mesh.
  20524. */
  20525. refreshBoundingInfo(): Mesh;
  20526. _refreshBoundingInfo(applySkeleton: boolean): Mesh;
  20527. private _getPositionData(applySkeleton);
  20528. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  20529. subdivide(count: number): void;
  20530. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  20531. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  20532. /**
  20533. * Sets the mesh VertexBuffer.
  20534. * Returns the Mesh.
  20535. */
  20536. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  20537. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  20538. /**
  20539. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  20540. * tuto : http://doc.babylonjs.com/tutorials/How_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  20541. * The parameter `positionFunction` is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything.
  20542. * The parameter `computeNormals` is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update.
  20543. * Returns the Mesh.
  20544. */
  20545. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  20546. /**
  20547. * Creates a un-shared specific occurence of the geometry for the mesh.
  20548. * Returns the Mesh.
  20549. */
  20550. makeGeometryUnique(): Mesh;
  20551. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  20552. /**
  20553. * Update the current index buffer
  20554. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  20555. * Returns the Mesh.
  20556. */
  20557. updateIndices(indices: IndicesArray, offset?: number): Mesh;
  20558. /**
  20559. * Invert the geometry to move from a right handed system to a left handed one.
  20560. * Returns the Mesh.
  20561. */
  20562. toLeftHanded(): Mesh;
  20563. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  20564. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number, alternate?: boolean): Mesh;
  20565. /**
  20566. * Registers for this mesh a javascript function called just before the rendering process.
  20567. * This function is passed the current mesh.
  20568. * Return the Mesh.
  20569. */
  20570. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  20571. /**
  20572. * Disposes a previously registered javascript function called before the rendering.
  20573. * This function is passed the current mesh.
  20574. * Returns the Mesh.
  20575. */
  20576. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  20577. /**
  20578. * Registers for this mesh a javascript function called just after the rendering is complete.
  20579. * This function is passed the current mesh.
  20580. * Returns the Mesh.
  20581. */
  20582. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  20583. /**
  20584. * Disposes a previously registered javascript function called after the rendering.
  20585. * This function is passed the current mesh.
  20586. * Return the Mesh.
  20587. */
  20588. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  20589. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  20590. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  20591. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  20592. /**
  20593. * Triggers the draw call for the mesh.
  20594. * Usually, you don't need to call this method by your own because the mesh rendering is handled by the scene rendering manager.
  20595. * Returns the Mesh.
  20596. */
  20597. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  20598. private _onBeforeDraw(isInstance, world, effectiveMaterial?);
  20599. /**
  20600. * Returns an array populated with ParticleSystem objects whose the mesh is the emitter.
  20601. */
  20602. getEmittedParticleSystems(): IParticleSystem[];
  20603. /**
  20604. * Returns an array populated with ParticleSystem objects whose the mesh or its children are the emitter.
  20605. */
  20606. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  20607. /**
  20608. * Normalize matrix weights so that all vertices have a total weight set to 1
  20609. */
  20610. cleanMatrixWeights(): void;
  20611. _checkDelayState(): Mesh;
  20612. private _queueLoad(scene);
  20613. /**
  20614. * Boolean, true is the mesh in the frustum defined by the Plane objects from the `frustumPlanes` array parameter.
  20615. */
  20616. isInFrustum(frustumPlanes: Plane[]): boolean;
  20617. /**
  20618. * Sets the mesh material by the material or multiMaterial `id` property.
  20619. * The material `id` is a string identifying the material or the multiMaterial.
  20620. * This method returns the Mesh.
  20621. */
  20622. setMaterialByID(id: string): Mesh;
  20623. /**
  20624. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  20625. */
  20626. getAnimatables(): IAnimatable[];
  20627. /**
  20628. * Modifies the mesh geometry according to the passed transformation matrix.
  20629. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  20630. * The mesh normals are modified accordingly the same transformation.
  20631. * tuto : http://doc.babylonjs.com/resources/baking_transformations
  20632. * Note that, under the hood, this method sets a new VertexBuffer each call.
  20633. * Returns the Mesh.
  20634. */
  20635. bakeTransformIntoVertices(transform: Matrix): Mesh;
  20636. /**
  20637. * Modifies the mesh geometry according to its own current World Matrix.
  20638. * The mesh World Matrix is then reset.
  20639. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  20640. * tuto : tuto : http://doc.babylonjs.com/resources/baking_transformations
  20641. * Note that, under the hood, this method sets a new VertexBuffer each call.
  20642. * Returns the Mesh.
  20643. */
  20644. bakeCurrentTransformIntoVertices(): Mesh;
  20645. readonly _positions: Nullable<Vector3[]>;
  20646. _resetPointsArrayCache(): Mesh;
  20647. _generatePointsArray(): boolean;
  20648. /**
  20649. * Returns a new Mesh object generated from the current mesh properties.
  20650. * This method must not get confused with createInstance().
  20651. * The parameter `name` is a string, the name given to the new mesh.
  20652. * The optional parameter `newParent` can be any Node object (default `null`).
  20653. * The optional parameter `doNotCloneChildren` (default `false`) allows/denies the recursive cloning of the original mesh children if any.
  20654. * 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.
  20655. */
  20656. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  20657. /**
  20658. * Releases resources associated with this mesh.
  20659. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  20660. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  20661. */
  20662. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  20663. /**
  20664. * Modifies the mesh geometry according to a displacement map.
  20665. * 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.
  20666. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  20667. * This method returns nothing.
  20668. * The parameter `url` is a string, the URL from the image file is to be downloaded.
  20669. * The parameters `minHeight` and `maxHeight` are the lower and upper limits of the displacement.
  20670. * 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.
  20671. * The parameter `uvOffset` is an optional vector2 used to offset UV.
  20672. * The parameter `uvScale` is an optional vector2 used to scale UV.
  20673. *
  20674. * Returns the Mesh.
  20675. */
  20676. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2): Mesh;
  20677. /**
  20678. * Modifies the mesh geometry according to a displacementMap buffer.
  20679. * 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.
  20680. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  20681. * This method returns nothing.
  20682. * 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.
  20683. * The parameters `heightMapWidth` and `heightMapHeight` are positive integers to set the width and height of the buffer image.
  20684. * The parameters `minHeight` and `maxHeight` are the lower and upper limits of the displacement.
  20685. * The parameter `uvOffset` is an optional vector2 used to offset UV.
  20686. * The parameter `uvScale` is an optional vector2 used to scale UV.
  20687. *
  20688. * Returns the Mesh.
  20689. */
  20690. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2): Mesh;
  20691. /**
  20692. * Modify the mesh to get a flat shading rendering.
  20693. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  20694. * This method returns the Mesh.
  20695. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  20696. */
  20697. convertToFlatShadedMesh(): Mesh;
  20698. /**
  20699. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  20700. * In other words, more vertices, no more indices and a single bigger VBO.
  20701. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  20702. * Returns the Mesh.
  20703. */
  20704. convertToUnIndexedMesh(): Mesh;
  20705. /**
  20706. * Inverses facet orientations and inverts also the normals with `flipNormals` (default `false`) if true.
  20707. * This method returns the Mesh.
  20708. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  20709. */
  20710. flipFaces(flipNormals?: boolean): Mesh;
  20711. /**
  20712. * Creates a new InstancedMesh object from the mesh model.
  20713. * An instance shares the same properties and the same material than its model.
  20714. * Only these properties of each instance can then be set individually :
  20715. * - position
  20716. * - rotation
  20717. * - rotationQuaternion
  20718. * - setPivotMatrix
  20719. * - scaling
  20720. * tuto : http://doc.babylonjs.com/tutorials/How_to_use_Instances
  20721. * Warning : this method is not supported for Line mesh and LineSystem
  20722. */
  20723. createInstance(name: string): InstancedMesh;
  20724. /**
  20725. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  20726. * After this call, all the mesh instances have the same submeshes than the current mesh.
  20727. * This method returns the Mesh.
  20728. */
  20729. synchronizeInstances(): Mesh;
  20730. /**
  20731. * Simplify the mesh according to the given array of settings.
  20732. * Function will return immediately and will simplify async. It returns the Mesh.
  20733. * @param settings a collection of simplification settings.
  20734. * @param parallelProcessing should all levels calculate parallel or one after the other.
  20735. * @param type the type of simplification to run.
  20736. * @param successCallback optional success callback to be called after the simplification finished processing all settings.
  20737. */
  20738. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  20739. /**
  20740. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  20741. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  20742. * This should be used together with the simplification to avoid disappearing triangles.
  20743. * Returns the Mesh.
  20744. * @param successCallback an optional success callback to be called after the optimization finished.
  20745. */
  20746. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  20747. serialize(serializationObject: any): void;
  20748. _syncGeometryWithMorphTargetManager(): void;
  20749. /**
  20750. * Returns a new Mesh object parsed from the source provided.
  20751. * The parameter `parsedMesh` is the source.
  20752. * The parameter `rootUrl` is a string, it's the root URL to prefix the `delayLoadingFile` property with
  20753. */
  20754. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  20755. /**
  20756. * Creates a ribbon mesh.
  20757. * Please consider using the same method from the MeshBuilder class instead.
  20758. * 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.
  20759. *
  20760. * Please read this full tutorial to understand how to design a ribbon : http://doc.babylonjs.com/tutorials/Ribbon_Tutorial
  20761. * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  20762. * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array.
  20763. * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array.
  20764. * 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.
  20765. * 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.
  20766. * 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
  20767. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  20768. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  20769. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  20770. */
  20771. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean | undefined, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  20772. /**
  20773. * Creates a plane polygonal mesh. By default, this is a disc.
  20774. * Please consider using the same method from the MeshBuilder class instead.
  20775. * The parameter `radius` sets the radius size (float) of the polygon (default 0.5).
  20776. * 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.
  20777. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  20778. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  20779. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  20780. */
  20781. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  20782. /**
  20783. * Creates a box mesh.
  20784. * Please consider using the same method from the MeshBuilder class instead.
  20785. * The parameter `size` sets the size (float) of each box side (default 1).
  20786. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  20787. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  20788. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  20789. */
  20790. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  20791. /**
  20792. * Creates a sphere mesh.
  20793. * Please consider using the same method from the MeshBuilder class instead.
  20794. * The parameter `diameter` sets the diameter size (float) of the sphere (default 1).
  20795. * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32).
  20796. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  20797. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  20798. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  20799. */
  20800. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  20801. /**
  20802. * Creates a cylinder or a cone mesh.
  20803. * Please consider using the same method from the MeshBuilder class instead.
  20804. * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  20805. * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  20806. * 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.
  20807. * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  20808. * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  20809. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  20810. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  20811. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  20812. */
  20813. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  20814. /**
  20815. * Creates a torus mesh.
  20816. * Please consider using the same method from the MeshBuilder class instead.
  20817. * The parameter `diameter` sets the diameter size (float) of the torus (default 1).
  20818. * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5).
  20819. * The parameter `tessellation` sets the number of torus sides (postive integer, default 16).
  20820. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  20821. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  20822. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  20823. */
  20824. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  20825. /**
  20826. * Creates a torus knot mesh.
  20827. * Please consider using the same method from the MeshBuilder class instead.
  20828. * The parameter `radius` sets the global radius size (float) of the torus knot (default 2).
  20829. * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32).
  20830. * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32).
  20831. * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3).
  20832. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  20833. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  20834. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  20835. */
  20836. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  20837. /**
  20838. * Creates a line mesh.
  20839. * Please consider using the same method from the MeshBuilder class instead.
  20840. * 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.
  20841. * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function.
  20842. * The parameter `points` is an array successive Vector3.
  20843. * 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
  20844. * When updating an instance, remember that only point positions can change, not the number of points.
  20845. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  20846. */
  20847. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  20848. /**
  20849. * Creates a dashed line mesh.
  20850. * Please consider using the same method from the MeshBuilder class instead.
  20851. * 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.
  20852. * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function.
  20853. * The parameter `points` is an array successive Vector3.
  20854. * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200).
  20855. * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3).
  20856. * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1).
  20857. * 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
  20858. * When updating an instance, remember that only point positions can change, not the number of points.
  20859. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  20860. */
  20861. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  20862. /**
  20863. * Creates a polygon mesh.
  20864. * Please consider using the same method from the MeshBuilder class instead.
  20865. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  20866. * 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.
  20867. * You can set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  20868. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  20869. * Remember you can only change the shape positions, not their number when updating a polygon.
  20870. */
  20871. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number): Mesh;
  20872. /**
  20873. * Creates an extruded polygon mesh, with depth in the Y direction.
  20874. * Please consider using the same method from the MeshBuilder class instead.
  20875. */
  20876. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number): Mesh;
  20877. /**
  20878. * Creates an extruded shape mesh.
  20879. * 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.
  20880. * Please consider using the same method from the MeshBuilder class instead.
  20881. *
  20882. * Please read this full tutorial to understand how to design an extruded shape : http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  20883. * 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
  20884. * extruded along the Z axis.
  20885. * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  20886. * 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.
  20887. * The parameter `scale` (float, default 1) is the value to scale the shape.
  20888. * 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
  20889. * 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
  20890. * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  20891. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  20892. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  20893. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  20894. */
  20895. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  20896. /**
  20897. * Creates an custom extruded shape mesh.
  20898. * 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.
  20899. * Please consider using the same method from the MeshBuilder class instead.
  20900. *
  20901. * Please read this full tutorial to understand how to design a custom extruded shape : http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  20902. * 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
  20903. * extruded along the Z axis.
  20904. * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  20905. * 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
  20906. * and the distance of this point from the begining of the path :
  20907. * ```javascript
  20908. * var rotationFunction = function(i, distance) {
  20909. * // do things
  20910. * return rotationValue; }
  20911. * ```
  20912. * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  20913. * 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
  20914. * and the distance of this point from the begining of the path :
  20915. * ```javascript
  20916. * var scaleFunction = function(i, distance) {
  20917. * // do things
  20918. * return scaleValue;}
  20919. * ```
  20920. * It must returns a float value that will be the scale value applied to the shape on each path point.
  20921. * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`.
  20922. * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`.
  20923. * 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
  20924. * 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
  20925. * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  20926. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  20927. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  20928. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  20929. */
  20930. 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;
  20931. /**
  20932. * Creates lathe mesh.
  20933. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  20934. * Please consider using the same method from the MeshBuilder class instead.
  20935. * 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
  20936. * rotated around the Y axis. It's usually a 2D shape, so the Vector3 z coordinates are often set to zero.
  20937. * The parameter `radius` (positive float, default 1) is the radius value of the lathe.
  20938. * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe.
  20939. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  20940. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  20941. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  20942. */
  20943. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  20944. /**
  20945. * Creates a plane mesh.
  20946. * Please consider using the same method from the MeshBuilder class instead.
  20947. * The parameter `size` sets the size (float) of both sides of the plane at once (default 1).
  20948. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  20949. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  20950. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  20951. */
  20952. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  20953. /**
  20954. * Creates a ground mesh.
  20955. * Please consider using the same method from the MeshBuilder class instead.
  20956. * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground.
  20957. * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side.
  20958. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  20959. */
  20960. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  20961. /**
  20962. * Creates a tiled ground mesh.
  20963. * Please consider using the same method from the MeshBuilder class instead.
  20964. * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates.
  20965. * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates.
  20966. * The parameter `subdivisions` is a javascript object `{w: positive integer, h: positive integer}` (default `{w: 6, h: 6}`). `w` and `h` are the
  20967. * numbers of subdivisions on the ground width and height. Each subdivision is called a tile.
  20968. * The parameter `precision` is a javascript object `{w: positive integer, h: positive integer}` (default `{w: 2, h: 2}`). `w` and `h` are the
  20969. * numbers of subdivisions on the ground width and height of each tile.
  20970. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  20971. */
  20972. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  20973. w: number;
  20974. h: number;
  20975. }, precision: {
  20976. w: number;
  20977. h: number;
  20978. }, scene: Scene, updatable?: boolean): Mesh;
  20979. /**
  20980. * Creates a ground mesh from a height map.
  20981. * tuto : http://doc.babylonjs.com/babylon101/height_map
  20982. * Please consider using the same method from the MeshBuilder class instead.
  20983. * The parameter `url` sets the URL of the height map image resource.
  20984. * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  20985. * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  20986. * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  20987. * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  20988. * 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).
  20989. * This function is passed the newly built mesh :
  20990. * ```javascript
  20991. * function(mesh) { // do things
  20992. * return; }
  20993. * ```
  20994. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  20995. */
  20996. 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;
  20997. /**
  20998. * Creates a tube mesh.
  20999. * 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.
  21000. * Please consider using the same method from the MeshBuilder class instead.
  21001. * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube.
  21002. * The parameter `radius` (positive float, default 1) sets the tube radius size.
  21003. * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface.
  21004. * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`.
  21005. * 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.
  21006. * It must return a radius value (positive float) :
  21007. * ```javascript
  21008. * var radiusFunction = function(i, distance) {
  21009. * // do things
  21010. * return radius; }
  21011. * ```
  21012. * 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
  21013. * 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
  21014. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21015. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  21016. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21017. */
  21018. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  21019. (i: number, distance: number): number;
  21020. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  21021. /**
  21022. * Creates a polyhedron mesh.
  21023. * Please consider using the same method from the MeshBuilder class instead.
  21024. * 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
  21025. * to choose the wanted type.
  21026. * The parameter `size` (positive float, default 1) sets the polygon size.
  21027. * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value).
  21028. * 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`.
  21029. * 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
  21030. * 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)`).
  21031. * 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
  21032. * 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.
  21033. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21034. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  21035. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21036. */
  21037. static CreatePolyhedron(name: string, options: {
  21038. type?: number;
  21039. size?: number;
  21040. sizeX?: number;
  21041. sizeY?: number;
  21042. sizeZ?: number;
  21043. custom?: any;
  21044. faceUV?: Vector4[];
  21045. faceColors?: Color4[];
  21046. updatable?: boolean;
  21047. sideOrientation?: number;
  21048. }, scene: Scene): Mesh;
  21049. /**
  21050. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided.
  21051. * Please consider using the same method from the MeshBuilder class instead.
  21052. * The parameter `radius` sets the radius size (float) of the icosphere (default 1).
  21053. * 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`).
  21054. * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size.
  21055. * 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.
  21056. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21057. * Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  21058. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21059. */
  21060. static CreateIcoSphere(name: string, options: {
  21061. radius?: number;
  21062. flat?: boolean;
  21063. subdivisions?: number;
  21064. sideOrientation?: number;
  21065. updatable?: boolean;
  21066. }, scene: Scene): Mesh;
  21067. /**
  21068. * Creates a decal mesh.
  21069. * Please consider using the same method from the MeshBuilder class instead.
  21070. * 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.
  21071. * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates.
  21072. * The parameter `normal` (Vector3, default Vector3.Up) sets the normal of the mesh where the decal is applied onto in World coordinates.
  21073. * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling.
  21074. * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal.
  21075. */
  21076. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  21077. /**
  21078. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  21079. */
  21080. setPositionsForCPUSkinning(): Float32Array;
  21081. /**
  21082. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  21083. */
  21084. setNormalsForCPUSkinning(): Float32Array;
  21085. /**
  21086. * Updates the vertex buffer by applying transformation from the bones.
  21087. * Returns the Mesh.
  21088. *
  21089. * @param {skeleton} skeleton to apply
  21090. */
  21091. applySkeleton(skeleton: Skeleton): Mesh;
  21092. /**
  21093. * Returns an object `{min:` Vector3`, max:` Vector3`}`
  21094. * This min and max Vector3 are the minimum and maximum vectors of each mesh bounding box from the passed array, in the World system
  21095. */
  21096. static MinMax(meshes: AbstractMesh[]): {
  21097. min: Vector3;
  21098. max: Vector3;
  21099. };
  21100. /**
  21101. * Returns a Vector3, the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array.
  21102. */
  21103. static Center(meshesOrMinMaxVector: {
  21104. min: Vector3;
  21105. max: Vector3;
  21106. } | AbstractMesh[]): Vector3;
  21107. /**
  21108. * Merge the array of meshes into a single mesh for performance reasons.
  21109. * @param {Array<Mesh>} meshes - The vertices source. They should all be of the same material. Entries can empty
  21110. * @param {boolean} disposeSource - When true (default), dispose of the vertices from the source meshes
  21111. * @param {boolean} allow32BitsIndices - When the sum of the vertices > 64k, this must be set to true.
  21112. * @param {Mesh} meshSubclass - When set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  21113. * @param {boolean} subdivideWithSubMeshes - When true (false default), subdivide mesh to his subMesh array with meshes source.
  21114. */
  21115. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean): Nullable<Mesh>;
  21116. }
  21117. }
  21118. declare module BABYLON {
  21119. /**
  21120. * Define an interface for all classes that will get and set the data on vertices
  21121. */
  21122. interface IGetSetVerticesData {
  21123. isVerticesDataPresent(kind: string): boolean;
  21124. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21125. getIndices(copyWhenShared?: boolean): Nullable<IndicesArray>;
  21126. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  21127. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  21128. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  21129. }
  21130. /**
  21131. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  21132. */
  21133. class VertexData {
  21134. /**
  21135. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  21136. */
  21137. positions: Nullable<FloatArray>;
  21138. /**
  21139. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  21140. */
  21141. normals: Nullable<FloatArray>;
  21142. /**
  21143. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  21144. */
  21145. tangents: Nullable<FloatArray>;
  21146. /**
  21147. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21148. */
  21149. uvs: Nullable<FloatArray>;
  21150. /**
  21151. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21152. */
  21153. uvs2: Nullable<FloatArray>;
  21154. /**
  21155. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21156. */
  21157. uvs3: Nullable<FloatArray>;
  21158. /**
  21159. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21160. */
  21161. uvs4: Nullable<FloatArray>;
  21162. /**
  21163. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21164. */
  21165. uvs5: Nullable<FloatArray>;
  21166. /**
  21167. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21168. */
  21169. uvs6: Nullable<FloatArray>;
  21170. /**
  21171. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  21172. */
  21173. colors: Nullable<FloatArray>;
  21174. /**
  21175. * 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).
  21176. */
  21177. matricesIndices: Nullable<FloatArray>;
  21178. /**
  21179. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  21180. */
  21181. matricesWeights: Nullable<FloatArray>;
  21182. /**
  21183. * An array extending the number of possible indices
  21184. */
  21185. matricesIndicesExtra: Nullable<FloatArray>;
  21186. /**
  21187. * An array extending the number of possible weights when the number of indices is extended
  21188. */
  21189. matricesWeightsExtra: Nullable<FloatArray>;
  21190. /**
  21191. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  21192. */
  21193. indices: Nullable<IndicesArray>;
  21194. /**
  21195. * Uses the passed data array to set the set the values for the specified kind of data
  21196. * @param data a linear array of floating numbers
  21197. * @param kind the type of data that is being set, eg positions, colors etc
  21198. */
  21199. set(data: FloatArray, kind: string): void;
  21200. /**
  21201. * Associates the vertexData to the passed Mesh.
  21202. * Sets it as updatable or not (default `false`)
  21203. * @param mesh the mesh the vertexData is applied to
  21204. * @param updatable when used and having the value true allows new data to update the vertexData
  21205. * @returns the VertexData
  21206. */
  21207. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  21208. /**
  21209. * Associates the vertexData to the passed Geometry.
  21210. * Sets it as updatable or not (default `false`)
  21211. * @param geometry the geometry the vertexData is applied to
  21212. * @param updatable when used and having the value true allows new data to update the vertexData
  21213. * @returns VertexData
  21214. */
  21215. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  21216. /**
  21217. * Updates the associated mesh
  21218. * @param mesh the mesh to be updated
  21219. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  21220. * @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
  21221. * @returns VertexData
  21222. */
  21223. updateMesh(mesh: Mesh, updateExtends?: boolean, makeItUnique?: boolean): VertexData;
  21224. /**
  21225. * Updates the associated geometry
  21226. * @param geometry the geometry to be updated
  21227. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  21228. * @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
  21229. * @returns VertexData.
  21230. */
  21231. updateGeometry(geometry: Geometry, updateExtends?: boolean, makeItUnique?: boolean): VertexData;
  21232. private _applyTo(meshOrGeometry, updatable?);
  21233. private _update(meshOrGeometry, updateExtends?, makeItUnique?);
  21234. /**
  21235. * Transforms each position and each normal of the vertexData according to the passed Matrix
  21236. * @param matrix the transforming matrix
  21237. * @returns the VertexData
  21238. */
  21239. transform(matrix: Matrix): VertexData;
  21240. /**
  21241. * Merges the passed VertexData into the current one
  21242. * @param other the VertexData to be merged into the current one
  21243. * @returns the modified VertexData
  21244. */
  21245. merge(other: VertexData): VertexData;
  21246. private _mergeElement(source, other);
  21247. private _validate();
  21248. /**
  21249. * Serializes the VertexData
  21250. * @returns a serialized object
  21251. */
  21252. serialize(): any;
  21253. /**
  21254. * Extracts the vertexData from a mesh
  21255. * @param mesh the mesh from which to extract the VertexData
  21256. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  21257. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  21258. * @returns the object VertexData associated to the passed mesh
  21259. */
  21260. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  21261. /**
  21262. * Extracts the vertexData from the geometry
  21263. * @param geometry the geometry from which to extract the VertexData
  21264. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  21265. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  21266. * @returns the object VertexData associated to the passed mesh
  21267. */
  21268. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  21269. private static _ExtractFrom(meshOrGeometry, copyWhenShared?, forceCopy?);
  21270. /**
  21271. * Creates the VertexData for a Ribbon
  21272. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  21273. * * pathArray array of paths, each of which an array of successive Vector3
  21274. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  21275. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  21276. * * 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
  21277. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21278. * * 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)
  21279. * * 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)
  21280. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  21281. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  21282. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  21283. * @returns the VertexData of the ribbon
  21284. */
  21285. static CreateRibbon(options: {
  21286. pathArray: Vector3[][];
  21287. closeArray?: boolean;
  21288. closePath?: boolean;
  21289. offset?: number;
  21290. sideOrientation?: number;
  21291. frontUVs?: Vector4;
  21292. backUVs?: Vector4;
  21293. invertUV?: boolean;
  21294. uvs?: Vector2[];
  21295. colors?: Color4[];
  21296. }): VertexData;
  21297. /**
  21298. * Creates the VertexData for a box
  21299. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21300. * * size sets the width, height and depth of the box to the value of size, optional default 1
  21301. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  21302. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  21303. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  21304. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  21305. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  21306. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21307. * * 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)
  21308. * * 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)
  21309. * @returns the VertexData of the box
  21310. */
  21311. static CreateBox(options: {
  21312. size?: number;
  21313. width?: number;
  21314. height?: number;
  21315. depth?: number;
  21316. faceUV?: Vector4[];
  21317. faceColors?: Color4[];
  21318. sideOrientation?: number;
  21319. frontUVs?: Vector4;
  21320. backUVs?: Vector4;
  21321. }): VertexData;
  21322. /**
  21323. * Creates the VertexData for an ellipsoid, defaults to a sphere
  21324. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21325. * * segments sets the number of horizontal strips optional, default 32
  21326. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  21327. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  21328. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  21329. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  21330. * * 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
  21331. * * 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
  21332. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21333. * * 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)
  21334. * * 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)
  21335. * @returns the VertexData of the ellipsoid
  21336. */
  21337. static CreateSphere(options: {
  21338. segments?: number;
  21339. diameter?: number;
  21340. diameterX?: number;
  21341. diameterY?: number;
  21342. diameterZ?: number;
  21343. arc?: number;
  21344. slice?: number;
  21345. sideOrientation?: number;
  21346. frontUVs?: Vector4;
  21347. backUVs?: Vector4;
  21348. }): VertexData;
  21349. /**
  21350. * Creates the VertexData for a cylinder, cone or prism
  21351. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21352. * * height sets the height (y direction) of the cylinder, optional, default 2
  21353. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  21354. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  21355. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  21356. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  21357. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  21358. * * 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
  21359. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  21360. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  21361. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  21362. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  21363. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21364. * * 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)
  21365. * * 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)
  21366. * @returns the VertexData of the cylinder, cone or prism
  21367. */
  21368. static CreateCylinder(options: {
  21369. height?: number;
  21370. diameterTop?: number;
  21371. diameterBottom?: number;
  21372. diameter?: number;
  21373. tessellation?: number;
  21374. subdivisions?: number;
  21375. arc?: number;
  21376. faceColors?: Color4[];
  21377. faceUV?: Vector4[];
  21378. hasRings?: boolean;
  21379. enclose?: boolean;
  21380. sideOrientation?: number;
  21381. frontUVs?: Vector4;
  21382. backUVs?: Vector4;
  21383. }): VertexData;
  21384. /**
  21385. * Creates the VertexData for a torus
  21386. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21387. * * diameter the diameter of the torus, optional default 1
  21388. * * thickness the diameter of the tube forming the torus, optional default 0.5
  21389. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  21390. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21391. * * 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)
  21392. * * 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)
  21393. * @returns the VertexData of the torus
  21394. */
  21395. static CreateTorus(options: {
  21396. diameter?: number;
  21397. thickness?: number;
  21398. tessellation?: number;
  21399. sideOrientation?: number;
  21400. frontUVs?: Vector4;
  21401. backUVs?: Vector4;
  21402. }): VertexData;
  21403. /**
  21404. * Creates the VertexData of the LineSystem
  21405. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  21406. * - lines an array of lines, each line being an array of successive Vector3
  21407. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  21408. * @returns the VertexData of the LineSystem
  21409. */
  21410. static CreateLineSystem(options: {
  21411. lines: Vector3[][];
  21412. colors?: Nullable<Color4[][]>;
  21413. }): VertexData;
  21414. /**
  21415. * Create the VertexData for a DashedLines
  21416. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  21417. * - points an array successive Vector3
  21418. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  21419. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  21420. * - dashNb the intended total number of dashes, optional, default 200
  21421. * @returns the VertexData for the DashedLines
  21422. */
  21423. static CreateDashedLines(options: {
  21424. points: Vector3[];
  21425. dashSize?: number;
  21426. gapSize?: number;
  21427. dashNb?: number;
  21428. }): VertexData;
  21429. /**
  21430. * Creates the VertexData for a Ground
  21431. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  21432. * - width the width (x direction) of the ground, optional, default 1
  21433. * - height the height (z direction) of the ground, optional, default 1
  21434. * - subdivisions the number of subdivisions per side, optional, default 1
  21435. * @returns the VertexData of the Ground
  21436. */
  21437. static CreateGround(options: {
  21438. width?: number;
  21439. height?: number;
  21440. subdivisions?: number;
  21441. subdivisionsX?: number;
  21442. subdivisionsY?: number;
  21443. }): VertexData;
  21444. /**
  21445. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  21446. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  21447. * * xmin the ground minimum X coordinate, optional, default -1
  21448. * * zmin the ground minimum Z coordinate, optional, default -1
  21449. * * xmax the ground maximum X coordinate, optional, default 1
  21450. * * zmax the ground maximum Z coordinate, optional, default 1
  21451. * * 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}
  21452. * * 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}
  21453. * @returns the VertexData of the TiledGround
  21454. */
  21455. static CreateTiledGround(options: {
  21456. xmin: number;
  21457. zmin: number;
  21458. xmax: number;
  21459. zmax: number;
  21460. subdivisions?: {
  21461. w: number;
  21462. h: number;
  21463. };
  21464. precision?: {
  21465. w: number;
  21466. h: number;
  21467. };
  21468. }): VertexData;
  21469. /**
  21470. * Creates the VertexData of the Ground designed from a heightmap
  21471. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  21472. * * width the width (x direction) of the ground
  21473. * * height the height (z direction) of the ground
  21474. * * subdivisions the number of subdivisions per side
  21475. * * minHeight the minimum altitude on the ground, optional, default 0
  21476. * * maxHeight the maximum altitude on the ground, optional default 1
  21477. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  21478. * * buffer the array holding the image color data
  21479. * * bufferWidth the width of image
  21480. * * bufferHeight the height of image
  21481. * @returns the VertexData of the Ground designed from a heightmap
  21482. */
  21483. static CreateGroundFromHeightMap(options: {
  21484. width: number;
  21485. height: number;
  21486. subdivisions: number;
  21487. minHeight: number;
  21488. maxHeight: number;
  21489. colorFilter: Color3;
  21490. buffer: Uint8Array;
  21491. bufferWidth: number;
  21492. bufferHeight: number;
  21493. }): VertexData;
  21494. /**
  21495. * Creates the VertexData for a Plane
  21496. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  21497. * * size sets the width and height of the plane to the value of size, optional default 1
  21498. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  21499. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  21500. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21501. * * 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)
  21502. * * 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)
  21503. * @returns the VertexData of the box
  21504. */
  21505. static CreatePlane(options: {
  21506. size?: number;
  21507. width?: number;
  21508. height?: number;
  21509. sideOrientation?: number;
  21510. frontUVs?: Vector4;
  21511. backUVs?: Vector4;
  21512. }): VertexData;
  21513. /**
  21514. * Creates the VertexData of the Disc or regular Polygon
  21515. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  21516. * * radius the radius of the disc, optional default 0.5
  21517. * * tessellation the number of polygon sides, optional, default 64
  21518. * * 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
  21519. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21520. * * 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)
  21521. * * 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)
  21522. * @returns the VertexData of the box
  21523. */
  21524. static CreateDisc(options: {
  21525. radius?: number;
  21526. tessellation?: number;
  21527. arc?: number;
  21528. sideOrientation?: number;
  21529. frontUVs?: Vector4;
  21530. backUVs?: Vector4;
  21531. }): VertexData;
  21532. /**
  21533. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  21534. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  21535. * @param polygon a mesh built from polygonTriangulation.build()
  21536. * @param sideOrientation takes the values BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21537. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  21538. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  21539. * @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)
  21540. * @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)
  21541. * @returns the VertexData of the Polygon
  21542. */
  21543. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  21544. /**
  21545. * Creates the VertexData of the IcoSphere
  21546. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  21547. * * radius the radius of the IcoSphere, optional default 1
  21548. * * radiusX allows stretching in the x direction, optional, default radius
  21549. * * radiusY allows stretching in the y direction, optional, default radius
  21550. * * radiusZ allows stretching in the z direction, optional, default radius
  21551. * * flat when true creates a flat shaded mesh, optional, default true
  21552. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  21553. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21554. * * 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)
  21555. * * 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)
  21556. * @returns the VertexData of the IcoSphere
  21557. */
  21558. static CreateIcoSphere(options: {
  21559. radius?: number;
  21560. radiusX?: number;
  21561. radiusY?: number;
  21562. radiusZ?: number;
  21563. flat?: boolean;
  21564. subdivisions?: number;
  21565. sideOrientation?: number;
  21566. frontUVs?: Vector4;
  21567. backUVs?: Vector4;
  21568. }): VertexData;
  21569. /**
  21570. * Creates the VertexData for a Polyhedron
  21571. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  21572. * * type provided types are:
  21573. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  21574. * * 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)
  21575. * * size the size of the IcoSphere, optional default 1
  21576. * * sizeX allows stretching in the x direction, optional, default size
  21577. * * sizeY allows stretching in the y direction, optional, default size
  21578. * * sizeZ allows stretching in the z direction, optional, default size
  21579. * * 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
  21580. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  21581. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  21582. * * flat when true creates a flat shaded mesh, optional, default true
  21583. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  21584. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21585. * * 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)
  21586. * * 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)
  21587. * @returns the VertexData of the Polyhedron
  21588. */
  21589. static CreatePolyhedron(options: {
  21590. type?: number;
  21591. size?: number;
  21592. sizeX?: number;
  21593. sizeY?: number;
  21594. sizeZ?: number;
  21595. custom?: any;
  21596. faceUV?: Vector4[];
  21597. faceColors?: Color4[];
  21598. flat?: boolean;
  21599. sideOrientation?: number;
  21600. frontUVs?: Vector4;
  21601. backUVs?: Vector4;
  21602. }): VertexData;
  21603. /**
  21604. * Creates the VertexData for a TorusKnot
  21605. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  21606. * * radius the radius of the torus knot, optional, default 2
  21607. * * tube the thickness of the tube, optional, default 0.5
  21608. * * radialSegments the number of sides on each tube segments, optional, default 32
  21609. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  21610. * * p the number of windings around the z axis, optional, default 2
  21611. * * q the number of windings around the x axis, optional, default 3
  21612. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21613. * * 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)
  21614. * * 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)
  21615. * @returns the VertexData of the Torus Knot
  21616. */
  21617. static CreateTorusKnot(options: {
  21618. radius?: number;
  21619. tube?: number;
  21620. radialSegments?: number;
  21621. tubularSegments?: number;
  21622. p?: number;
  21623. q?: number;
  21624. sideOrientation?: number;
  21625. frontUVs?: Vector4;
  21626. backUVs?: Vector4;
  21627. }): VertexData;
  21628. /**
  21629. * Compute normals for given positions and indices
  21630. * @param positions an array of vertex positions, [...., x, y, z, ......]
  21631. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  21632. * @param normals an array of vertex normals, [...., x, y, z, ......]
  21633. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  21634. * * facetNormals : optional array of facet normals (vector3)
  21635. * * facetPositions : optional array of facet positions (vector3)
  21636. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  21637. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  21638. * * bInfo : optional bounding info, required for facetPartitioning computation
  21639. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  21640. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  21641. * * useRightHandedSystem: optional boolean to for right handed system computation
  21642. * * depthSort : optional boolean to enable the facet depth sort computation
  21643. * * distanceTo : optional Vector3 to compute the facet depth from this location
  21644. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  21645. */
  21646. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  21647. facetNormals?: any;
  21648. facetPositions?: any;
  21649. facetPartitioning?: any;
  21650. ratio?: number;
  21651. bInfo?: any;
  21652. bbSize?: Vector3;
  21653. subDiv?: any;
  21654. useRightHandedSystem?: boolean;
  21655. depthSort?: boolean;
  21656. distanceTo?: Vector3;
  21657. depthSortedFacets?: any;
  21658. }): void;
  21659. private static _ComputeSides(sideOrientation, positions, indices, normals, uvs, frontUVs?, backUVs?);
  21660. /**
  21661. * Applies VertexData created from the imported parameters to the geometry
  21662. * @param parsedVertexData the parsed data from an imported file
  21663. * @param geometry the geometry to apply the VertexData to
  21664. */
  21665. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  21666. }
  21667. }
  21668. declare module BABYLON {
  21669. /**
  21670. * Class containing static functions to help procedurally build meshes
  21671. */
  21672. class MeshBuilder {
  21673. private static updateSideOrientation(orientation?);
  21674. /**
  21675. * Creates a box mesh
  21676. * * The parameter `size` sets the size (float) of each box side (default 1)
  21677. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value than `size`)
  21678. * * 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)
  21679. * * Please read this tutorial : http://doc.babylonjs.com/tutorials/CreateBox_Per_Face_Textures_And_Colors
  21680. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21681. * * 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
  21682. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  21683. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#box
  21684. * @param name defines the name of the mesh
  21685. * @param options defines the options used to create the mesh
  21686. * @param scene defines the hosting scene
  21687. * @returns the box mesh
  21688. */
  21689. static CreateBox(name: string, options: {
  21690. size?: number;
  21691. width?: number;
  21692. height?: number;
  21693. depth?: number;
  21694. faceUV?: Vector4[];
  21695. faceColors?: Color4[];
  21696. sideOrientation?: number;
  21697. frontUVs?: Vector4;
  21698. backUVs?: Vector4;
  21699. updatable?: boolean;
  21700. }, scene?: Nullable<Scene>): Mesh;
  21701. /**
  21702. * Creates a sphere mesh
  21703. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  21704. * * 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`)
  21705. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  21706. * * 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
  21707. * * 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)
  21708. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21709. * * 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
  21710. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  21711. * @param name defines the name of the mesh
  21712. * @param options defines the options used to create the mesh
  21713. * @param scene defines the hosting scene
  21714. * @returns the sphere mesh
  21715. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#sphere
  21716. */
  21717. static CreateSphere(name: string, options: {
  21718. segments?: number;
  21719. diameter?: number;
  21720. diameterX?: number;
  21721. diameterY?: number;
  21722. diameterZ?: number;
  21723. arc?: number;
  21724. slice?: number;
  21725. sideOrientation?: number;
  21726. frontUVs?: Vector4;
  21727. backUVs?: Vector4;
  21728. updatable?: boolean;
  21729. }, scene: any): Mesh;
  21730. /**
  21731. * Creates a plane polygonal mesh. By default, this is a disc
  21732. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  21733. * * 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
  21734. * * 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
  21735. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21736. * * 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
  21737. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  21738. * @param name defines the name of the mesh
  21739. * @param options defines the options used to create the mesh
  21740. * @param scene defines the hosting scene
  21741. * @returns the plane polygonal mesh
  21742. * @see http://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  21743. */
  21744. static CreateDisc(name: string, options: {
  21745. radius?: number;
  21746. tessellation?: number;
  21747. arc?: number;
  21748. updatable?: boolean;
  21749. sideOrientation?: number;
  21750. frontUVs?: Vector4;
  21751. backUVs?: Vector4;
  21752. }, scene?: Nullable<Scene>): Mesh;
  21753. /**
  21754. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  21755. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  21756. * * 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`)
  21757. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  21758. * * 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
  21759. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21760. * * 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
  21761. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  21762. * @param name defines the name of the mesh
  21763. * @param options defines the options used to create the mesh
  21764. * @param scene defines the hosting scene
  21765. * @returns the icosahedron mesh
  21766. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  21767. */
  21768. static CreateIcoSphere(name: string, options: {
  21769. radius?: number;
  21770. radiusX?: number;
  21771. radiusY?: number;
  21772. radiusZ?: number;
  21773. flat?: boolean;
  21774. subdivisions?: number;
  21775. sideOrientation?: number;
  21776. frontUVs?: Vector4;
  21777. backUVs?: Vector4;
  21778. updatable?: boolean;
  21779. }, scene: Scene): Mesh;
  21780. /**
  21781. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  21782. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  21783. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  21784. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  21785. * * 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
  21786. * * 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
  21787. * * 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
  21788. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21789. * * 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
  21790. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  21791. * * 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
  21792. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  21793. * * 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
  21794. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  21795. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  21796. * @param name defines the name of the mesh
  21797. * @param options defines the options used to create the mesh
  21798. * @param scene defines the hosting scene
  21799. * @returns the ribbon mesh
  21800. * @see http://doc.babylonjs.com/tutorials/Ribbon_Tutorial
  21801. * @see http://doc.babylonjs.com/tutorials/Parametric_Shapes
  21802. */
  21803. static CreateRibbon(name: string, options: {
  21804. pathArray: Vector3[][];
  21805. closeArray?: boolean;
  21806. closePath?: boolean;
  21807. offset?: number;
  21808. updatable?: boolean;
  21809. sideOrientation?: number;
  21810. frontUVs?: Vector4;
  21811. backUVs?: Vector4;
  21812. instance?: Mesh;
  21813. invertUV?: boolean;
  21814. uvs?: Vector2[];
  21815. colors?: Color4[];
  21816. }, scene?: Nullable<Scene>): Mesh;
  21817. /**
  21818. * Creates a cylinder or a cone mesh
  21819. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  21820. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  21821. * * 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.
  21822. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  21823. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  21824. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  21825. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  21826. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  21827. * * 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).
  21828. * * 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
  21829. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  21830. * * 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
  21831. * * 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.
  21832. * * If `enclose` is false, a ring surface is one element.
  21833. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  21834. * * 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
  21835. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21836. * * 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
  21837. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21838. * @param name defines the name of the mesh
  21839. * @param options defines the options used to create the mesh
  21840. * @param scene defines the hosting scene
  21841. * @returns the cylinder mesh
  21842. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#cylinder-or-cone
  21843. */
  21844. static CreateCylinder(name: string, options: {
  21845. height?: number;
  21846. diameterTop?: number;
  21847. diameterBottom?: number;
  21848. diameter?: number;
  21849. tessellation?: number;
  21850. subdivisions?: number;
  21851. arc?: number;
  21852. faceColors?: Color4[];
  21853. faceUV?: Vector4[];
  21854. updatable?: boolean;
  21855. hasRings?: boolean;
  21856. enclose?: boolean;
  21857. sideOrientation?: number;
  21858. frontUVs?: Vector4;
  21859. backUVs?: Vector4;
  21860. }, scene: any): Mesh;
  21861. /**
  21862. * Creates a torus mesh
  21863. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  21864. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  21865. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  21866. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21867. * * 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
  21868. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21869. * @param name defines the name of the mesh
  21870. * @param options defines the options used to create the mesh
  21871. * @param scene defines the hosting scene
  21872. * @returns the torus mesh
  21873. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#torus
  21874. */
  21875. static CreateTorus(name: string, options: {
  21876. diameter?: number;
  21877. thickness?: number;
  21878. tessellation?: number;
  21879. updatable?: boolean;
  21880. sideOrientation?: number;
  21881. frontUVs?: Vector4;
  21882. backUVs?: Vector4;
  21883. }, scene: any): Mesh;
  21884. /**
  21885. * Creates a torus knot mesh
  21886. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  21887. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  21888. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  21889. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  21890. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21891. * * 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
  21892. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21893. * @param name defines the name of the mesh
  21894. * @param options defines the options used to create the mesh
  21895. * @param scene defines the hosting scene
  21896. * @returns the torus knot mesh
  21897. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#torus-knot
  21898. */
  21899. static CreateTorusKnot(name: string, options: {
  21900. radius?: number;
  21901. tube?: number;
  21902. radialSegments?: number;
  21903. tubularSegments?: number;
  21904. p?: number;
  21905. q?: number;
  21906. updatable?: boolean;
  21907. sideOrientation?: number;
  21908. frontUVs?: Vector4;
  21909. backUVs?: Vector4;
  21910. }, scene: any): Mesh;
  21911. /**
  21912. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  21913. * * 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
  21914. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  21915. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  21916. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  21917. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  21918. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  21919. * * 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
  21920. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  21921. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  21922. * @see http://doc.babylonjs.com/how_to/parametric_shapes#line-system
  21923. * @param name defines the name of the new line system
  21924. * @param options defines the options used to create the line system
  21925. * @param scene defines the hosting scene
  21926. * @returns a new line system mesh
  21927. */
  21928. static CreateLineSystem(name: string, options: {
  21929. lines: Vector3[][];
  21930. updatable?: boolean;
  21931. instance?: Nullable<LinesMesh>;
  21932. colors?: Nullable<Color4[][]>;
  21933. useVertexAlpha?: boolean;
  21934. }, scene: Nullable<Scene>): LinesMesh;
  21935. /**
  21936. * Creates a line mesh
  21937. * 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
  21938. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  21939. * * The parameter `points` is an array successive Vector3
  21940. * * 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
  21941. * * The optional parameter `colors` is an array of successive Color4, one per line point
  21942. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  21943. * * When updating an instance, remember that only point positions can change, not the number of points
  21944. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  21945. * @see http://doc.babylonjs.com/how_to/parametric_shapes#lines
  21946. * @param name defines the name of the new line system
  21947. * @param options defines the options used to create the line system
  21948. * @param scene defines the hosting scene
  21949. * @returns a new line mesh
  21950. */
  21951. static CreateLines(name: string, options: {
  21952. points: Vector3[];
  21953. updatable?: boolean;
  21954. instance?: Nullable<LinesMesh>;
  21955. colors?: Color4[];
  21956. useVertexAlpha?: boolean;
  21957. }, scene?: Nullable<Scene>): LinesMesh;
  21958. /**
  21959. * Creates a dashed line mesh
  21960. * * 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
  21961. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  21962. * * The parameter `points` is an array successive Vector3
  21963. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  21964. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  21965. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  21966. * * 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
  21967. * * When updating an instance, remember that only point positions can change, not the number of points
  21968. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  21969. * @param name defines the name of the mesh
  21970. * @param options defines the options used to create the mesh
  21971. * @param scene defines the hosting scene
  21972. * @returns the dashed line mesh
  21973. * @see http://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  21974. */
  21975. static CreateDashedLines(name: string, options: {
  21976. points: Vector3[];
  21977. dashSize?: number;
  21978. gapSize?: number;
  21979. dashNb?: number;
  21980. updatable?: boolean;
  21981. instance?: LinesMesh;
  21982. }, scene?: Nullable<Scene>): LinesMesh;
  21983. /**
  21984. * 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.
  21985. * * 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.
  21986. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  21987. * * 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.
  21988. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  21989. * * 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
  21990. * * 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
  21991. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  21992. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21993. * * 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
  21994. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  21995. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21996. * @param name defines the name of the mesh
  21997. * @param options defines the options used to create the mesh
  21998. * @param scene defines the hosting scene
  21999. * @returns the extruded shape mesh
  22000. * @see http://doc.babylonjs.com/tutorials/Parametric_Shapes
  22001. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  22002. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  22003. */
  22004. static ExtrudeShape(name: string, options: {
  22005. shape: Vector3[];
  22006. path: Vector3[];
  22007. scale?: number;
  22008. rotation?: number;
  22009. cap?: number;
  22010. updatable?: boolean;
  22011. sideOrientation?: number;
  22012. frontUVs?: Vector4;
  22013. backUVs?: Vector4;
  22014. instance?: Mesh;
  22015. invertUV?: boolean;
  22016. }, scene?: Nullable<Scene>): Mesh;
  22017. /**
  22018. * Creates an custom extruded shape mesh.
  22019. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  22020. * * 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.
  22021. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  22022. * * 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
  22023. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  22024. * * 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
  22025. * * It must returns a float value that will be the scale value applied to the shape on each path point
  22026. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  22027. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  22028. * * 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
  22029. * * 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
  22030. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  22031. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22032. * * 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
  22033. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  22034. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22035. * @param name defines the name of the mesh
  22036. * @param options defines the options used to create the mesh
  22037. * @param scene defines the hosting scene
  22038. * @returns the custom extruded shape mesh
  22039. * @see http://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  22040. * @see http://doc.babylonjs.com/tutorials/Parametric_Shapes
  22041. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  22042. */
  22043. static ExtrudeShapeCustom(name: string, options: {
  22044. shape: Vector3[];
  22045. path: Vector3[];
  22046. scaleFunction?: any;
  22047. rotationFunction?: any;
  22048. ribbonCloseArray?: boolean;
  22049. ribbonClosePath?: boolean;
  22050. cap?: number;
  22051. updatable?: boolean;
  22052. sideOrientation?: number;
  22053. frontUVs?: Vector4;
  22054. backUVs?: Vector4;
  22055. instance?: Mesh;
  22056. invertUV?: boolean;
  22057. }, scene: Scene): Mesh;
  22058. /**
  22059. * Creates lathe mesh.
  22060. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  22061. * * 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
  22062. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  22063. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  22064. * * 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
  22065. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  22066. * * 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
  22067. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22068. * * 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
  22069. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  22070. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22071. * @param name defines the name of the mesh
  22072. * @param options defines the options used to create the mesh
  22073. * @param scene defines the hosting scene
  22074. * @returns the lathe mesh
  22075. * @see http://doc.babylonjs.com/how_to/parametric_shapes#lathe
  22076. */
  22077. static CreateLathe(name: string, options: {
  22078. shape: Vector3[];
  22079. radius?: number;
  22080. tessellation?: number;
  22081. arc?: number;
  22082. closed?: boolean;
  22083. updatable?: boolean;
  22084. sideOrientation?: number;
  22085. frontUVs?: Vector4;
  22086. backUVs?: Vector4;
  22087. cap?: number;
  22088. invertUV?: boolean;
  22089. }, scene: Scene): Mesh;
  22090. /**
  22091. * Creates a plane mesh
  22092. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  22093. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value than `size`)
  22094. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  22095. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22096. * * 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
  22097. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22098. * @param name defines the name of the mesh
  22099. * @param options defines the options used to create the mesh
  22100. * @param scene defines the hosting scene
  22101. * @returns the plane mesh
  22102. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#plane
  22103. */
  22104. static CreatePlane(name: string, options: {
  22105. size?: number;
  22106. width?: number;
  22107. height?: number;
  22108. sideOrientation?: number;
  22109. frontUVs?: Vector4;
  22110. backUVs?: Vector4;
  22111. updatable?: boolean;
  22112. sourcePlane?: Plane;
  22113. }, scene: Scene): Mesh;
  22114. /**
  22115. * Creates a ground mesh
  22116. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  22117. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  22118. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22119. * @param name defines the name of the mesh
  22120. * @param options defines the options used to create the mesh
  22121. * @param scene defines the hosting scene
  22122. * @returns the ground mesh
  22123. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#plane
  22124. */
  22125. static CreateGround(name: string, options: {
  22126. width?: number;
  22127. height?: number;
  22128. subdivisions?: number;
  22129. subdivisionsX?: number;
  22130. subdivisionsY?: number;
  22131. updatable?: boolean;
  22132. }, scene: any): Mesh;
  22133. /**
  22134. * Creates a tiled ground mesh
  22135. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  22136. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  22137. * * 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
  22138. * * 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
  22139. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22140. * @param name defines the name of the mesh
  22141. * @param options defines the options used to create the mesh
  22142. * @param scene defines the hosting scene
  22143. * @returns the tiled ground mesh
  22144. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#tiled-ground
  22145. */
  22146. static CreateTiledGround(name: string, options: {
  22147. xmin: number;
  22148. zmin: number;
  22149. xmax: number;
  22150. zmax: number;
  22151. subdivisions?: {
  22152. w: number;
  22153. h: number;
  22154. };
  22155. precision?: {
  22156. w: number;
  22157. h: number;
  22158. };
  22159. updatable?: boolean;
  22160. }, scene: Scene): Mesh;
  22161. /**
  22162. * Creates a ground mesh from a height map
  22163. * * The parameter `url` sets the URL of the height map image resource.
  22164. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  22165. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  22166. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  22167. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  22168. * * 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.
  22169. * * 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).
  22170. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22171. * @param name defines the name of the mesh
  22172. * @param url defines the url to the height map
  22173. * @param options defines the options used to create the mesh
  22174. * @param scene defines the hosting scene
  22175. * @returns the ground mesh
  22176. * @see http://doc.babylonjs.com/babylon101/height_map
  22177. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#ground-from-a-height-map
  22178. */
  22179. static CreateGroundFromHeightMap(name: string, url: string, options: {
  22180. width?: number;
  22181. height?: number;
  22182. subdivisions?: number;
  22183. minHeight?: number;
  22184. maxHeight?: number;
  22185. colorFilter?: Color3;
  22186. updatable?: boolean;
  22187. onReady?: (mesh: GroundMesh) => void;
  22188. }, scene: Scene): GroundMesh;
  22189. /**
  22190. * Creates a polygon mesh
  22191. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  22192. * * 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
  22193. * * You can set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22194. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22195. * * 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)
  22196. * * Remember you can only change the shape positions, not their number when updating a polygon
  22197. * @param name defines the name of the mesh
  22198. * @param options defines the options used to create the mesh
  22199. * @param scene defines the hosting scene
  22200. * @returns the polygon mesh
  22201. */
  22202. static CreatePolygon(name: string, options: {
  22203. shape: Vector3[];
  22204. holes?: Vector3[][];
  22205. depth?: number;
  22206. faceUV?: Vector4[];
  22207. faceColors?: Color4[];
  22208. updatable?: boolean;
  22209. sideOrientation?: number;
  22210. frontUVs?: Vector4;
  22211. backUVs?: Vector4;
  22212. }, scene: Scene): Mesh;
  22213. /**
  22214. * Creates an extruded polygon mesh, with depth in the Y direction.
  22215. * * 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)
  22216. * @see http://doc.babylonjs.com/tutorials/CreateBox_Per_Face_Textures_And_Colors
  22217. * @param name defines the name of the mesh
  22218. * @param options defines the options used to create the mesh
  22219. * @param scene defines the hosting scene
  22220. * @returns the polygon mesh
  22221. */
  22222. static ExtrudePolygon(name: string, options: {
  22223. shape: Vector3[];
  22224. holes?: Vector3[][];
  22225. depth?: number;
  22226. faceUV?: Vector4[];
  22227. faceColors?: Color4[];
  22228. updatable?: boolean;
  22229. sideOrientation?: number;
  22230. frontUVs?: Vector4;
  22231. backUVs?: Vector4;
  22232. }, scene: Scene): Mesh;
  22233. /**
  22234. * Creates a tube mesh.
  22235. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  22236. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  22237. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  22238. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  22239. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  22240. * * 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)
  22241. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  22242. * * 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
  22243. * * 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
  22244. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22245. * * 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
  22246. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  22247. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22248. * @param name defines the name of the mesh
  22249. * @param options defines the options used to create the mesh
  22250. * @param scene defines the hosting scene
  22251. * @returns the tube mesh
  22252. * @see http://doc.babylonjs.com/tutorials/Parametric_Shapes
  22253. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#tube
  22254. */
  22255. static CreateTube(name: string, options: {
  22256. path: Vector3[];
  22257. radius?: number;
  22258. tessellation?: number;
  22259. radiusFunction?: {
  22260. (i: number, distance: number): number;
  22261. };
  22262. cap?: number;
  22263. arc?: number;
  22264. updatable?: boolean;
  22265. sideOrientation?: number;
  22266. frontUVs?: Vector4;
  22267. backUVs?: Vector4;
  22268. instance?: Mesh;
  22269. invertUV?: boolean;
  22270. }, scene: Scene): Mesh;
  22271. /**
  22272. * Creates a polyhedron mesh
  22273. * * 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
  22274. * * The parameter `size` (positive float, default 1) sets the polygon size
  22275. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  22276. * * 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`
  22277. * * 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
  22278. * * 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)`)
  22279. * * 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
  22280. * * 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
  22281. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22282. * * 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
  22283. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22284. * @param name defines the name of the mesh
  22285. * @param options defines the options used to create the mesh
  22286. * @param scene defines the hosting scene
  22287. * @returns the polyhedron mesh
  22288. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes
  22289. */
  22290. static CreatePolyhedron(name: string, options: {
  22291. type?: number;
  22292. size?: number;
  22293. sizeX?: number;
  22294. sizeY?: number;
  22295. sizeZ?: number;
  22296. custom?: any;
  22297. faceUV?: Vector4[];
  22298. faceColors?: Color4[];
  22299. flat?: boolean;
  22300. updatable?: boolean;
  22301. sideOrientation?: number;
  22302. frontUVs?: Vector4;
  22303. backUVs?: Vector4;
  22304. }, scene: Scene): Mesh;
  22305. /**
  22306. * Creates a decal mesh.
  22307. * 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
  22308. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  22309. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  22310. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  22311. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  22312. * @param name defines the name of the mesh
  22313. * @param sourceMesh defines the mesh where the decal must be applied
  22314. * @param options defines the options used to create the mesh
  22315. * @param scene defines the hosting scene
  22316. * @returns the decal mesh
  22317. * @see http://doc.babylonjs.com/how_to/decals
  22318. */
  22319. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  22320. position?: Vector3;
  22321. normal?: Vector3;
  22322. size?: Vector3;
  22323. angle?: number;
  22324. }): Mesh;
  22325. private static _ExtrudeShapeGeneric(name, shape, curve, scale, rotation, scaleFunction, rotateFunction, rbCA, rbCP, cap, custom, scene, updtbl, side, instance, invertUV, frontUVs, backUVs);
  22326. }
  22327. }
  22328. declare module BABYLON {
  22329. class MeshLODLevel {
  22330. distance: number;
  22331. mesh: Mesh;
  22332. constructor(distance: number, mesh: Mesh);
  22333. }
  22334. }
  22335. declare module BABYLON {
  22336. /**
  22337. * A simplifier interface for future simplification implementations.
  22338. */
  22339. interface ISimplifier {
  22340. /**
  22341. * Simplification of a given mesh according to the given settings.
  22342. * Since this requires computation, it is assumed that the function runs async.
  22343. * @param settings The settings of the simplification, including quality and distance
  22344. * @param successCallback A callback that will be called after the mesh was simplified.
  22345. * @param errorCallback in case of an error, this callback will be called. optional.
  22346. */
  22347. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  22348. }
  22349. /**
  22350. * Expected simplification settings.
  22351. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%);
  22352. */
  22353. interface ISimplificationSettings {
  22354. quality: number;
  22355. distance: number;
  22356. optimizeMesh?: boolean;
  22357. }
  22358. class SimplificationSettings implements ISimplificationSettings {
  22359. quality: number;
  22360. distance: number;
  22361. optimizeMesh: boolean | undefined;
  22362. constructor(quality: number, distance: number, optimizeMesh?: boolean | undefined);
  22363. }
  22364. interface ISimplificationTask {
  22365. settings: Array<ISimplificationSettings>;
  22366. simplificationType: SimplificationType;
  22367. mesh: Mesh;
  22368. successCallback?: () => void;
  22369. parallelProcessing: boolean;
  22370. }
  22371. class SimplificationQueue {
  22372. private _simplificationArray;
  22373. running: boolean;
  22374. constructor();
  22375. addTask(task: ISimplificationTask): void;
  22376. executeNext(): void;
  22377. runSimplification(task: ISimplificationTask): void;
  22378. private getSimplifier(task);
  22379. }
  22380. /**
  22381. * The implemented types of simplification
  22382. * At the moment only Quadratic Error Decimation is implemented
  22383. */
  22384. enum SimplificationType {
  22385. /** Quadratic error decimation */
  22386. QUADRATIC = 0,
  22387. }
  22388. class DecimationTriangle {
  22389. vertices: Array<DecimationVertex>;
  22390. normal: Vector3;
  22391. error: Array<number>;
  22392. deleted: boolean;
  22393. isDirty: boolean;
  22394. borderFactor: number;
  22395. deletePending: boolean;
  22396. originalOffset: number;
  22397. constructor(vertices: Array<DecimationVertex>);
  22398. }
  22399. class DecimationVertex {
  22400. position: Vector3;
  22401. id: number;
  22402. q: QuadraticMatrix;
  22403. isBorder: boolean;
  22404. triangleStart: number;
  22405. triangleCount: number;
  22406. originalOffsets: Array<number>;
  22407. constructor(position: Vector3, id: number);
  22408. updatePosition(newPosition: Vector3): void;
  22409. }
  22410. class QuadraticMatrix {
  22411. data: Array<number>;
  22412. constructor(data?: Array<number>);
  22413. det(a11: number, a12: number, a13: number, a21: number, a22: number, a23: number, a31: number, a32: number, a33: number): number;
  22414. addInPlace(matrix: QuadraticMatrix): void;
  22415. addArrayInPlace(data: Array<number>): void;
  22416. add(matrix: QuadraticMatrix): QuadraticMatrix;
  22417. static FromData(a: number, b: number, c: number, d: number): QuadraticMatrix;
  22418. static DataFromNumbers(a: number, b: number, c: number, d: number): number[];
  22419. }
  22420. class Reference {
  22421. vertexId: number;
  22422. triangleId: number;
  22423. constructor(vertexId: number, triangleId: number);
  22424. }
  22425. /**
  22426. * An implementation of the Quadratic Error simplification algorithm.
  22427. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  22428. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  22429. * @author RaananW
  22430. */
  22431. class QuadraticErrorSimplification implements ISimplifier {
  22432. private _mesh;
  22433. private triangles;
  22434. private vertices;
  22435. private references;
  22436. private _reconstructedMesh;
  22437. syncIterations: number;
  22438. aggressiveness: number;
  22439. decimationIterations: number;
  22440. boundingBoxEpsilon: number;
  22441. constructor(_mesh: Mesh);
  22442. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  22443. private runDecimation(settings, submeshIndex, successCallback);
  22444. private initWithMesh(submeshIndex, callback, optimizeMesh?);
  22445. private init(callback);
  22446. private reconstructMesh(submeshIndex);
  22447. private initDecimatedMesh();
  22448. private isFlipped(vertex1, vertex2, point, deletedArray, borderFactor, delTr);
  22449. private updateTriangles(origVertex, vertex, deletedArray, deletedTriangles);
  22450. private identifyBorder();
  22451. private updateMesh(identifyBorders?);
  22452. private vertexError(q, point);
  22453. private calculateError(vertex1, vertex2, pointResult?, normalResult?, uvResult?, colorResult?);
  22454. }
  22455. }
  22456. declare module BABYLON {
  22457. class Polygon {
  22458. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  22459. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  22460. static Parse(input: string): Vector2[];
  22461. static StartingAt(x: number, y: number): Path2;
  22462. }
  22463. class PolygonMeshBuilder {
  22464. private _points;
  22465. private _outlinepoints;
  22466. private _holes;
  22467. private _name;
  22468. private _scene;
  22469. private _epoints;
  22470. private _eholes;
  22471. private _addToepoint(points);
  22472. constructor(name: string, contours: Path2, scene: Scene);
  22473. constructor(name: string, contours: Vector2[], scene: Scene);
  22474. addHole(hole: Vector2[]): PolygonMeshBuilder;
  22475. build(updatable?: boolean, depth?: number): Mesh;
  22476. private addSide(positions, normals, uvs, indices, bounds, points, depth, flip);
  22477. }
  22478. }
  22479. declare module BABYLON {
  22480. class BaseSubMesh {
  22481. _materialDefines: Nullable<MaterialDefines>;
  22482. _materialEffect: Nullable<Effect>;
  22483. readonly effect: Nullable<Effect>;
  22484. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  22485. }
  22486. class SubMesh extends BaseSubMesh implements ICullable {
  22487. materialIndex: number;
  22488. verticesStart: number;
  22489. verticesCount: number;
  22490. indexStart: number;
  22491. indexCount: number;
  22492. linesIndexCount: number;
  22493. private _mesh;
  22494. private _renderingMesh;
  22495. private _boundingInfo;
  22496. private _linesIndexBuffer;
  22497. _lastColliderWorldVertices: Nullable<Vector3[]>;
  22498. _trianglePlanes: Plane[];
  22499. _lastColliderTransformMatrix: Matrix;
  22500. _renderId: number;
  22501. _alphaIndex: number;
  22502. _distanceToCamera: number;
  22503. _id: number;
  22504. private _currentMaterial;
  22505. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  22506. constructor(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  22507. readonly IsGlobal: boolean;
  22508. /**
  22509. * Returns the submesh BoudingInfo object.
  22510. */
  22511. getBoundingInfo(): BoundingInfo;
  22512. /**
  22513. * Sets the submesh BoundingInfo.
  22514. * Return the SubMesh.
  22515. */
  22516. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  22517. /**
  22518. * Returns the mesh of the current submesh.
  22519. */
  22520. getMesh(): AbstractMesh;
  22521. /**
  22522. * Returns the rendering mesh of the submesh.
  22523. */
  22524. getRenderingMesh(): Mesh;
  22525. /**
  22526. * Returns the submesh material.
  22527. */
  22528. getMaterial(): Nullable<Material>;
  22529. /**
  22530. * Sets a new updated BoundingInfo object to the submesh.
  22531. * Returns the SubMesh.
  22532. */
  22533. refreshBoundingInfo(): SubMesh;
  22534. _checkCollision(collider: Collider): boolean;
  22535. /**
  22536. * Updates the submesh BoundingInfo.
  22537. * Returns the Submesh.
  22538. */
  22539. updateBoundingInfo(world: Matrix): SubMesh;
  22540. /**
  22541. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  22542. * Boolean returned.
  22543. */
  22544. isInFrustum(frustumPlanes: Plane[]): boolean;
  22545. /**
  22546. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes.
  22547. * Boolean returned.
  22548. */
  22549. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  22550. /**
  22551. * Renders the submesh.
  22552. * Returns it.
  22553. */
  22554. render(enableAlphaMode: boolean): SubMesh;
  22555. /**
  22556. * Returns a new Index Buffer.
  22557. * Type returned : WebGLBuffer.
  22558. */
  22559. getLinesIndexBuffer(indices: IndicesArray, engine: Engine): WebGLBuffer;
  22560. /**
  22561. * True is the passed Ray intersects the submesh bounding box.
  22562. * Boolean returned.
  22563. */
  22564. canIntersects(ray: Ray): boolean;
  22565. /**
  22566. * Returns an object IntersectionInfo.
  22567. */
  22568. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean): Nullable<IntersectionInfo>;
  22569. _rebuild(): void;
  22570. /**
  22571. * Creates a new Submesh from the passed Mesh.
  22572. */
  22573. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  22574. /**
  22575. * Disposes the Submesh.
  22576. * Returns nothing.
  22577. */
  22578. dispose(): void;
  22579. /**
  22580. * Creates a new Submesh from the passed parameters :
  22581. * - materialIndex (integer) : the index of the main mesh material.
  22582. * - startIndex (integer) : the index where to start the copy in the mesh indices array.
  22583. * - indexCount (integer) : the number of indices to copy then from the startIndex.
  22584. * - mesh (Mesh) : the main mesh to create the submesh from.
  22585. * - renderingMesh (optional Mesh) : rendering mesh.
  22586. */
  22587. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  22588. }
  22589. }
  22590. declare module BABYLON {
  22591. class TransformNode extends Node {
  22592. static BILLBOARDMODE_NONE: number;
  22593. static BILLBOARDMODE_X: number;
  22594. static BILLBOARDMODE_Y: number;
  22595. static BILLBOARDMODE_Z: number;
  22596. static BILLBOARDMODE_ALL: number;
  22597. private _forward;
  22598. private _forwardInverted;
  22599. private _up;
  22600. private _right;
  22601. private _rightInverted;
  22602. private _rotation;
  22603. private _rotationQuaternion;
  22604. protected _scaling: Vector3;
  22605. protected _isDirty: boolean;
  22606. private _transformToBoneReferal;
  22607. billboardMode: number;
  22608. scalingDeterminant: number;
  22609. infiniteDistance: boolean;
  22610. position: Vector3;
  22611. _poseMatrix: Matrix;
  22612. private _localWorld;
  22613. _worldMatrix: Matrix;
  22614. _worldMatrixDeterminant: number;
  22615. private _absolutePosition;
  22616. private _pivotMatrix;
  22617. private _pivotMatrixInverse;
  22618. private _postMultiplyPivotMatrix;
  22619. protected _isWorldMatrixFrozen: boolean;
  22620. /**
  22621. * An event triggered after the world matrix is updated
  22622. */
  22623. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  22624. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  22625. /**
  22626. * Gets a string idenfifying the name of the class
  22627. * @returns "TransformNode" string
  22628. */
  22629. getClassName(): string;
  22630. /**
  22631. * Rotation property : a Vector3 depicting the rotation value in radians around each local axis X, Y, Z.
  22632. * If rotation quaternion is set, this Vector3 will (almost always) be the Zero vector!
  22633. * Default : (0.0, 0.0, 0.0)
  22634. */
  22635. rotation: Vector3;
  22636. /**
  22637. * Scaling property : a Vector3 depicting the mesh scaling along each local axis X, Y, Z.
  22638. * Default : (1.0, 1.0, 1.0)
  22639. */
  22640. /**
  22641. * Scaling property : a Vector3 depicting the mesh scaling along each local axis X, Y, Z.
  22642. * Default : (1.0, 1.0, 1.0)
  22643. */
  22644. scaling: Vector3;
  22645. /**
  22646. * Rotation Quaternion property : this a Quaternion object depicting the mesh rotation by using a unit quaternion.
  22647. * It's null by default.
  22648. * 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)
  22649. */
  22650. rotationQuaternion: Nullable<Quaternion>;
  22651. /**
  22652. * The forward direction of that transform in world space.
  22653. */
  22654. readonly forward: Vector3;
  22655. /**
  22656. * The up direction of that transform in world space.
  22657. */
  22658. readonly up: Vector3;
  22659. /**
  22660. * The right direction of that transform in world space.
  22661. */
  22662. readonly right: Vector3;
  22663. /**
  22664. * Returns the latest update of the World matrix
  22665. * Returns a Matrix.
  22666. */
  22667. getWorldMatrix(): Matrix;
  22668. /** @hidden */
  22669. _getWorldMatrixDeterminant(): number;
  22670. /**
  22671. * Returns directly the latest state of the mesh World matrix.
  22672. * A Matrix is returned.
  22673. */
  22674. readonly worldMatrixFromCache: Matrix;
  22675. /**
  22676. * Copies the paramater passed Matrix into the mesh Pose matrix.
  22677. * Returns the TransformNode.
  22678. */
  22679. updatePoseMatrix(matrix: Matrix): TransformNode;
  22680. /**
  22681. * Returns the mesh Pose matrix.
  22682. * Returned object : Matrix
  22683. */
  22684. getPoseMatrix(): Matrix;
  22685. _isSynchronized(): boolean;
  22686. _initCache(): void;
  22687. markAsDirty(property: string): TransformNode;
  22688. /**
  22689. * Returns the current mesh absolute position.
  22690. * Retuns a Vector3.
  22691. */
  22692. readonly absolutePosition: Vector3;
  22693. /**
  22694. * Sets a new matrix to apply before all other transformation
  22695. * @param matrix defines the transform matrix
  22696. * @returns the current TransformNode
  22697. */
  22698. setPreTransformMatrix(matrix: Matrix): TransformNode;
  22699. /**
  22700. * Sets a new pivot matrix to the current node
  22701. * @param matrix defines the new pivot matrix to use
  22702. * @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
  22703. * @returns the current TransformNode
  22704. */
  22705. setPivotMatrix(matrix: Matrix, postMultiplyPivotMatrix?: boolean): TransformNode;
  22706. /**
  22707. * Returns the mesh pivot matrix.
  22708. * Default : Identity.
  22709. * A Matrix is returned.
  22710. */
  22711. getPivotMatrix(): Matrix;
  22712. /**
  22713. * Prevents the World matrix to be computed any longer.
  22714. * Returns the TransformNode.
  22715. */
  22716. freezeWorldMatrix(): TransformNode;
  22717. /**
  22718. * Allows back the World matrix computation.
  22719. * Returns the TransformNode.
  22720. */
  22721. unfreezeWorldMatrix(): this;
  22722. /**
  22723. * True if the World matrix has been frozen.
  22724. * Returns a boolean.
  22725. */
  22726. readonly isWorldMatrixFrozen: boolean;
  22727. /**
  22728. * Retuns the mesh absolute position in the World.
  22729. * Returns a Vector3.
  22730. */
  22731. getAbsolutePosition(): Vector3;
  22732. /**
  22733. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  22734. * Returns the TransformNode.
  22735. */
  22736. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  22737. /**
  22738. * Sets the mesh position in its local space.
  22739. * Returns the TransformNode.
  22740. */
  22741. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  22742. /**
  22743. * Returns the mesh position in the local space from the current World matrix values.
  22744. * Returns a new Vector3.
  22745. */
  22746. getPositionExpressedInLocalSpace(): Vector3;
  22747. /**
  22748. * Translates the mesh along the passed Vector3 in its local space.
  22749. * Returns the TransformNode.
  22750. */
  22751. locallyTranslate(vector3: Vector3): TransformNode;
  22752. private static _lookAtVectorCache;
  22753. /**
  22754. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  22755. * @param targetPoint the position (must be in same space as current mesh) to look at
  22756. * @param yawCor optional yaw (y-axis) correction in radians
  22757. * @param pitchCor optional pitch (x-axis) correction in radians
  22758. * @param rollCor optional roll (z-axis) correction in radians
  22759. * @param space the choosen space of the target
  22760. * @returns the TransformNode.
  22761. */
  22762. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  22763. /**
  22764. * Returns a new Vector3 what is the localAxis, expressed in the mesh local space, rotated like the mesh.
  22765. * This Vector3 is expressed in the World space.
  22766. */
  22767. getDirection(localAxis: Vector3): Vector3;
  22768. /**
  22769. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  22770. * localAxis is expressed in the mesh local space.
  22771. * result is computed in the Wordl space from the mesh World matrix.
  22772. * Returns the TransformNode.
  22773. */
  22774. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  22775. /**
  22776. * Sets a new pivot point to the current node
  22777. * @param point defines the new pivot point to use
  22778. * @param space defines if the point is in world or local space (local by default)
  22779. * @returns the current TransformNode
  22780. */
  22781. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  22782. /**
  22783. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  22784. */
  22785. getPivotPoint(): Vector3;
  22786. /**
  22787. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  22788. * Returns the TransformNode.
  22789. */
  22790. getPivotPointToRef(result: Vector3): TransformNode;
  22791. /**
  22792. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  22793. */
  22794. getAbsolutePivotPoint(): Vector3;
  22795. /**
  22796. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  22797. * Returns the TransformNode.
  22798. */
  22799. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  22800. /**
  22801. * Defines the passed node as the parent of the current node.
  22802. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  22803. * Returns the TransformNode.
  22804. */
  22805. setParent(node: Nullable<Node>): TransformNode;
  22806. private _nonUniformScaling;
  22807. readonly nonUniformScaling: boolean;
  22808. _updateNonUniformScalingState(value: boolean): boolean;
  22809. /**
  22810. * Attach the current TransformNode to another TransformNode associated with a bone
  22811. * @param bone Bone affecting the TransformNode
  22812. * @param affectedTransformNode TransformNode associated with the bone
  22813. */
  22814. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  22815. detachFromBone(): TransformNode;
  22816. private static _rotationAxisCache;
  22817. /**
  22818. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  22819. * space (default LOCAL) can be either BABYLON.Space.LOCAL, either BABYLON.Space.WORLD.
  22820. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  22821. * The passed axis is also normalized.
  22822. * Returns the TransformNode.
  22823. */
  22824. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  22825. /**
  22826. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  22827. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  22828. * The passed axis is also normalized.
  22829. * Returns the TransformNode.
  22830. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  22831. */
  22832. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  22833. /**
  22834. * Translates the mesh along the axis vector for the passed distance in the given space.
  22835. * space (default LOCAL) can be either BABYLON.Space.LOCAL, either BABYLON.Space.WORLD.
  22836. * Returns the TransformNode.
  22837. */
  22838. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  22839. /**
  22840. * Adds a rotation step to the mesh current rotation.
  22841. * x, y, z are Euler angles expressed in radians.
  22842. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  22843. * This means this rotation is made in the mesh local space only.
  22844. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  22845. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  22846. * ```javascript
  22847. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  22848. * ```
  22849. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  22850. * 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.
  22851. * Returns the TransformNode.
  22852. */
  22853. addRotation(x: number, y: number, z: number): TransformNode;
  22854. /**
  22855. * Computes the mesh World matrix and returns it.
  22856. * If the mesh world matrix is frozen, this computation does nothing more than returning the last frozen values.
  22857. * If the parameter `force` is let to `false` (default), the current cached World matrix is returned.
  22858. * If the parameter `force`is set to `true`, the actual computation is done.
  22859. * Returns the mesh World Matrix.
  22860. */
  22861. computeWorldMatrix(force?: boolean): Matrix;
  22862. protected _afterComputeWorldMatrix(): void;
  22863. /**
  22864. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  22865. * @param func: callback function to add
  22866. *
  22867. * Returns the TransformNode.
  22868. */
  22869. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  22870. /**
  22871. * Removes a registered callback function.
  22872. * Returns the TransformNode.
  22873. */
  22874. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  22875. /**
  22876. * Clone the current transform node
  22877. * Returns the new transform node
  22878. * @param name Name of the new clone
  22879. * @param newParent New parent for the clone
  22880. * @param doNotCloneChildren Do not clone children hierarchy
  22881. */
  22882. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  22883. serialize(currentSerializationObject?: any): any;
  22884. /**
  22885. * Returns a new TransformNode object parsed from the source provided.
  22886. * The parameter `parsedMesh` is the source.
  22887. * The parameter `rootUrl` is a string, it's the root URL to prefix the `delayLoadingFile` property with
  22888. */
  22889. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  22890. /**
  22891. * Releases resources associated with this transform node.
  22892. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  22893. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  22894. */
  22895. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  22896. }
  22897. }
  22898. declare module BABYLON {
  22899. class VertexBuffer {
  22900. /** @hidden */
  22901. _buffer: Buffer;
  22902. private _kind;
  22903. private _size;
  22904. private _ownsBuffer;
  22905. private _instanced;
  22906. private _instanceDivisor;
  22907. /**
  22908. * The byte type.
  22909. */
  22910. static readonly BYTE: number;
  22911. /**
  22912. * The unsigned byte type.
  22913. */
  22914. static readonly UNSIGNED_BYTE: number;
  22915. /**
  22916. * The short type.
  22917. */
  22918. static readonly SHORT: number;
  22919. /**
  22920. * The unsigned short type.
  22921. */
  22922. static readonly UNSIGNED_SHORT: number;
  22923. /**
  22924. * The integer type.
  22925. */
  22926. static readonly INT: number;
  22927. /**
  22928. * The unsigned integer type.
  22929. */
  22930. static readonly UNSIGNED_INT: number;
  22931. /**
  22932. * The float type.
  22933. */
  22934. static readonly FLOAT: number;
  22935. /**
  22936. * Gets or sets the instance divisor when in instanced mode
  22937. */
  22938. instanceDivisor: number;
  22939. /**
  22940. * Gets the byte stride.
  22941. */
  22942. readonly byteStride: number;
  22943. /**
  22944. * Gets the byte offset.
  22945. */
  22946. readonly byteOffset: number;
  22947. /**
  22948. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  22949. */
  22950. readonly normalized: boolean;
  22951. /**
  22952. * Gets the data type of each component in the array.
  22953. */
  22954. readonly type: number;
  22955. /**
  22956. * Constructor
  22957. * @param engine the engine
  22958. * @param data the data to use for this vertex buffer
  22959. * @param kind the vertex buffer kind
  22960. * @param updatable whether the data is updatable
  22961. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  22962. * @param stride the stride (optional)
  22963. * @param instanced whether the buffer is instanced (optional)
  22964. * @param offset the offset of the data (optional)
  22965. * @param size the number of components (optional)
  22966. * @param type the type of the component (optional)
  22967. * @param normalized whether the data contains normalized data (optional)
  22968. * @param useBytes set to true if stride and offset are in bytes (optional)
  22969. */
  22970. 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);
  22971. _rebuild(): void;
  22972. /**
  22973. * Returns the kind of the VertexBuffer (string).
  22974. */
  22975. getKind(): string;
  22976. /**
  22977. * Boolean : is the VertexBuffer updatable ?
  22978. */
  22979. isUpdatable(): boolean;
  22980. /**
  22981. * Returns an array of numbers or a typed array containing the VertexBuffer data.
  22982. */
  22983. getData(): Nullable<DataArray>;
  22984. /**
  22985. * Returns the WebGLBuffer associated to the VertexBuffer.
  22986. */
  22987. getBuffer(): Nullable<WebGLBuffer>;
  22988. /**
  22989. * Returns the stride as a multiple of the type byte length.
  22990. * DEPRECATED. Use byteStride instead.
  22991. */
  22992. getStrideSize(): number;
  22993. /**
  22994. * Returns the offset as a multiple of the type byte length.
  22995. * DEPRECATED. Use byteOffset instead.
  22996. */
  22997. getOffset(): number;
  22998. /**
  22999. * Returns the number of components per vertex attribute (integer).
  23000. */
  23001. getSize(): number;
  23002. /**
  23003. * Boolean : is the WebGLBuffer of the VertexBuffer instanced now ?
  23004. */
  23005. getIsInstanced(): boolean;
  23006. /**
  23007. * Returns the instancing divisor, zero for non-instanced (integer).
  23008. */
  23009. getInstanceDivisor(): number;
  23010. /**
  23011. * Creates the underlying WebGLBuffer from the passed numeric array or Float32Array.
  23012. * Returns the created WebGLBuffer.
  23013. */
  23014. create(data?: DataArray): void;
  23015. /**
  23016. * Updates the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  23017. * This function will create a new buffer if the current one is not updatable
  23018. * Returns the updated WebGLBuffer.
  23019. */
  23020. update(data: DataArray): void;
  23021. /**
  23022. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  23023. * Returns the directly updated WebGLBuffer.
  23024. * @param data the new data
  23025. * @param offset the new offset
  23026. * @param useBytes set to true if the offset is in bytes
  23027. */
  23028. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  23029. /**
  23030. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  23031. */
  23032. dispose(): void;
  23033. /**
  23034. * Enumerates each value of this vertex buffer as numbers.
  23035. * @param count the number of values to enumerate
  23036. * @param callback the callback function called for each value
  23037. */
  23038. forEach(count: number, callback: (value: number, index: number) => void): void;
  23039. private static _PositionKind;
  23040. private static _NormalKind;
  23041. private static _TangentKind;
  23042. private static _UVKind;
  23043. private static _UV2Kind;
  23044. private static _UV3Kind;
  23045. private static _UV4Kind;
  23046. private static _UV5Kind;
  23047. private static _UV6Kind;
  23048. private static _ColorKind;
  23049. private static _MatricesIndicesKind;
  23050. private static _MatricesWeightsKind;
  23051. private static _MatricesIndicesExtraKind;
  23052. private static _MatricesWeightsExtraKind;
  23053. static readonly PositionKind: string;
  23054. static readonly NormalKind: string;
  23055. static readonly TangentKind: string;
  23056. static readonly UVKind: string;
  23057. static readonly UV2Kind: string;
  23058. static readonly UV3Kind: string;
  23059. static readonly UV4Kind: string;
  23060. static readonly UV5Kind: string;
  23061. static readonly UV6Kind: string;
  23062. static readonly ColorKind: string;
  23063. static readonly MatricesIndicesKind: string;
  23064. static readonly MatricesWeightsKind: string;
  23065. static readonly MatricesIndicesExtraKind: string;
  23066. static readonly MatricesWeightsExtraKind: string;
  23067. /**
  23068. * Deduces the stride given a kind.
  23069. * @param kind The kind string to deduce
  23070. * @returns The deduced stride
  23071. */
  23072. static DeduceStride(kind: string): number;
  23073. /**
  23074. * Gets the byte length of the given type.
  23075. * @param type the type
  23076. * @returns the number of bytes
  23077. */
  23078. static GetTypeByteLength(type: number): number;
  23079. /**
  23080. * Enumerates each value of the given parameters as numbers.
  23081. * @param data the data to enumerate
  23082. * @param byteOffset the byte offset of the data
  23083. * @param byteStride the byte stride of the data
  23084. * @param componentCount the number of components per element
  23085. * @param componentType the type of the component
  23086. * @param count the total number of components
  23087. * @param normalized whether the data is normalized
  23088. * @param callback the callback function called for each value
  23089. */
  23090. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  23091. private static _GetFloatValue(dataView, type, byteOffset, normalized);
  23092. }
  23093. }
  23094. declare module BABYLON {
  23095. /**
  23096. * This represents a GPU particle system in Babylon
  23097. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  23098. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  23099. */
  23100. class GPUParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  23101. /**
  23102. * The id of the Particle system.
  23103. */
  23104. id: string;
  23105. /**
  23106. * The friendly name of the Particle system.
  23107. */
  23108. name: string;
  23109. /**
  23110. * The emitter represents the Mesh or position we are attaching the particle system to.
  23111. */
  23112. emitter: Nullable<AbstractMesh | Vector3>;
  23113. /**
  23114. * The rendering group used by the Particle system to chose when to render.
  23115. */
  23116. renderingGroupId: number;
  23117. /**
  23118. * The layer mask we are rendering the particles through.
  23119. */
  23120. layerMask: number;
  23121. private _capacity;
  23122. private _activeCount;
  23123. private _currentActiveCount;
  23124. private _renderEffect;
  23125. private _updateEffect;
  23126. private _buffer0;
  23127. private _buffer1;
  23128. private _spriteBuffer;
  23129. private _updateVAO;
  23130. private _renderVAO;
  23131. private _targetIndex;
  23132. private _sourceBuffer;
  23133. private _targetBuffer;
  23134. private _scene;
  23135. private _engine;
  23136. private _currentRenderId;
  23137. private _started;
  23138. private _stopped;
  23139. private _timeDelta;
  23140. private _randomTexture;
  23141. private readonly _attributesStrideSize;
  23142. private _updateEffectOptions;
  23143. private _randomTextureSize;
  23144. private _actualFrame;
  23145. /**
  23146. * List of animations used by the particle system.
  23147. */
  23148. animations: Animation[];
  23149. /**
  23150. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  23151. */
  23152. static readonly IsSupported: boolean;
  23153. /**
  23154. * An event triggered when the system is disposed.
  23155. */
  23156. onDisposeObservable: Observable<GPUParticleSystem>;
  23157. /**
  23158. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  23159. */
  23160. updateSpeed: number;
  23161. /**
  23162. * The amount of time the particle system is running (depends of the overall update speed).
  23163. */
  23164. targetStopDuration: number;
  23165. /**
  23166. * The texture used to render each particle. (this can be a spritesheet)
  23167. */
  23168. particleTexture: Nullable<Texture>;
  23169. /**
  23170. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  23171. */
  23172. blendMode: number;
  23173. /**
  23174. * Minimum life time of emitting particles.
  23175. */
  23176. minLifeTime: number;
  23177. /**
  23178. * Maximum life time of emitting particles.
  23179. */
  23180. maxLifeTime: number;
  23181. /**
  23182. * Minimum Size of emitting particles.
  23183. */
  23184. minSize: number;
  23185. /**
  23186. * Maximum Size of emitting particles.
  23187. */
  23188. maxSize: number;
  23189. /**
  23190. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  23191. */
  23192. color1: Color4;
  23193. /**
  23194. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  23195. */
  23196. color2: Color4;
  23197. /**
  23198. * Color the particle will have at the end of its lifetime.
  23199. */
  23200. colorDead: Color4;
  23201. /**
  23202. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  23203. */
  23204. emitRate: number;
  23205. /**
  23206. * You can use gravity if you want to give an orientation to your particles.
  23207. */
  23208. gravity: Vector3;
  23209. /**
  23210. * Minimum power of emitting particles.
  23211. */
  23212. minEmitPower: number;
  23213. /**
  23214. * Maximum power of emitting particles.
  23215. */
  23216. maxEmitPower: number;
  23217. /**
  23218. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  23219. */
  23220. minAngularSpeed: number;
  23221. /**
  23222. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  23223. */
  23224. maxAngularSpeed: number;
  23225. /**
  23226. * The particle emitter type defines the emitter used by the particle system.
  23227. * It can be for example box, sphere, or cone...
  23228. */
  23229. particleEmitterType: Nullable<IParticleEmitterType>;
  23230. /**
  23231. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  23232. * This only works when particleEmitterTyps is a BoxParticleEmitter
  23233. */
  23234. direction1: Vector3;
  23235. /**
  23236. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  23237. * This only works when particleEmitterTyps is a BoxParticleEmitter
  23238. */
  23239. direction2: Vector3;
  23240. /**
  23241. * 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.
  23242. * This only works when particleEmitterTyps is a BoxParticleEmitter
  23243. */
  23244. minEmitBox: Vector3;
  23245. /**
  23246. * 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.
  23247. * This only works when particleEmitterTyps is a BoxParticleEmitter
  23248. */
  23249. maxEmitBox: Vector3;
  23250. /**
  23251. * Gets the maximum number of particles active at the same time.
  23252. * @returns The max number of active particles.
  23253. */
  23254. getCapacity(): number;
  23255. /**
  23256. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  23257. * to override the particles.
  23258. */
  23259. forceDepthWrite: boolean;
  23260. /**
  23261. * Gets or set the number of active particles
  23262. */
  23263. activeParticleCount: number;
  23264. /**
  23265. * Is this system ready to be used/rendered
  23266. * @return true if the system is ready
  23267. */
  23268. isReady(): boolean;
  23269. /**
  23270. * Gets Wether the system has been started.
  23271. * @returns True if it has been started, otherwise false.
  23272. */
  23273. isStarted(): boolean;
  23274. /**
  23275. * Starts the particle system and begins to emit.
  23276. */
  23277. start(): void;
  23278. /**
  23279. * Stops the particle system.
  23280. */
  23281. stop(): void;
  23282. /**
  23283. * Remove all active particles
  23284. */
  23285. reset(): void;
  23286. /**
  23287. * Returns the string "GPUParticleSystem"
  23288. * @returns a string containing the class name
  23289. */
  23290. getClassName(): string;
  23291. /**
  23292. * Instantiates a GPU particle system.
  23293. * 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.
  23294. * @param name The name of the particle system
  23295. * @param capacity The max number of particles alive at the same time
  23296. * @param scene The scene the particle system belongs to
  23297. */
  23298. constructor(name: string, options: Partial<{
  23299. capacity: number;
  23300. randomTextureSize: number;
  23301. }>, scene: Scene);
  23302. private _createUpdateVAO(source);
  23303. private _createRenderVAO(source, spriteSource);
  23304. private _initialize(force?);
  23305. /** @hidden */
  23306. _recreateUpdateEffect(): void;
  23307. /** @hidden */
  23308. _recreateRenderEffect(): void;
  23309. /**
  23310. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  23311. */
  23312. animate(): void;
  23313. /**
  23314. * Renders the particle system in its current state.
  23315. * @returns the current number of particles
  23316. */
  23317. render(): number;
  23318. /**
  23319. * Rebuilds the particle system
  23320. */
  23321. rebuild(): void;
  23322. private _releaseBuffers();
  23323. private _releaseVAOs();
  23324. /**
  23325. * Disposes the particle system and free the associated resources
  23326. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  23327. */
  23328. dispose(disposeTexture?: boolean): void;
  23329. /**
  23330. * Clones the particle system.
  23331. * @param name The name of the cloned object
  23332. * @param newEmitter The new emitter to use
  23333. * @returns the cloned particle system
  23334. */
  23335. clone(name: string, newEmitter: any): Nullable<GPUParticleSystem>;
  23336. /**
  23337. * Serializes the particle system to a JSON object.
  23338. * @returns the JSON object
  23339. */
  23340. serialize(): any;
  23341. /**
  23342. * Parses a JSON object to create a GPU particle system.
  23343. * @param parsedParticleSystem The JSON object to parse
  23344. * @param scene The scene to create the particle system in
  23345. * @param rootUrl The root url to use to load external dependencies like texture
  23346. * @returns the parsed GPU particle system
  23347. */
  23348. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string): GPUParticleSystem;
  23349. }
  23350. }
  23351. declare module BABYLON {
  23352. /**
  23353. * Interface representing a particle system in Babylon.
  23354. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  23355. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  23356. */
  23357. interface IParticleSystem {
  23358. /**
  23359. * The id of the Particle system.
  23360. */
  23361. id: string;
  23362. /**
  23363. * The name of the Particle system.
  23364. */
  23365. name: string;
  23366. /**
  23367. * The emitter represents the Mesh or position we are attaching the particle system to.
  23368. */
  23369. emitter: Nullable<AbstractMesh | Vector3>;
  23370. /**
  23371. * The rendering group used by the Particle system to chose when to render.
  23372. */
  23373. renderingGroupId: number;
  23374. /**
  23375. * The layer mask we are rendering the particles through.
  23376. */
  23377. layerMask: number;
  23378. /**
  23379. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  23380. */
  23381. updateSpeed: number;
  23382. /**
  23383. * The amount of time the particle system is running (depends of the overall update speed).
  23384. */
  23385. targetStopDuration: number;
  23386. /**
  23387. * The texture used to render each particle. (this can be a spritesheet)
  23388. */
  23389. particleTexture: Nullable<Texture>;
  23390. /**
  23391. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  23392. */
  23393. blendMode: number;
  23394. /**
  23395. * Minimum life time of emitting particles.
  23396. */
  23397. minLifeTime: number;
  23398. /**
  23399. * Maximum life time of emitting particles.
  23400. */
  23401. maxLifeTime: number;
  23402. /**
  23403. * Minimum Size of emitting particles.
  23404. */
  23405. minSize: number;
  23406. /**
  23407. * Maximum Size of emitting particles.
  23408. */
  23409. maxSize: number;
  23410. /**
  23411. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  23412. */
  23413. color1: Color4;
  23414. /**
  23415. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  23416. */
  23417. color2: Color4;
  23418. /**
  23419. * Color the particle will have at the end of its lifetime.
  23420. */
  23421. colorDead: Color4;
  23422. /**
  23423. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  23424. */
  23425. emitRate: number;
  23426. /**
  23427. * You can use gravity if you want to give an orientation to your particles.
  23428. */
  23429. gravity: Vector3;
  23430. /**
  23431. * Minimum power of emitting particles.
  23432. */
  23433. minEmitPower: number;
  23434. /**
  23435. * Maximum power of emitting particles.
  23436. */
  23437. maxEmitPower: number;
  23438. /**
  23439. * The particle emitter type defines the emitter used by the particle system.
  23440. * It can be for example box, sphere, or cone...
  23441. */
  23442. particleEmitterType: Nullable<IParticleEmitterType>;
  23443. /**
  23444. * Gets the maximum number of particles active at the same time.
  23445. * @returns The max number of active particles.
  23446. */
  23447. getCapacity(): number;
  23448. /**
  23449. * Gets Wether the system has been started.
  23450. * @returns True if it has been started, otherwise false.
  23451. */
  23452. isStarted(): boolean;
  23453. /**
  23454. * Gets if the particle system has been started.
  23455. * @return true if the system has been started, otherwise false.
  23456. */
  23457. isStarted(): boolean;
  23458. /**
  23459. * Animates the particle system for this frame.
  23460. */
  23461. animate(): void;
  23462. /**
  23463. * Renders the particle system in its current state.
  23464. * @returns the current number of particles
  23465. */
  23466. render(): number;
  23467. /**
  23468. * Dispose the particle system and frees its associated resources.
  23469. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  23470. */
  23471. dispose(disposeTexture?: boolean): void;
  23472. /**
  23473. * Clones the particle system.
  23474. * @param name The name of the cloned object
  23475. * @param newEmitter The new emitter to use
  23476. * @returns the cloned particle system
  23477. */
  23478. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  23479. /**
  23480. * Serializes the particle system to a JSON object.
  23481. * @returns the JSON object
  23482. */
  23483. serialize(): any;
  23484. /**
  23485. * Rebuild the particle system
  23486. */
  23487. rebuild(): void;
  23488. /**
  23489. * Starts the particle system and begins to emit.
  23490. */
  23491. start(): void;
  23492. /**
  23493. * Stops the particle system.
  23494. */
  23495. stop(): void;
  23496. /**
  23497. * Remove all active particles
  23498. */
  23499. reset(): void;
  23500. /**
  23501. * Is this system ready to be used/rendered
  23502. * @return true if the system is ready
  23503. */
  23504. isReady(): boolean;
  23505. }
  23506. }
  23507. declare module BABYLON {
  23508. /**
  23509. * A particle represents one of the element emitted by a particle system.
  23510. * This is mainly define by its coordinates, direction, velocity and age.
  23511. */
  23512. class Particle {
  23513. /**
  23514. * particleSystem the particle system the particle belongs to.
  23515. */
  23516. particleSystem: ParticleSystem;
  23517. /**
  23518. * The world position of the particle in the scene.
  23519. */
  23520. position: Vector3;
  23521. /**
  23522. * The world direction of the particle in the scene.
  23523. */
  23524. direction: Vector3;
  23525. /**
  23526. * The color of the particle.
  23527. */
  23528. color: Color4;
  23529. /**
  23530. * The color change of the particle per step.
  23531. */
  23532. colorStep: Color4;
  23533. /**
  23534. * Defines how long will the life of the particle be.
  23535. */
  23536. lifeTime: number;
  23537. /**
  23538. * The current age of the particle.
  23539. */
  23540. age: number;
  23541. /**
  23542. * The current size of the particle.
  23543. */
  23544. size: number;
  23545. /**
  23546. * The current angle of the particle.
  23547. */
  23548. angle: number;
  23549. /**
  23550. * Defines how fast is the angle changing.
  23551. */
  23552. angularSpeed: number;
  23553. /**
  23554. * Defines the cell index used by the particle to be rendered from a sprite.
  23555. */
  23556. cellIndex: number;
  23557. private _currentFrameCounter;
  23558. /**
  23559. * Creates a new instance Particle
  23560. * @param particleSystem the particle system the particle belongs to
  23561. */
  23562. constructor(
  23563. /**
  23564. * particleSystem the particle system the particle belongs to.
  23565. */
  23566. particleSystem: ParticleSystem);
  23567. private updateCellInfoFromSystem();
  23568. /**
  23569. * Defines how the sprite cell index is updated for the particle. This is
  23570. * defined as a callback.
  23571. */
  23572. updateCellIndex: (scaledUpdateSpeed: number) => void;
  23573. private _updateCellIndexWithSpeedCalculated(scaledUpdateSpeed);
  23574. private _updateCellIndexWithCustomSpeed();
  23575. /**
  23576. * Copy the properties of particle to another one.
  23577. * @param other the particle to copy the information to.
  23578. */
  23579. copyTo(other: Particle): void;
  23580. }
  23581. }
  23582. declare module BABYLON {
  23583. /**
  23584. * This represents a particle system in Babylon.
  23585. * 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.
  23586. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  23587. * @example https://doc.babylonjs.com/babylon101/particles
  23588. */
  23589. class ParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  23590. /**
  23591. * Source color is added to the destination color without alpha affecting the result.
  23592. */
  23593. static BLENDMODE_ONEONE: number;
  23594. /**
  23595. * Blend current color and particle color using particle’s alpha.
  23596. */
  23597. static BLENDMODE_STANDARD: number;
  23598. /**
  23599. * List of animations used by the particle system.
  23600. */
  23601. animations: Animation[];
  23602. /**
  23603. * The id of the Particle system.
  23604. */
  23605. id: string;
  23606. /**
  23607. * The friendly name of the Particle system.
  23608. */
  23609. name: string;
  23610. /**
  23611. * The rendering group used by the Particle system to chose when to render.
  23612. */
  23613. renderingGroupId: number;
  23614. /**
  23615. * The emitter represents the Mesh or position we are attaching the particle system to.
  23616. */
  23617. emitter: Nullable<AbstractMesh | Vector3>;
  23618. /**
  23619. * The maximum number of particles to emit per frame
  23620. */
  23621. emitRate: number;
  23622. /**
  23623. * If you want to launch only a few particles at once, that can be done, as well.
  23624. */
  23625. manualEmitCount: number;
  23626. /**
  23627. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  23628. */
  23629. updateSpeed: number;
  23630. /**
  23631. * The amount of time the particle system is running (depends of the overall update speed).
  23632. */
  23633. targetStopDuration: number;
  23634. /**
  23635. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  23636. */
  23637. disposeOnStop: boolean;
  23638. /**
  23639. * Minimum power of emitting particles.
  23640. */
  23641. minEmitPower: number;
  23642. /**
  23643. * Maximum power of emitting particles.
  23644. */
  23645. maxEmitPower: number;
  23646. /**
  23647. * Minimum life time of emitting particles.
  23648. */
  23649. minLifeTime: number;
  23650. /**
  23651. * Maximum life time of emitting particles.
  23652. */
  23653. maxLifeTime: number;
  23654. /**
  23655. * Minimum Size of emitting particles.
  23656. */
  23657. minSize: number;
  23658. /**
  23659. * Maximum Size of emitting particles.
  23660. */
  23661. maxSize: number;
  23662. /**
  23663. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  23664. */
  23665. minAngularSpeed: number;
  23666. /**
  23667. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  23668. */
  23669. maxAngularSpeed: number;
  23670. /**
  23671. * The texture used to render each particle. (this can be a spritesheet)
  23672. */
  23673. particleTexture: Nullable<Texture>;
  23674. /**
  23675. * The layer mask we are rendering the particles through.
  23676. */
  23677. layerMask: number;
  23678. /**
  23679. * This can help using your own shader to render the particle system.
  23680. * The according effect will be created
  23681. */
  23682. customShader: any;
  23683. /**
  23684. * By default particle system starts as soon as they are created. This prevents the
  23685. * automatic start to happen and let you decide when to start emitting particles.
  23686. */
  23687. preventAutoStart: boolean;
  23688. /**
  23689. * This function can be defined to provide custom update for active particles.
  23690. * This function will be called instead of regular update (age, position, color, etc.).
  23691. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  23692. */
  23693. updateFunction: (particles: Particle[]) => void;
  23694. /**
  23695. * Callback triggered when the particle animation is ending.
  23696. */
  23697. onAnimationEnd: Nullable<() => void>;
  23698. /**
  23699. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  23700. */
  23701. blendMode: number;
  23702. /**
  23703. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  23704. * to override the particles.
  23705. */
  23706. forceDepthWrite: boolean;
  23707. /**
  23708. * You can use gravity if you want to give an orientation to your particles.
  23709. */
  23710. gravity: Vector3;
  23711. /**
  23712. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  23713. * This only works when particleEmitterTyps is a BoxParticleEmitter
  23714. */
  23715. direction1: Vector3;
  23716. /**
  23717. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  23718. * This only works when particleEmitterTyps is a BoxParticleEmitter
  23719. */
  23720. direction2: Vector3;
  23721. /**
  23722. * 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.
  23723. * This only works when particleEmitterTyps is a BoxParticleEmitter
  23724. */
  23725. minEmitBox: Vector3;
  23726. /**
  23727. * 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.
  23728. * This only works when particleEmitterTyps is a BoxParticleEmitter
  23729. */
  23730. maxEmitBox: Vector3;
  23731. /**
  23732. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  23733. */
  23734. color1: Color4;
  23735. /**
  23736. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  23737. */
  23738. color2: Color4;
  23739. /**
  23740. * Color the particle will have at the end of its lifetime.
  23741. */
  23742. colorDead: Color4;
  23743. /**
  23744. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel.
  23745. */
  23746. textureMask: Color4;
  23747. /**
  23748. * The particle emitter type defines the emitter used by the particle system.
  23749. * It can be for example box, sphere, or cone...
  23750. */
  23751. particleEmitterType: IParticleEmitterType;
  23752. /**
  23753. * This function can be defined to specify initial direction for every new particle.
  23754. * It by default use the emitterType defined function.
  23755. */
  23756. startDirectionFunction: (emitPower: number, worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  23757. /**
  23758. * This function can be defined to specify initial position for every new particle.
  23759. * It by default use the emitterType defined function.
  23760. */
  23761. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  23762. /**
  23763. * If using a spritesheet (isAnimationSheetEnabled), defines if the sprite animation should loop between startSpriteCellID and endSpriteCellID or not.
  23764. */
  23765. spriteCellLoop: boolean;
  23766. /**
  23767. * If using a spritesheet (isAnimationSheetEnabled) and spriteCellLoop defines the speed of the sprite loop.
  23768. */
  23769. spriteCellChangeSpeed: number;
  23770. /**
  23771. * If using a spritesheet (isAnimationSheetEnabled) and spriteCellLoop defines the first sprite cell to display.
  23772. */
  23773. startSpriteCellID: number;
  23774. /**
  23775. * If using a spritesheet (isAnimationSheetEnabled) and spriteCellLoop defines the last sprite cell to display.
  23776. */
  23777. endSpriteCellID: number;
  23778. /**
  23779. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use.
  23780. */
  23781. spriteCellWidth: number;
  23782. /**
  23783. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use.
  23784. */
  23785. spriteCellHeight: number;
  23786. /**
  23787. * An event triggered when the system is disposed.
  23788. */
  23789. onDisposeObservable: Observable<ParticleSystem>;
  23790. private _onDisposeObserver;
  23791. /**
  23792. * Sets a callback that will be triggered when the system is disposed.
  23793. */
  23794. onDispose: () => void;
  23795. /**
  23796. * Gets wether an animation sprite sheet is enabled or not on the particle system.
  23797. */
  23798. readonly isAnimationSheetEnabled: Boolean;
  23799. private _particles;
  23800. private _epsilon;
  23801. private _capacity;
  23802. private _scene;
  23803. private _stockParticles;
  23804. private _newPartsExcess;
  23805. private _vertexData;
  23806. private _vertexBuffer;
  23807. private _vertexBuffers;
  23808. private _indexBuffer;
  23809. private _effect;
  23810. private _customEffect;
  23811. private _cachedDefines;
  23812. private _scaledColorStep;
  23813. private _colorDiff;
  23814. private _scaledDirection;
  23815. private _scaledGravity;
  23816. private _currentRenderId;
  23817. private _alive;
  23818. private _started;
  23819. private _stopped;
  23820. private _actualFrame;
  23821. private _scaledUpdateSpeed;
  23822. private _vertexBufferSize;
  23823. private _isAnimationSheetEnabled;
  23824. /**
  23825. * 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.
  23826. */
  23827. subEmitters: ParticleSystem[];
  23828. /**
  23829. * The current active Sub-systems, this property is used by the root particle system only.
  23830. */
  23831. activeSubSystems: Array<ParticleSystem>;
  23832. private _rootParticleSystem;
  23833. /**
  23834. * Gets the current list of active particles
  23835. */
  23836. readonly particles: Particle[];
  23837. /**
  23838. * Returns the string "ParticleSystem"
  23839. * @returns a string containing the class name
  23840. */
  23841. getClassName(): string;
  23842. /**
  23843. * Instantiates a particle system.
  23844. * 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.
  23845. * @param name The name of the particle system
  23846. * @param capacity The max number of particles alive at the same time
  23847. * @param scene The scene the particle system belongs to
  23848. * @param customEffect a custom effect used to change the way particles are rendered by default
  23849. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  23850. * @param epsilon Offset used to render the particles
  23851. */
  23852. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  23853. private _createIndexBuffer();
  23854. /**
  23855. * Gets the maximum number of particles active at the same time.
  23856. * @returns The max number of active particles.
  23857. */
  23858. getCapacity(): number;
  23859. /**
  23860. * Gets Wether there are still active particles in the system.
  23861. * @returns True if it is alive, otherwise false.
  23862. */
  23863. isAlive(): boolean;
  23864. /**
  23865. * Gets Wether the system has been started.
  23866. * @returns True if it has been started, otherwise false.
  23867. */
  23868. isStarted(): boolean;
  23869. /**
  23870. * Starts the particle system and begins to emit.
  23871. */
  23872. start(): void;
  23873. /**
  23874. * Stops the particle system.
  23875. * @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.
  23876. */
  23877. stop(stopSubEmitters?: boolean): void;
  23878. /**
  23879. * Remove all active particles
  23880. */
  23881. reset(): void;
  23882. /**
  23883. * @hidden (for internal use only)
  23884. */
  23885. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  23886. /**
  23887. * @hidden (for internal use only)
  23888. */
  23889. _appendParticleVertexWithAnimation(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  23890. /**
  23891. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  23892. * Its lifetime will start back at 0.
  23893. */
  23894. recycleParticle: (particle: Particle) => void;
  23895. private _stopSubEmitters();
  23896. private _createParticle;
  23897. private _removeFromRoot();
  23898. private _emitFromParticle;
  23899. private _update(newParticles);
  23900. private _getEffect();
  23901. /**
  23902. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  23903. */
  23904. animate(): void;
  23905. private _appendParticleVertexes;
  23906. private _appenedParticleVertexesWithSheet(offset, particle);
  23907. private _appenedParticleVertexesNoSheet(offset, particle);
  23908. /**
  23909. * Rebuilds the particle system.
  23910. */
  23911. rebuild(): void;
  23912. /**
  23913. * Is this system ready to be used/rendered
  23914. * @return true if the system is ready
  23915. */
  23916. isReady(): boolean;
  23917. /**
  23918. * Renders the particle system in its current state.
  23919. * @returns the current number of particles
  23920. */
  23921. render(): number;
  23922. /**
  23923. * Disposes the particle system and free the associated resources
  23924. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  23925. */
  23926. dispose(disposeTexture?: boolean): void;
  23927. /**
  23928. * Creates a Sphere Emitter for the particle system. (emits along the sphere radius)
  23929. * @param radius The radius of the sphere to emit from
  23930. * @returns the emitter
  23931. */
  23932. createSphereEmitter(radius?: number): SphereParticleEmitter;
  23933. /**
  23934. * Creates a Directed Sphere Emitter for the particle system. (emits between direction1 and direction2)
  23935. * @param radius The radius of the sphere to emit from
  23936. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  23937. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  23938. * @returns the emitter
  23939. */
  23940. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  23941. /**
  23942. * Creates a Cone Emitter for the particle system. (emits from the cone to the particle position)
  23943. * @param radius The radius of the cone to emit from
  23944. * @param angle The base angle of the cone
  23945. * @returns the emitter
  23946. */
  23947. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  23948. /**
  23949. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  23950. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  23951. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  23952. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  23953. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  23954. * @returns the emitter
  23955. */
  23956. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  23957. /**
  23958. * Clones the particle system.
  23959. * @param name The name of the cloned object
  23960. * @param newEmitter The new emitter to use
  23961. * @returns the cloned particle system
  23962. */
  23963. clone(name: string, newEmitter: any): ParticleSystem;
  23964. /**
  23965. * Serializes the particle system to a JSON object.
  23966. * @returns the JSON object
  23967. */
  23968. serialize(): any;
  23969. /**
  23970. * Parses a JSON object to create a particle system.
  23971. * @param parsedParticleSystem The JSON object to parse
  23972. * @param scene The scene to create the particle system in
  23973. * @param rootUrl The root url to use to load external dependencies like texture
  23974. * @returns the Parsed particle system
  23975. */
  23976. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string): ParticleSystem;
  23977. }
  23978. }
  23979. declare module BABYLON {
  23980. /**
  23981. * Represents one particle of a solid particle system.
  23982. */
  23983. class SolidParticle {
  23984. /**
  23985. * particle global index
  23986. */
  23987. idx: number;
  23988. /**
  23989. * The color of the particle
  23990. */
  23991. color: Nullable<Color4>;
  23992. /**
  23993. * The world space position of the particle.
  23994. */
  23995. position: Vector3;
  23996. /**
  23997. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  23998. */
  23999. rotation: Vector3;
  24000. /**
  24001. * The world space rotation quaternion of the particle.
  24002. */
  24003. rotationQuaternion: Nullable<Quaternion>;
  24004. /**
  24005. * The scaling of the particle.
  24006. */
  24007. scaling: Vector3;
  24008. /**
  24009. * The uvs of the particle.
  24010. */
  24011. uvs: Vector4;
  24012. /**
  24013. * The current speed of the particle.
  24014. */
  24015. velocity: Vector3;
  24016. /**
  24017. * The pivot point in the particle local space.
  24018. */
  24019. pivot: Vector3;
  24020. /**
  24021. * Must the particle be translated from its pivot point in its local space ?
  24022. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  24023. * Default : false
  24024. */
  24025. translateFromPivot: boolean;
  24026. /**
  24027. * Is the particle active or not ?
  24028. */
  24029. alive: boolean;
  24030. /**
  24031. * Is the particle visible or not ?
  24032. */
  24033. isVisible: boolean;
  24034. /**
  24035. * Index of this particle in the global "positions" array (Internal use)
  24036. */
  24037. _pos: number;
  24038. /**
  24039. * Index of this particle in the global "indices" array (Internal use)
  24040. */
  24041. _ind: number;
  24042. /**
  24043. * ModelShape of this particle (Internal use)
  24044. */
  24045. _model: ModelShape;
  24046. /**
  24047. * ModelShape id of this particle
  24048. */
  24049. shapeId: number;
  24050. /**
  24051. * Index of the particle in its shape id (Internal use)
  24052. */
  24053. idxInShape: number;
  24054. /**
  24055. * Reference to the shape model BoundingInfo object (Internal use)
  24056. */
  24057. _modelBoundingInfo: BoundingInfo;
  24058. /**
  24059. * Particle BoundingInfo object (Internal use)
  24060. */
  24061. _boundingInfo: BoundingInfo;
  24062. /**
  24063. * Reference to the SPS what the particle belongs to (Internal use)
  24064. */
  24065. _sps: SolidParticleSystem;
  24066. /**
  24067. * Still set as invisible in order to skip useless computations (Internal use)
  24068. */
  24069. _stillInvisible: boolean;
  24070. /**
  24071. * Last computed particle rotation matrix
  24072. */
  24073. _rotationMatrix: number[];
  24074. /**
  24075. * Parent particle Id, if any.
  24076. * Default null.
  24077. */
  24078. parentId: Nullable<number>;
  24079. /**
  24080. * Internal global position in the SPS.
  24081. */
  24082. _globalPosition: Vector3;
  24083. /**
  24084. * Creates a Solid Particle object.
  24085. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  24086. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  24087. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  24088. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  24089. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  24090. * @param shapeId (integer) is the model shape identifier in the SPS.
  24091. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  24092. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  24093. */
  24094. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  24095. /**
  24096. * Legacy support, changed scale to scaling
  24097. */
  24098. /**
  24099. * Legacy support, changed scale to scaling
  24100. */
  24101. scale: Vector3;
  24102. /**
  24103. * Legacy support, changed quaternion to rotationQuaternion
  24104. */
  24105. /**
  24106. * Legacy support, changed quaternion to rotationQuaternion
  24107. */
  24108. quaternion: Nullable<Quaternion>;
  24109. /**
  24110. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  24111. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  24112. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  24113. * @returns true if it intersects
  24114. */
  24115. intersectsMesh(target: Mesh | SolidParticle): boolean;
  24116. }
  24117. /**
  24118. * Represents the shape of the model used by one particle of a solid particle system.
  24119. * SPS internal tool, don't use it manually.
  24120. */
  24121. class ModelShape {
  24122. /**
  24123. * The shape id.
  24124. */
  24125. shapeID: number;
  24126. /**
  24127. * flat array of model positions (internal use)
  24128. */
  24129. _shape: Vector3[];
  24130. /**
  24131. * flat array of model UVs (internal use)
  24132. */
  24133. _shapeUV: number[];
  24134. /**
  24135. * length of the shape in the model indices array (internal use)
  24136. */
  24137. _indicesLength: number;
  24138. /**
  24139. * Custom position function (internal use)
  24140. */
  24141. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  24142. /**
  24143. * Custom vertex function (internal use)
  24144. */
  24145. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  24146. /**
  24147. * 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.
  24148. * SPS internal tool, don't use it manually.
  24149. * @hidden
  24150. */
  24151. 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>);
  24152. }
  24153. /**
  24154. * Represents a Depth Sorted Particle in the solid particle system.
  24155. */
  24156. class DepthSortedParticle {
  24157. /**
  24158. * Index of the particle in the "indices" array
  24159. */
  24160. ind: number;
  24161. /**
  24162. * Length of the particle shape in the "indices" array
  24163. */
  24164. indicesLength: number;
  24165. /**
  24166. * Squared distance from the particle to the camera
  24167. */
  24168. sqDistance: number;
  24169. }
  24170. }
  24171. declare module BABYLON {
  24172. /**
  24173. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  24174. *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.
  24175. * The SPS is also a particle system. It provides some methods to manage the particles.
  24176. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  24177. *
  24178. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  24179. */
  24180. class SolidParticleSystem implements IDisposable {
  24181. /**
  24182. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  24183. * Example : var p = SPS.particles[i];
  24184. */
  24185. particles: SolidParticle[];
  24186. /**
  24187. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  24188. */
  24189. nbParticles: number;
  24190. /**
  24191. * If the particles must ever face the camera (default false). Useful for planar particles.
  24192. */
  24193. billboard: boolean;
  24194. /**
  24195. * Recompute normals when adding a shape
  24196. */
  24197. recomputeNormals: boolean;
  24198. /**
  24199. * This a counter ofr your own usage. It's not set by any SPS functions.
  24200. */
  24201. counter: number;
  24202. /**
  24203. * The SPS name. This name is also given to the underlying mesh.
  24204. */
  24205. name: string;
  24206. /**
  24207. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  24208. */
  24209. mesh: Mesh;
  24210. /**
  24211. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  24212. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  24213. */
  24214. vars: any;
  24215. /**
  24216. * This array is populated when the SPS is set as 'pickable'.
  24217. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  24218. * Each element of this array is an object `{idx: int, faceId: int}`.
  24219. * `idx` is the picked particle index in the `SPS.particles` array
  24220. * `faceId` is the picked face index counted within this particle.
  24221. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  24222. */
  24223. pickedParticles: {
  24224. idx: number;
  24225. faceId: number;
  24226. }[];
  24227. /**
  24228. * This array is populated when `enableDepthSort` is set to true.
  24229. * Each element of this array is an instance of the class DepthSortedParticle.
  24230. */
  24231. depthSortedParticles: DepthSortedParticle[];
  24232. /**
  24233. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  24234. */
  24235. _bSphereOnly: boolean;
  24236. /**
  24237. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  24238. */
  24239. _bSphereRadiusFactor: number;
  24240. private _scene;
  24241. private _positions;
  24242. private _indices;
  24243. private _normals;
  24244. private _colors;
  24245. private _uvs;
  24246. private _indices32;
  24247. private _positions32;
  24248. private _normals32;
  24249. private _fixedNormal32;
  24250. private _colors32;
  24251. private _uvs32;
  24252. private _index;
  24253. private _updatable;
  24254. private _pickable;
  24255. private _isVisibilityBoxLocked;
  24256. private _alwaysVisible;
  24257. private _depthSort;
  24258. private _shapeCounter;
  24259. private _copy;
  24260. private _shape;
  24261. private _shapeUV;
  24262. private _color;
  24263. private _computeParticleColor;
  24264. private _computeParticleTexture;
  24265. private _computeParticleRotation;
  24266. private _computeParticleVertex;
  24267. private _computeBoundingBox;
  24268. private _depthSortParticles;
  24269. private _cam_axisZ;
  24270. private _cam_axisY;
  24271. private _cam_axisX;
  24272. private _axisZ;
  24273. private _camera;
  24274. private _particle;
  24275. private _camDir;
  24276. private _camInvertedPosition;
  24277. private _rotMatrix;
  24278. private _invertMatrix;
  24279. private _rotated;
  24280. private _quaternion;
  24281. private _vertex;
  24282. private _normal;
  24283. private _yaw;
  24284. private _pitch;
  24285. private _roll;
  24286. private _halfroll;
  24287. private _halfpitch;
  24288. private _halfyaw;
  24289. private _sinRoll;
  24290. private _cosRoll;
  24291. private _sinPitch;
  24292. private _cosPitch;
  24293. private _sinYaw;
  24294. private _cosYaw;
  24295. private _mustUnrotateFixedNormals;
  24296. private _minimum;
  24297. private _maximum;
  24298. private _minBbox;
  24299. private _maxBbox;
  24300. private _particlesIntersect;
  24301. private _depthSortFunction;
  24302. private _needs32Bits;
  24303. private _pivotBackTranslation;
  24304. private _scaledPivot;
  24305. private _particleHasParent;
  24306. private _parent;
  24307. /**
  24308. * Creates a SPS (Solid Particle System) object.
  24309. * @param name (String) is the SPS name, this will be the underlying mesh name.
  24310. * @param scene (Scene) is the scene in which the SPS is added.
  24311. * @param updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  24312. * @param isPickable (optional boolean, default false) : if the solid particles must be pickable.
  24313. * @param enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  24314. * @param particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  24315. * @param boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  24316. * @param bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  24317. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  24318. */
  24319. constructor(name: string, scene: Scene, options?: {
  24320. updatable?: boolean;
  24321. isPickable?: boolean;
  24322. enableDepthSort?: boolean;
  24323. particleIntersection?: boolean;
  24324. boundingSphereOnly?: boolean;
  24325. bSphereRadiusFactor?: number;
  24326. });
  24327. /**
  24328. * Builds the SPS underlying mesh. Returns a standard Mesh.
  24329. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  24330. * @returns the created mesh
  24331. */
  24332. buildMesh(): Mesh;
  24333. /**
  24334. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  24335. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  24336. * Thus the particles generated from `digest()` have their property `position` set yet.
  24337. * @param mesh ( Mesh ) is the mesh to be digested
  24338. * @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
  24339. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  24340. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  24341. * @returns the current SPS
  24342. */
  24343. digest(mesh: Mesh, options?: {
  24344. facetNb?: number;
  24345. number?: number;
  24346. delta?: number;
  24347. }): SolidParticleSystem;
  24348. private _unrotateFixedNormals();
  24349. private _resetCopy();
  24350. private _meshBuilder(p, shape, positions, meshInd, indices, meshUV, uvs, meshCol, colors, meshNor, normals, idx, idxInShape, options);
  24351. private _posToShape(positions);
  24352. private _uvsToShapeUV(uvs);
  24353. private _addParticle(idx, idxpos, idxind, model, shapeId, idxInShape, bInfo?);
  24354. /**
  24355. * Adds some particles to the SPS from the model shape. Returns the shape id.
  24356. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  24357. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  24358. * @param nb (positive integer) the number of particles to be created from this model
  24359. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  24360. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  24361. * @returns the number of shapes in the system
  24362. */
  24363. addShape(mesh: Mesh, nb: number, options?: {
  24364. positionFunction?: any;
  24365. vertexFunction?: any;
  24366. }): number;
  24367. private _rebuildParticle(particle);
  24368. /**
  24369. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  24370. * @returns the SPS.
  24371. */
  24372. rebuildMesh(): SolidParticleSystem;
  24373. /**
  24374. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  24375. * This method calls `updateParticle()` for each particle of the SPS.
  24376. * For an animated SPS, it is usually called within the render loop.
  24377. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  24378. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  24379. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  24380. * @returns the SPS.
  24381. */
  24382. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  24383. private _quaternionRotationYPR();
  24384. private _quaternionToRotationMatrix();
  24385. /**
  24386. * Disposes the SPS.
  24387. */
  24388. dispose(): void;
  24389. /**
  24390. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  24391. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24392. * @returns the SPS.
  24393. */
  24394. refreshVisibleSize(): SolidParticleSystem;
  24395. /**
  24396. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  24397. * @param size the size (float) of the visibility box
  24398. * note : this doesn't lock the SPS mesh bounding box.
  24399. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24400. */
  24401. setVisibilityBox(size: number): void;
  24402. /**
  24403. * Gets whether the SPS as always visible or not
  24404. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24405. */
  24406. /**
  24407. * Sets the SPS as always visible or not
  24408. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24409. */
  24410. isAlwaysVisible: boolean;
  24411. /**
  24412. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  24413. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24414. */
  24415. /**
  24416. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  24417. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24418. */
  24419. isVisibilityBoxLocked: boolean;
  24420. /**
  24421. * Gets if `setParticles()` computes the particle rotations or not.
  24422. * Default value : true. The SPS is faster when it's set to false.
  24423. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  24424. */
  24425. /**
  24426. * Tells to `setParticles()` to compute the particle rotations or not.
  24427. * Default value : true. The SPS is faster when it's set to false.
  24428. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  24429. */
  24430. computeParticleRotation: boolean;
  24431. /**
  24432. * Gets if `setParticles()` computes the particle colors or not.
  24433. * Default value : true. The SPS is faster when it's set to false.
  24434. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  24435. */
  24436. /**
  24437. * Tells to `setParticles()` to compute the particle colors or not.
  24438. * Default value : true. The SPS is faster when it's set to false.
  24439. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  24440. */
  24441. computeParticleColor: boolean;
  24442. /**
  24443. * Gets if `setParticles()` computes the particle textures or not.
  24444. * Default value : true. The SPS is faster when it's set to false.
  24445. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  24446. */
  24447. computeParticleTexture: boolean;
  24448. /**
  24449. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  24450. * Default value : false. The SPS is faster when it's set to false.
  24451. * Note : the particle custom vertex positions aren't stored values.
  24452. */
  24453. /**
  24454. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  24455. * Default value : false. The SPS is faster when it's set to false.
  24456. * Note : the particle custom vertex positions aren't stored values.
  24457. */
  24458. computeParticleVertex: boolean;
  24459. /**
  24460. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  24461. */
  24462. /**
  24463. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  24464. */
  24465. computeBoundingBox: boolean;
  24466. /**
  24467. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  24468. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  24469. * Default : `true`
  24470. */
  24471. /**
  24472. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  24473. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  24474. * Default : `true`
  24475. */
  24476. depthSortParticles: boolean;
  24477. /**
  24478. * This function does nothing. It may be overwritten to set all the particle first values.
  24479. * The SPS doesn't call this function, you may have to call it by your own.
  24480. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  24481. */
  24482. initParticles(): void;
  24483. /**
  24484. * This function does nothing. It may be overwritten to recycle a particle.
  24485. * The SPS doesn't call this function, you may have to call it by your own.
  24486. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  24487. * @param particle The particle to recycle
  24488. * @returns the recycled particle
  24489. */
  24490. recycleParticle(particle: SolidParticle): SolidParticle;
  24491. /**
  24492. * Updates a particle : this function should be overwritten by the user.
  24493. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  24494. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  24495. * @example : just set a particle position or velocity and recycle conditions
  24496. * @param particle The particle to update
  24497. * @returns the updated particle
  24498. */
  24499. updateParticle(particle: SolidParticle): SolidParticle;
  24500. /**
  24501. * Updates a vertex of a particle : it can be overwritten by the user.
  24502. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  24503. * @param particle the current particle
  24504. * @param vertex the current index of the current particle
  24505. * @param pt the index of the current vertex in the particle shape
  24506. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  24507. * @example : just set a vertex particle position
  24508. * @returns the updated vertex
  24509. */
  24510. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  24511. /**
  24512. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  24513. * This does nothing and may be overwritten by the user.
  24514. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24515. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24516. * @param update the boolean update value actually passed to setParticles()
  24517. */
  24518. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  24519. /**
  24520. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  24521. * This will be passed three parameters.
  24522. * This does nothing and may be overwritten by the user.
  24523. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24524. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24525. * @param update the boolean update value actually passed to setParticles()
  24526. */
  24527. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  24528. }
  24529. }
  24530. declare module BABYLON {
  24531. class ReflectionProbe {
  24532. name: string;
  24533. private _scene;
  24534. private _renderTargetTexture;
  24535. private _projectionMatrix;
  24536. private _viewMatrix;
  24537. private _target;
  24538. private _add;
  24539. private _attachedMesh;
  24540. private _invertYAxis;
  24541. position: Vector3;
  24542. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  24543. samples: number;
  24544. refreshRate: number;
  24545. getScene(): Scene;
  24546. readonly cubeTexture: RenderTargetTexture;
  24547. readonly renderList: Nullable<AbstractMesh[]>;
  24548. attachToMesh(mesh: AbstractMesh): void;
  24549. /**
  24550. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  24551. *
  24552. * @param renderingGroupId The rendering group id corresponding to its index
  24553. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  24554. */
  24555. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  24556. dispose(): void;
  24557. }
  24558. }
  24559. declare module BABYLON {
  24560. interface PhysicsImpostorJoint {
  24561. mainImpostor: PhysicsImpostor;
  24562. connectedImpostor: PhysicsImpostor;
  24563. joint: PhysicsJoint;
  24564. }
  24565. class PhysicsEngine {
  24566. private _physicsPlugin;
  24567. gravity: Vector3;
  24568. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  24569. setGravity(gravity: Vector3): void;
  24570. /**
  24571. * Set the time step of the physics engine.
  24572. * default is 1/60.
  24573. * To slow it down, enter 1/600 for example.
  24574. * To speed it up, 1/30
  24575. * @param {number} newTimeStep the new timestep to apply to this world.
  24576. */
  24577. setTimeStep(newTimeStep?: number): void;
  24578. /**
  24579. * Get the time step of the physics engine.
  24580. */
  24581. getTimeStep(): number;
  24582. dispose(): void;
  24583. getPhysicsPluginName(): string;
  24584. static Epsilon: number;
  24585. private _impostors;
  24586. private _joints;
  24587. /**
  24588. * Adding a new impostor for the impostor tracking.
  24589. * This will be done by the impostor itself.
  24590. * @param {PhysicsImpostor} impostor the impostor to add
  24591. */
  24592. addImpostor(impostor: PhysicsImpostor): void;
  24593. /**
  24594. * Remove an impostor from the engine.
  24595. * This impostor and its mesh will not longer be updated by the physics engine.
  24596. * @param {PhysicsImpostor} impostor the impostor to remove
  24597. */
  24598. removeImpostor(impostor: PhysicsImpostor): void;
  24599. /**
  24600. * Add a joint to the physics engine
  24601. * @param {PhysicsImpostor} mainImpostor the main impostor to which the joint is added.
  24602. * @param {PhysicsImpostor} connectedImpostor the impostor that is connected to the main impostor using this joint
  24603. * @param {PhysicsJoint} the joint that will connect both impostors.
  24604. */
  24605. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  24606. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  24607. /**
  24608. * Called by the scene. no need to call it.
  24609. */
  24610. _step(delta: number): void;
  24611. getPhysicsPlugin(): IPhysicsEnginePlugin;
  24612. getImpostors(): Array<PhysicsImpostor>;
  24613. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  24614. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  24615. }
  24616. interface IPhysicsEnginePlugin {
  24617. world: any;
  24618. name: string;
  24619. setGravity(gravity: Vector3): void;
  24620. setTimeStep(timeStep: number): void;
  24621. getTimeStep(): number;
  24622. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  24623. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  24624. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  24625. generatePhysicsBody(impostor: PhysicsImpostor): void;
  24626. removePhysicsBody(impostor: PhysicsImpostor): void;
  24627. generateJoint(joint: PhysicsImpostorJoint): void;
  24628. removeJoint(joint: PhysicsImpostorJoint): void;
  24629. isSupported(): boolean;
  24630. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  24631. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  24632. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  24633. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  24634. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  24635. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  24636. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  24637. getBodyMass(impostor: PhysicsImpostor): number;
  24638. getBodyFriction(impostor: PhysicsImpostor): number;
  24639. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  24640. getBodyRestitution(impostor: PhysicsImpostor): number;
  24641. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  24642. sleepBody(impostor: PhysicsImpostor): void;
  24643. wakeUpBody(impostor: PhysicsImpostor): void;
  24644. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  24645. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  24646. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  24647. getRadius(impostor: PhysicsImpostor): number;
  24648. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  24649. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  24650. dispose(): void;
  24651. }
  24652. }
  24653. declare module BABYLON {
  24654. class PhysicsHelper {
  24655. private _scene;
  24656. private _physicsEngine;
  24657. constructor(scene: Scene);
  24658. /**
  24659. * @param {Vector3} origin the origin of the explosion
  24660. * @param {number} radius the explosion radius
  24661. * @param {number} strength the explosion strength
  24662. * @param {PhysicsRadialImpulseFalloff} falloff possible options: Constant & Linear. Defaults to Constant
  24663. */
  24664. applyRadialExplosionImpulse(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  24665. /**
  24666. * @param {Vector3} origin the origin of the explosion
  24667. * @param {number} radius the explosion radius
  24668. * @param {number} strength the explosion strength
  24669. * @param {PhysicsRadialImpulseFalloff} falloff possible options: Constant & Linear. Defaults to Constant
  24670. */
  24671. applyRadialExplosionForce(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  24672. /**
  24673. * @param {Vector3} origin the origin of the explosion
  24674. * @param {number} radius the explosion radius
  24675. * @param {number} strength the explosion strength
  24676. * @param {PhysicsRadialImpulseFalloff} falloff possible options: Constant & Linear. Defaults to Constant
  24677. */
  24678. gravitationalField(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  24679. /**
  24680. * @param {Vector3} origin the origin of the updraft
  24681. * @param {number} radius the radius of the updraft
  24682. * @param {number} strength the strength of the updraft
  24683. * @param {number} height the height of the updraft
  24684. * @param {PhysicsUpdraftMode} updraftMode possible options: Center & Perpendicular. Defaults to Center
  24685. */
  24686. updraft(origin: Vector3, radius: number, strength: number, height: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  24687. /**
  24688. * @param {Vector3} origin the of the vortex
  24689. * @param {number} radius the radius of the vortex
  24690. * @param {number} strength the strength of the vortex
  24691. * @param {number} height the height of the vortex
  24692. */
  24693. vortex(origin: Vector3, radius: number, strength: number, height: number): Nullable<PhysicsVortexEvent>;
  24694. }
  24695. /***** Radial explosion *****/
  24696. class PhysicsRadialExplosionEvent {
  24697. private _scene;
  24698. private _sphere;
  24699. private _sphereOptions;
  24700. private _rays;
  24701. private _dataFetched;
  24702. constructor(scene: Scene);
  24703. /**
  24704. * Returns the data related to the radial explosion event (sphere & rays).
  24705. * @returns {PhysicsRadialExplosionEventData}
  24706. */
  24707. getData(): PhysicsRadialExplosionEventData;
  24708. /**
  24709. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  24710. * @param impostor
  24711. * @param {Vector3} origin the origin of the explosion
  24712. * @param {number} radius the explosion radius
  24713. * @param {number} strength the explosion strength
  24714. * @param {PhysicsRadialImpulseFalloff} falloff possible options: Constant & Linear
  24715. * @returns {Nullable<PhysicsForceAndContactPoint>}
  24716. */
  24717. getImpostorForceAndContactPoint(impostor: PhysicsImpostor, origin: Vector3, radius: number, strength: number, falloff: PhysicsRadialImpulseFalloff): Nullable<PhysicsForceAndContactPoint>;
  24718. /**
  24719. * Disposes the sphere.
  24720. * @param {bolean} force
  24721. */
  24722. dispose(force?: boolean): void;
  24723. /*** Helpers ***/
  24724. private _prepareSphere();
  24725. private _intersectsWithSphere(impostor, origin, radius);
  24726. }
  24727. /***** Gravitational Field *****/
  24728. class PhysicsGravitationalFieldEvent {
  24729. private _physicsHelper;
  24730. private _scene;
  24731. private _origin;
  24732. private _radius;
  24733. private _strength;
  24734. private _falloff;
  24735. private _tickCallback;
  24736. private _sphere;
  24737. private _dataFetched;
  24738. constructor(physicsHelper: PhysicsHelper, scene: Scene, origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff);
  24739. /**
  24740. * Returns the data related to the gravitational field event (sphere).
  24741. * @returns {PhysicsGravitationalFieldEventData}
  24742. */
  24743. getData(): PhysicsGravitationalFieldEventData;
  24744. /**
  24745. * Enables the gravitational field.
  24746. */
  24747. enable(): void;
  24748. /**
  24749. * Disables the gravitational field.
  24750. */
  24751. disable(): void;
  24752. /**
  24753. * Disposes the sphere.
  24754. * @param {bolean} force
  24755. */
  24756. dispose(force?: boolean): void;
  24757. private _tick();
  24758. }
  24759. /***** Updraft *****/
  24760. class PhysicsUpdraftEvent {
  24761. private _scene;
  24762. private _origin;
  24763. private _radius;
  24764. private _strength;
  24765. private _height;
  24766. private _updraftMode;
  24767. private _physicsEngine;
  24768. private _originTop;
  24769. private _originDirection;
  24770. private _tickCallback;
  24771. private _cylinder;
  24772. private _cylinderPosition;
  24773. private _dataFetched;
  24774. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number, _updraftMode: PhysicsUpdraftMode);
  24775. /**
  24776. * Returns the data related to the updraft event (cylinder).
  24777. * @returns {PhysicsUpdraftEventData}
  24778. */
  24779. getData(): PhysicsUpdraftEventData;
  24780. /**
  24781. * Enables the updraft.
  24782. */
  24783. enable(): void;
  24784. /**
  24785. * Disables the cortex.
  24786. */
  24787. disable(): void;
  24788. /**
  24789. * Disposes the sphere.
  24790. * @param {bolean} force
  24791. */
  24792. dispose(force?: boolean): void;
  24793. private getImpostorForceAndContactPoint(impostor);
  24794. private _tick();
  24795. /*** Helpers ***/
  24796. private _prepareCylinder();
  24797. private _intersectsWithCylinder(impostor);
  24798. }
  24799. /***** Vortex *****/
  24800. class PhysicsVortexEvent {
  24801. private _scene;
  24802. private _origin;
  24803. private _radius;
  24804. private _strength;
  24805. private _height;
  24806. private _physicsEngine;
  24807. private _originTop;
  24808. private _centripetalForceThreshold;
  24809. private _updraftMultiplier;
  24810. private _tickCallback;
  24811. private _cylinder;
  24812. private _cylinderPosition;
  24813. private _dataFetched;
  24814. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number);
  24815. /**
  24816. * Returns the data related to the vortex event (cylinder).
  24817. * @returns {PhysicsVortexEventData}
  24818. */
  24819. getData(): PhysicsVortexEventData;
  24820. /**
  24821. * Enables the vortex.
  24822. */
  24823. enable(): void;
  24824. /**
  24825. * Disables the cortex.
  24826. */
  24827. disable(): void;
  24828. /**
  24829. * Disposes the sphere.
  24830. * @param {bolean} force
  24831. */
  24832. dispose(force?: boolean): void;
  24833. private getImpostorForceAndContactPoint(impostor);
  24834. private _tick();
  24835. /*** Helpers ***/
  24836. private _prepareCylinder();
  24837. private _intersectsWithCylinder(impostor);
  24838. }
  24839. /***** Enums *****/
  24840. /**
  24841. * The strenght of the force in correspondence to the distance of the affected object
  24842. */
  24843. enum PhysicsRadialImpulseFalloff {
  24844. /** Defines that impulse is constant in strength across it's whole radius */
  24845. Constant = 0,
  24846. /** DEfines that impulse gets weaker if it's further from the origin */
  24847. Linear = 1,
  24848. }
  24849. /**
  24850. * The strenght of the force in correspondence to the distance of the affected object
  24851. */
  24852. enum PhysicsUpdraftMode {
  24853. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  24854. Center = 0,
  24855. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  24856. Perpendicular = 1,
  24857. }
  24858. /***** Data interfaces *****/
  24859. interface PhysicsForceAndContactPoint {
  24860. force: Vector3;
  24861. contactPoint: Vector3;
  24862. }
  24863. interface PhysicsRadialExplosionEventData {
  24864. sphere: Mesh;
  24865. rays: Array<Ray>;
  24866. }
  24867. interface PhysicsGravitationalFieldEventData {
  24868. sphere: Mesh;
  24869. }
  24870. interface PhysicsUpdraftEventData {
  24871. cylinder: Mesh;
  24872. }
  24873. interface PhysicsVortexEventData {
  24874. cylinder: Mesh;
  24875. }
  24876. }
  24877. declare module BABYLON {
  24878. interface PhysicsImpostorParameters {
  24879. mass: number;
  24880. friction?: number;
  24881. restitution?: number;
  24882. nativeOptions?: any;
  24883. ignoreParent?: boolean;
  24884. disableBidirectionalTransformation?: boolean;
  24885. }
  24886. interface IPhysicsEnabledObject {
  24887. position: Vector3;
  24888. rotationQuaternion: Nullable<Quaternion>;
  24889. scaling: Vector3;
  24890. rotation?: Vector3;
  24891. parent?: any;
  24892. getBoundingInfo(): BoundingInfo;
  24893. computeWorldMatrix(force: boolean): Matrix;
  24894. getWorldMatrix?(): Matrix;
  24895. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  24896. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  24897. getIndices?(): Nullable<IndicesArray>;
  24898. getScene?(): Scene;
  24899. getAbsolutePosition(): Vector3;
  24900. getAbsolutePivotPoint(): Vector3;
  24901. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  24902. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  24903. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  24904. getClassName(): string;
  24905. }
  24906. class PhysicsImpostor {
  24907. object: IPhysicsEnabledObject;
  24908. type: number;
  24909. private _options;
  24910. private _scene;
  24911. static DEFAULT_OBJECT_SIZE: Vector3;
  24912. static IDENTITY_QUATERNION: Quaternion;
  24913. private _physicsEngine;
  24914. private _physicsBody;
  24915. private _bodyUpdateRequired;
  24916. private _onBeforePhysicsStepCallbacks;
  24917. private _onAfterPhysicsStepCallbacks;
  24918. private _onPhysicsCollideCallbacks;
  24919. private _deltaPosition;
  24920. private _deltaRotation;
  24921. private _deltaRotationConjugated;
  24922. private _parent;
  24923. private _isDisposed;
  24924. private static _tmpVecs;
  24925. private static _tmpQuat;
  24926. readonly isDisposed: boolean;
  24927. mass: number;
  24928. friction: number;
  24929. restitution: number;
  24930. uniqueId: number;
  24931. private _joints;
  24932. constructor(object: IPhysicsEnabledObject, type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  24933. /**
  24934. * This function will completly initialize this impostor.
  24935. * It will create a new body - but only if this mesh has no parent.
  24936. * If it has, this impostor will not be used other than to define the impostor
  24937. * of the child mesh.
  24938. */
  24939. _init(): void;
  24940. private _getPhysicsParent();
  24941. /**
  24942. * Should a new body be generated.
  24943. */
  24944. isBodyInitRequired(): boolean;
  24945. setScalingUpdated(updated: boolean): void;
  24946. /**
  24947. * Force a regeneration of this or the parent's impostor's body.
  24948. * Use under cautious - This will remove all joints already implemented.
  24949. */
  24950. forceUpdate(): void;
  24951. /**
  24952. * Gets the body that holds this impostor. Either its own, or its parent.
  24953. */
  24954. /**
  24955. * Set the physics body. Used mainly by the physics engine/plugin
  24956. */
  24957. physicsBody: any;
  24958. parent: Nullable<PhysicsImpostor>;
  24959. resetUpdateFlags(): void;
  24960. getObjectExtendSize(): Vector3;
  24961. getObjectCenter(): Vector3;
  24962. /**
  24963. * Get a specific parametes from the options parameter.
  24964. */
  24965. getParam(paramName: string): any;
  24966. /**
  24967. * Sets a specific parameter in the options given to the physics plugin
  24968. */
  24969. setParam(paramName: string, value: number): void;
  24970. /**
  24971. * Specifically change the body's mass option. Won't recreate the physics body object
  24972. */
  24973. setMass(mass: number): void;
  24974. getLinearVelocity(): Nullable<Vector3>;
  24975. setLinearVelocity(velocity: Nullable<Vector3>): void;
  24976. getAngularVelocity(): Nullable<Vector3>;
  24977. setAngularVelocity(velocity: Nullable<Vector3>): void;
  24978. /**
  24979. * Execute a function with the physics plugin native code.
  24980. * Provide a function the will have two variables - the world object and the physics body object.
  24981. */
  24982. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  24983. /**
  24984. * Register a function that will be executed before the physics world is stepping forward.
  24985. */
  24986. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24987. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24988. /**
  24989. * Register a function that will be executed after the physics step
  24990. */
  24991. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24992. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24993. /**
  24994. * register a function that will be executed when this impostor collides against a different body.
  24995. */
  24996. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  24997. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  24998. private _tmpQuat;
  24999. private _tmpQuat2;
  25000. getParentsRotation(): Quaternion;
  25001. /**
  25002. * this function is executed by the physics engine.
  25003. */
  25004. beforeStep: () => void;
  25005. /**
  25006. * this function is executed by the physics engine.
  25007. */
  25008. afterStep: () => void;
  25009. /**
  25010. * Legacy collision detection event support
  25011. */
  25012. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  25013. onCollide: (e: {
  25014. body: any;
  25015. }) => void;
  25016. /**
  25017. * Apply a force
  25018. */
  25019. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  25020. /**
  25021. * Apply an impulse
  25022. */
  25023. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  25024. /**
  25025. * A help function to create a joint.
  25026. */
  25027. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  25028. /**
  25029. * Add a joint to this impostor with a different impostor.
  25030. */
  25031. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  25032. /**
  25033. * Will keep this body still, in a sleep mode.
  25034. */
  25035. sleep(): PhysicsImpostor;
  25036. /**
  25037. * Wake the body up.
  25038. */
  25039. wakeUp(): PhysicsImpostor;
  25040. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  25041. dispose(): void;
  25042. setDeltaPosition(position: Vector3): void;
  25043. setDeltaRotation(rotation: Quaternion): void;
  25044. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  25045. getRadius(): number;
  25046. /**
  25047. * Sync a bone with this impostor
  25048. * @param bone The bone to sync to the impostor.
  25049. * @param boneMesh The mesh that the bone is influencing.
  25050. * @param jointPivot The pivot of the joint / bone in local space.
  25051. * @param distToJoint Optional distance from the impostor to the joint.
  25052. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  25053. */
  25054. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  25055. /**
  25056. * Sync impostor to a bone
  25057. * @param bone The bone that the impostor will be synced to.
  25058. * @param boneMesh The mesh that the bone is influencing.
  25059. * @param jointPivot The pivot of the joint / bone in local space.
  25060. * @param distToJoint Optional distance from the impostor to the joint.
  25061. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  25062. * @param boneAxis Optional vector3 axis the bone is aligned with
  25063. */
  25064. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  25065. static NoImpostor: number;
  25066. static SphereImpostor: number;
  25067. static BoxImpostor: number;
  25068. static PlaneImpostor: number;
  25069. static MeshImpostor: number;
  25070. static CylinderImpostor: number;
  25071. static ParticleImpostor: number;
  25072. static HeightmapImpostor: number;
  25073. }
  25074. }
  25075. declare module BABYLON {
  25076. interface PhysicsJointData {
  25077. mainPivot?: Vector3;
  25078. connectedPivot?: Vector3;
  25079. mainAxis?: Vector3;
  25080. connectedAxis?: Vector3;
  25081. collision?: boolean;
  25082. nativeParams?: any;
  25083. }
  25084. /**
  25085. * This is a holder class for the physics joint created by the physics plugin.
  25086. * It holds a set of functions to control the underlying joint.
  25087. */
  25088. class PhysicsJoint {
  25089. type: number;
  25090. jointData: PhysicsJointData;
  25091. private _physicsJoint;
  25092. protected _physicsPlugin: IPhysicsEnginePlugin;
  25093. constructor(type: number, jointData: PhysicsJointData);
  25094. physicsJoint: any;
  25095. physicsPlugin: IPhysicsEnginePlugin;
  25096. /**
  25097. * Execute a function that is physics-plugin specific.
  25098. * @param {Function} func the function that will be executed.
  25099. * It accepts two parameters: the physics world and the physics joint.
  25100. */
  25101. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  25102. static DistanceJoint: number;
  25103. static HingeJoint: number;
  25104. static BallAndSocketJoint: number;
  25105. static WheelJoint: number;
  25106. static SliderJoint: number;
  25107. static PrismaticJoint: number;
  25108. static UniversalJoint: number;
  25109. static Hinge2Joint: number;
  25110. static PointToPointJoint: number;
  25111. static SpringJoint: number;
  25112. static LockJoint: number;
  25113. }
  25114. /**
  25115. * A class representing a physics distance joint.
  25116. */
  25117. class DistanceJoint extends PhysicsJoint {
  25118. constructor(jointData: DistanceJointData);
  25119. /**
  25120. * Update the predefined distance.
  25121. */
  25122. updateDistance(maxDistance: number, minDistance?: number): void;
  25123. }
  25124. class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  25125. constructor(type: number, jointData: PhysicsJointData);
  25126. /**
  25127. * Set the motor values.
  25128. * Attention, this function is plugin specific. Engines won't react 100% the same.
  25129. * @param {number} force the force to apply
  25130. * @param {number} maxForce max force for this motor.
  25131. */
  25132. setMotor(force?: number, maxForce?: number): void;
  25133. /**
  25134. * Set the motor's limits.
  25135. * Attention, this function is plugin specific. Engines won't react 100% the same.
  25136. */
  25137. setLimit(upperLimit: number, lowerLimit?: number): void;
  25138. }
  25139. /**
  25140. * This class represents a single hinge physics joint
  25141. */
  25142. class HingeJoint extends MotorEnabledJoint {
  25143. constructor(jointData: PhysicsJointData);
  25144. /**
  25145. * Set the motor values.
  25146. * Attention, this function is plugin specific. Engines won't react 100% the same.
  25147. * @param {number} force the force to apply
  25148. * @param {number} maxForce max force for this motor.
  25149. */
  25150. setMotor(force?: number, maxForce?: number): void;
  25151. /**
  25152. * Set the motor's limits.
  25153. * Attention, this function is plugin specific. Engines won't react 100% the same.
  25154. */
  25155. setLimit(upperLimit: number, lowerLimit?: number): void;
  25156. }
  25157. /**
  25158. * This class represents a dual hinge physics joint (same as wheel joint)
  25159. */
  25160. class Hinge2Joint extends MotorEnabledJoint {
  25161. constructor(jointData: PhysicsJointData);
  25162. /**
  25163. * Set the motor values.
  25164. * Attention, this function is plugin specific. Engines won't react 100% the same.
  25165. * @param {number} force the force to apply
  25166. * @param {number} maxForce max force for this motor.
  25167. * @param {motorIndex} the motor's index, 0 or 1.
  25168. */
  25169. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  25170. /**
  25171. * Set the motor limits.
  25172. * Attention, this function is plugin specific. Engines won't react 100% the same.
  25173. * @param {number} upperLimit the upper limit
  25174. * @param {number} lowerLimit lower limit
  25175. * @param {motorIndex} the motor's index, 0 or 1.
  25176. */
  25177. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  25178. }
  25179. interface IMotorEnabledJoint {
  25180. physicsJoint: any;
  25181. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  25182. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  25183. }
  25184. interface DistanceJointData extends PhysicsJointData {
  25185. maxDistance: number;
  25186. }
  25187. interface SpringJointData extends PhysicsJointData {
  25188. length: number;
  25189. stiffness: number;
  25190. damping: number;
  25191. }
  25192. }
  25193. declare module BABYLON {
  25194. class BoundingBoxRenderer {
  25195. frontColor: Color3;
  25196. backColor: Color3;
  25197. showBackLines: boolean;
  25198. renderList: SmartArray<BoundingBox>;
  25199. private _scene;
  25200. private _colorShader;
  25201. private _vertexBuffers;
  25202. private _indexBuffer;
  25203. constructor(scene: Scene);
  25204. private _prepareRessources();
  25205. private _createIndexBuffer();
  25206. _rebuild(): void;
  25207. reset(): void;
  25208. render(): void;
  25209. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  25210. dispose(): void;
  25211. }
  25212. }
  25213. declare module BABYLON {
  25214. /**
  25215. * This represents a depth renderer in Babylon.
  25216. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  25217. */
  25218. class DepthRenderer {
  25219. private _scene;
  25220. private _depthMap;
  25221. private _effect;
  25222. private _cachedDefines;
  25223. private _camera;
  25224. /**
  25225. * Instantiates a depth renderer
  25226. * @param scene The scene the renderer belongs to
  25227. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  25228. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  25229. */
  25230. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  25231. /**
  25232. * Creates the depth rendering effect and checks if the effect is ready.
  25233. * @param subMesh The submesh to be used to render the depth map of
  25234. * @param useInstances If multiple world instances should be used
  25235. * @returns if the depth renderer is ready to render the depth map
  25236. */
  25237. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  25238. /**
  25239. * Gets the texture which the depth map will be written to.
  25240. * @returns The depth map texture
  25241. */
  25242. getDepthMap(): RenderTargetTexture;
  25243. /**
  25244. * Disposes of the depth renderer.
  25245. */
  25246. dispose(): void;
  25247. }
  25248. }
  25249. declare module BABYLON {
  25250. class EdgesRenderer {
  25251. edgesWidthScalerForOrthographic: number;
  25252. edgesWidthScalerForPerspective: number;
  25253. private _source;
  25254. private _linesPositions;
  25255. private _linesNormals;
  25256. private _linesIndices;
  25257. private _epsilon;
  25258. private _indicesCount;
  25259. private _lineShader;
  25260. private _ib;
  25261. private _buffers;
  25262. private _checkVerticesInsteadOfIndices;
  25263. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  25264. isEnabled: boolean;
  25265. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  25266. private _prepareRessources();
  25267. _rebuild(): void;
  25268. dispose(): void;
  25269. private _processEdgeForAdjacencies(pa, pb, p0, p1, p2);
  25270. private _processEdgeForAdjacenciesWithVertices(pa, pb, p0, p1, p2);
  25271. private _checkEdge(faceIndex, edge, faceNormals, p0, p1);
  25272. _generateEdgesLines(): void;
  25273. render(): void;
  25274. }
  25275. }
  25276. declare module BABYLON {
  25277. /**
  25278. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  25279. */
  25280. class GeometryBufferRenderer {
  25281. private _scene;
  25282. private _multiRenderTarget;
  25283. private _ratio;
  25284. private _enablePosition;
  25285. protected _effect: Effect;
  25286. protected _cachedDefines: string;
  25287. /**
  25288. * Set the render list (meshes to be rendered) used in the G buffer.
  25289. */
  25290. renderList: Mesh[];
  25291. /**
  25292. * Gets wether or not G buffer are supported by the running hardware.
  25293. * This requires draw buffer supports
  25294. */
  25295. readonly isSupported: boolean;
  25296. /**
  25297. * Gets wether or not position are enabled for the G buffer.
  25298. */
  25299. /**
  25300. * Sets wether or not position are enabled for the G buffer.
  25301. */
  25302. enablePosition: boolean;
  25303. /**
  25304. * Gets the scene associated with the buffer.
  25305. */
  25306. readonly scene: Scene;
  25307. /**
  25308. * Gets the ratio used by the buffer during its creation.
  25309. * How big is the buffer related to the main canvas.
  25310. */
  25311. readonly ratio: number;
  25312. /**
  25313. * Creates a new G Buffer for the scene
  25314. * @param scene The scene the buffer belongs to
  25315. * @param ratio How big is the buffer related to the main canvas.
  25316. */
  25317. constructor(scene: Scene, ratio?: number);
  25318. /**
  25319. * Checks wether everything is ready to render a submesh to the G buffer.
  25320. * @param subMesh the submesh to check readiness for
  25321. * @param useInstances is the mesh drawn using instance or not
  25322. * @returns true if ready otherwise false
  25323. */
  25324. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  25325. /**
  25326. * Gets the current underlying G Buffer.
  25327. * @returns the buffer
  25328. */
  25329. getGBuffer(): MultiRenderTarget;
  25330. /**
  25331. * Gets the number of samples used to render the buffer (anti aliasing).
  25332. */
  25333. /**
  25334. * Sets the number of samples used to render the buffer (anti aliasing).
  25335. */
  25336. samples: number;
  25337. /**
  25338. * Disposes the renderer and frees up associated resources.
  25339. */
  25340. dispose(): void;
  25341. protected _createRenderTargets(): void;
  25342. }
  25343. }
  25344. declare module BABYLON {
  25345. class OutlineRenderer {
  25346. private _scene;
  25347. private _effect;
  25348. private _cachedDefines;
  25349. zOffset: number;
  25350. constructor(scene: Scene);
  25351. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  25352. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  25353. }
  25354. }
  25355. declare module BABYLON {
  25356. class RenderingGroup {
  25357. index: number;
  25358. private _scene;
  25359. private _opaqueSubMeshes;
  25360. private _transparentSubMeshes;
  25361. private _alphaTestSubMeshes;
  25362. private _depthOnlySubMeshes;
  25363. private _particleSystems;
  25364. private _spriteManagers;
  25365. private _opaqueSortCompareFn;
  25366. private _alphaTestSortCompareFn;
  25367. private _transparentSortCompareFn;
  25368. private _renderOpaque;
  25369. private _renderAlphaTest;
  25370. private _renderTransparent;
  25371. private _edgesRenderers;
  25372. onBeforeTransparentRendering: () => void;
  25373. /**
  25374. * Set the opaque sort comparison function.
  25375. * If null the sub meshes will be render in the order they were created
  25376. */
  25377. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  25378. /**
  25379. * Set the alpha test sort comparison function.
  25380. * If null the sub meshes will be render in the order they were created
  25381. */
  25382. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  25383. /**
  25384. * Set the transparent sort comparison function.
  25385. * If null the sub meshes will be render in the order they were created
  25386. */
  25387. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  25388. /**
  25389. * Creates a new rendering group.
  25390. * @param index The rendering group index
  25391. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  25392. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  25393. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  25394. */
  25395. 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>);
  25396. /**
  25397. * Render all the sub meshes contained in the group.
  25398. * @param customRenderFunction Used to override the default render behaviour of the group.
  25399. * @returns true if rendered some submeshes.
  25400. */
  25401. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  25402. /**
  25403. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  25404. * @param subMeshes The submeshes to render
  25405. */
  25406. private renderOpaqueSorted(subMeshes);
  25407. /**
  25408. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  25409. * @param subMeshes The submeshes to render
  25410. */
  25411. private renderAlphaTestSorted(subMeshes);
  25412. /**
  25413. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  25414. * @param subMeshes The submeshes to render
  25415. */
  25416. private renderTransparentSorted(subMeshes);
  25417. /**
  25418. * Renders the submeshes in a specified order.
  25419. * @param subMeshes The submeshes to sort before render
  25420. * @param sortCompareFn The comparison function use to sort
  25421. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  25422. * @param transparent Specifies to activate blending if true
  25423. */
  25424. private static renderSorted(subMeshes, sortCompareFn, camera, transparent);
  25425. /**
  25426. * Renders the submeshes in the order they were dispatched (no sort applied).
  25427. * @param subMeshes The submeshes to render
  25428. */
  25429. private static renderUnsorted(subMeshes);
  25430. /**
  25431. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  25432. * are rendered back to front if in the same alpha index.
  25433. *
  25434. * @param a The first submesh
  25435. * @param b The second submesh
  25436. * @returns The result of the comparison
  25437. */
  25438. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  25439. /**
  25440. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  25441. * are rendered back to front.
  25442. *
  25443. * @param a The first submesh
  25444. * @param b The second submesh
  25445. * @returns The result of the comparison
  25446. */
  25447. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  25448. /**
  25449. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  25450. * are rendered front to back (prevent overdraw).
  25451. *
  25452. * @param a The first submesh
  25453. * @param b The second submesh
  25454. * @returns The result of the comparison
  25455. */
  25456. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  25457. /**
  25458. * Resets the different lists of submeshes to prepare a new frame.
  25459. */
  25460. prepare(): void;
  25461. dispose(): void;
  25462. /**
  25463. * Inserts the submesh in its correct queue depending on its material.
  25464. * @param subMesh The submesh to dispatch
  25465. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  25466. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  25467. */
  25468. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  25469. dispatchSprites(spriteManager: SpriteManager): void;
  25470. dispatchParticles(particleSystem: IParticleSystem): void;
  25471. private _renderParticles(activeMeshes);
  25472. private _renderSprites();
  25473. }
  25474. }
  25475. declare module BABYLON {
  25476. class RenderingManager {
  25477. /**
  25478. * The max id used for rendering groups (not included)
  25479. */
  25480. static MAX_RENDERINGGROUPS: number;
  25481. /**
  25482. * The min id used for rendering groups (included)
  25483. */
  25484. static MIN_RENDERINGGROUPS: number;
  25485. /**
  25486. * Used to globally prevent autoclearing scenes.
  25487. */
  25488. static AUTOCLEAR: boolean;
  25489. private _scene;
  25490. private _renderingGroups;
  25491. private _depthStencilBufferAlreadyCleaned;
  25492. private _autoClearDepthStencil;
  25493. private _customOpaqueSortCompareFn;
  25494. private _customAlphaTestSortCompareFn;
  25495. private _customTransparentSortCompareFn;
  25496. private _renderinGroupInfo;
  25497. constructor(scene: Scene);
  25498. private _clearDepthStencilBuffer(depth?, stencil?);
  25499. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  25500. reset(): void;
  25501. dispose(): void;
  25502. /**
  25503. * Clear the info related to rendering groups preventing retention points during dispose.
  25504. */
  25505. freeRenderingGroups(): void;
  25506. private _prepareRenderingGroup(renderingGroupId);
  25507. dispatchSprites(spriteManager: SpriteManager): void;
  25508. dispatchParticles(particleSystem: IParticleSystem): void;
  25509. /**
  25510. * @param subMesh The submesh to dispatch
  25511. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  25512. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  25513. */
  25514. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  25515. /**
  25516. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  25517. * This allowed control for front to back rendering or reversly depending of the special needs.
  25518. *
  25519. * @param renderingGroupId The rendering group id corresponding to its index
  25520. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  25521. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  25522. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  25523. */
  25524. 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;
  25525. /**
  25526. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  25527. *
  25528. * @param renderingGroupId The rendering group id corresponding to its index
  25529. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  25530. * @param depth Automatically clears depth between groups if true and autoClear is true.
  25531. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  25532. */
  25533. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  25534. }
  25535. }
  25536. declare module BABYLON {
  25537. /**
  25538. * Renders a layer on top of an existing scene
  25539. */
  25540. class UtilityLayerRenderer implements IDisposable {
  25541. /** the original scene that will be rendered on top of */ originalScene: Scene;
  25542. /**
  25543. * The scene that is rendered on top of the original scene
  25544. */
  25545. utilityLayerScene: Scene;
  25546. /**
  25547. * If the utility layer should automatically be rendered on top of existing scene
  25548. */
  25549. shouldRender: boolean;
  25550. private _afterRenderObserver;
  25551. private _sceneDisposeObserver;
  25552. /**
  25553. * Instantiates a UtilityLayerRenderer
  25554. * @param originalScene the original scene that will be rendered on top of
  25555. */
  25556. constructor(/** the original scene that will be rendered on top of */ originalScene: Scene);
  25557. /**
  25558. * Renders the utility layers scene on top of the original scene
  25559. */
  25560. render(): void;
  25561. /**
  25562. * Disposes of the renderer
  25563. */
  25564. dispose(): void;
  25565. private _updateCamera();
  25566. }
  25567. }
  25568. declare module BABYLON {
  25569. /**
  25570. * Postprocess used to generate anaglyphic rendering
  25571. */
  25572. class AnaglyphPostProcess extends PostProcess {
  25573. private _passedProcess;
  25574. /**
  25575. * Creates a new AnaglyphPostProcess
  25576. * @param name defines postprocess name
  25577. * @param options defines creation options or target ratio scale
  25578. * @param rigCameras defines cameras using this postprocess
  25579. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  25580. * @param engine defines hosting engine
  25581. * @param reusable defines if the postprocess will be reused multiple times per frame
  25582. */
  25583. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  25584. }
  25585. }
  25586. declare module BABYLON {
  25587. class BlackAndWhitePostProcess extends PostProcess {
  25588. degree: number;
  25589. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  25590. }
  25591. }
  25592. declare module BABYLON {
  25593. /**
  25594. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  25595. */
  25596. class BloomEffect extends PostProcessRenderEffect {
  25597. private bloomScale;
  25598. /**
  25599. * Internal
  25600. */
  25601. _effects: Array<PostProcess>;
  25602. /**
  25603. * Internal
  25604. */
  25605. _downscale: ExtractHighlightsPostProcess;
  25606. private _blurX;
  25607. private _blurY;
  25608. private _merge;
  25609. /**
  25610. * The luminance threshold to find bright areas of the image to bloom.
  25611. */
  25612. threshold: number;
  25613. /**
  25614. * The strength of the bloom.
  25615. */
  25616. weight: number;
  25617. /**
  25618. * Specifies the size of the bloom blur kernel, relative to the final output size
  25619. */
  25620. kernel: number;
  25621. /**
  25622. * Creates a new instance of @see BloomEffect
  25623. * @param scene The scene the effect belongs to.
  25624. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  25625. * @param bloomKernel The size of the kernel to be used when applying the blur.
  25626. * @param bloomWeight The the strength of bloom.
  25627. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  25628. * @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)
  25629. */
  25630. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  25631. /**
  25632. * Disposes each of the internal effects for a given camera.
  25633. * @param camera The camera to dispose the effect on.
  25634. */
  25635. disposeEffects(camera: Camera): void;
  25636. /**
  25637. * Internal
  25638. */
  25639. _updateEffects(): void;
  25640. /**
  25641. * Internal
  25642. * @returns if all the contained post processes are ready.
  25643. */
  25644. _isReady(): boolean;
  25645. }
  25646. }
  25647. declare module BABYLON {
  25648. /**
  25649. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  25650. */
  25651. class BloomMergePostProcess extends PostProcess {
  25652. /** Weight of the bloom to be added to the original input. */ weight: number;
  25653. /**
  25654. * Creates a new instance of @see BloomMergePostProcess
  25655. * @param name The name of the effect.
  25656. * @param originalFromInput Post process which's input will be used for the merge.
  25657. * @param blurred Blurred highlights post process which's output will be used.
  25658. * @param weight Weight of the bloom to be added to the original input.
  25659. * @param options The required width/height ratio to downsize to before computing the render pass.
  25660. * @param camera The camera to apply the render pass to.
  25661. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  25662. * @param engine The engine which the post process will be applied. (default: current engine)
  25663. * @param reusable If the post process can be reused on the same frame. (default: false)
  25664. * @param textureType Type of textures used when performing the post process. (default: 0)
  25665. * @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)
  25666. */
  25667. 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);
  25668. }
  25669. }
  25670. declare module BABYLON {
  25671. /**
  25672. * The Blur Post Process which blurs an image based on a kernel and direction.
  25673. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  25674. */
  25675. class BlurPostProcess extends PostProcess {
  25676. /** The direction in which to blur the image. */ direction: Vector2;
  25677. private blockCompilation;
  25678. protected _kernel: number;
  25679. protected _idealKernel: number;
  25680. protected _packedFloat: boolean;
  25681. private _staticDefines;
  25682. /**
  25683. * Gets the length in pixels of the blur sample region
  25684. */
  25685. /**
  25686. * Sets the length in pixels of the blur sample region
  25687. */
  25688. kernel: number;
  25689. /**
  25690. * Gets wether or not the blur is unpacking/repacking floats
  25691. */
  25692. /**
  25693. * Sets wether or not the blur needs to unpack/repack floats
  25694. */
  25695. packedFloat: boolean;
  25696. /**
  25697. * Creates a new instance BlurPostProcess
  25698. * @param name The name of the effect.
  25699. * @param direction The direction in which to blur the image.
  25700. * @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.
  25701. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  25702. * @param camera The camera to apply the render pass to.
  25703. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  25704. * @param engine The engine which the post process will be applied. (default: current engine)
  25705. * @param reusable If the post process can be reused on the same frame. (default: false)
  25706. * @param textureType Type of textures used when performing the post process. (default: 0)
  25707. * @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)
  25708. */
  25709. 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);
  25710. /**
  25711. * Updates the effect with the current post process compile time values and recompiles the shader.
  25712. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  25713. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  25714. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  25715. * @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
  25716. * @param onCompiled Called when the shader has been compiled.
  25717. * @param onError Called if there is an error when compiling a shader.
  25718. */
  25719. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  25720. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  25721. /**
  25722. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  25723. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  25724. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  25725. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  25726. * The gaps between physical kernels are compensated for in the weighting of the samples
  25727. * @param idealKernel Ideal blur kernel.
  25728. * @return Nearest best kernel.
  25729. */
  25730. protected _nearestBestKernel(idealKernel: number): number;
  25731. /**
  25732. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  25733. * @param x The point on the Gaussian distribution to sample.
  25734. * @return the value of the Gaussian function at x.
  25735. */
  25736. protected _gaussianWeight(x: number): number;
  25737. /**
  25738. * Generates a string that can be used as a floating point number in GLSL.
  25739. * @param x Value to print.
  25740. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  25741. * @return GLSL float string.
  25742. */
  25743. protected _glslFloat(x: number, decimalFigures?: number): string;
  25744. }
  25745. }
  25746. declare module BABYLON {
  25747. /**
  25748. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  25749. */
  25750. class ChromaticAberrationPostProcess extends PostProcess {
  25751. /**
  25752. * The amount of seperation of rgb channels (default: 30)
  25753. */
  25754. aberrationAmount: number;
  25755. /**
  25756. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  25757. */
  25758. radialIntensity: number;
  25759. /**
  25760. * 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))
  25761. */
  25762. direction: Vector2;
  25763. /**
  25764. * 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))
  25765. */
  25766. centerPosition: Vector2;
  25767. /**
  25768. * Creates a new instance ChromaticAberrationPostProcess
  25769. * @param name The name of the effect.
  25770. * @param screenWidth The width of the screen to apply the effect on.
  25771. * @param screenHeight The height of the screen to apply the effect on.
  25772. * @param options The required width/height ratio to downsize to before computing the render pass.
  25773. * @param camera The camera to apply the render pass to.
  25774. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  25775. * @param engine The engine which the post process will be applied. (default: current engine)
  25776. * @param reusable If the post process can be reused on the same frame. (default: false)
  25777. * @param textureType Type of textures used when performing the post process. (default: 0)
  25778. * @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)
  25779. */
  25780. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  25781. }
  25782. }
  25783. declare module BABYLON {
  25784. /**
  25785. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  25786. */
  25787. class CircleOfConfusionPostProcess extends PostProcess {
  25788. /**
  25789. * 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.
  25790. */
  25791. lensSize: number;
  25792. /**
  25793. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  25794. */
  25795. fStop: number;
  25796. /**
  25797. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  25798. */
  25799. focusDistance: number;
  25800. /**
  25801. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  25802. */
  25803. focalLength: number;
  25804. private _depthTexture;
  25805. /**
  25806. * Creates a new instance CircleOfConfusionPostProcess
  25807. * @param name The name of the effect.
  25808. * @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.
  25809. * @param options The required width/height ratio to downsize to before computing the render pass.
  25810. * @param camera The camera to apply the render pass to.
  25811. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  25812. * @param engine The engine which the post process will be applied. (default: current engine)
  25813. * @param reusable If the post process can be reused on the same frame. (default: false)
  25814. * @param textureType Type of textures used when performing the post process. (default: 0)
  25815. * @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)
  25816. */
  25817. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  25818. /**
  25819. * 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.
  25820. */
  25821. depthTexture: RenderTargetTexture;
  25822. }
  25823. }
  25824. declare module BABYLON {
  25825. class ColorCorrectionPostProcess extends PostProcess {
  25826. private _colorTableTexture;
  25827. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  25828. }
  25829. }
  25830. declare module BABYLON {
  25831. /**
  25832. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  25833. * input texture to perform effects such as edge detection or sharpening
  25834. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  25835. */
  25836. class ConvolutionPostProcess extends PostProcess {
  25837. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */ kernel: number[];
  25838. /**
  25839. * Creates a new instance ConvolutionPostProcess
  25840. * @param name The name of the effect.
  25841. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  25842. * @param options The required width/height ratio to downsize to before computing the render pass.
  25843. * @param camera The camera to apply the render pass to.
  25844. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  25845. * @param engine The engine which the post process will be applied. (default: current engine)
  25846. * @param reusable If the post process can be reused on the same frame. (default: false)
  25847. * @param textureType Type of textures used when performing the post process. (default: 0)
  25848. */
  25849. 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);
  25850. /**
  25851. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  25852. */
  25853. static EdgeDetect0Kernel: number[];
  25854. /**
  25855. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  25856. */
  25857. static EdgeDetect1Kernel: number[];
  25858. /**
  25859. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  25860. */
  25861. static EdgeDetect2Kernel: number[];
  25862. /**
  25863. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  25864. */
  25865. static SharpenKernel: number[];
  25866. /**
  25867. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  25868. */
  25869. static EmbossKernel: number[];
  25870. /**
  25871. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  25872. */
  25873. static GaussianKernel: number[];
  25874. }
  25875. }
  25876. declare module BABYLON {
  25877. /**
  25878. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  25879. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  25880. * based on samples that have a large difference in distance than the center pixel.
  25881. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  25882. */
  25883. class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  25884. direction: Vector2;
  25885. /**
  25886. * Creates a new instance CircleOfConfusionPostProcess
  25887. * @param name The name of the effect.
  25888. * @param scene The scene the effect belongs to.
  25889. * @param direction The direction the blur should be applied.
  25890. * @param kernel The size of the kernel used to blur.
  25891. * @param options The required width/height ratio to downsize to before computing the render pass.
  25892. * @param camera The camera to apply the render pass to.
  25893. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  25894. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  25895. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  25896. * @param engine The engine which the post process will be applied. (default: current engine)
  25897. * @param reusable If the post process can be reused on the same frame. (default: false)
  25898. * @param textureType Type of textures used when performing the post process. (default: 0)
  25899. * @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)
  25900. */
  25901. 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);
  25902. }
  25903. }
  25904. declare module BABYLON {
  25905. /**
  25906. * Specifies the level of max blur that should be applied when using the depth of field effect
  25907. */
  25908. enum DepthOfFieldEffectBlurLevel {
  25909. /**
  25910. * Subtle blur
  25911. */
  25912. Low = 0,
  25913. /**
  25914. * Medium blur
  25915. */
  25916. Medium = 1,
  25917. /**
  25918. * Large blur
  25919. */
  25920. High = 2,
  25921. }
  25922. /**
  25923. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  25924. */
  25925. class DepthOfFieldEffect extends PostProcessRenderEffect {
  25926. private _circleOfConfusion;
  25927. /**
  25928. * Internal, blurs from high to low
  25929. */
  25930. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  25931. private _depthOfFieldBlurY;
  25932. private _dofMerge;
  25933. /**
  25934. * Internal post processes in depth of field effect
  25935. */
  25936. _effects: Array<PostProcess>;
  25937. /**
  25938. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  25939. */
  25940. focalLength: number;
  25941. /**
  25942. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  25943. */
  25944. fStop: number;
  25945. /**
  25946. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  25947. */
  25948. focusDistance: number;
  25949. /**
  25950. * 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.
  25951. */
  25952. lensSize: number;
  25953. /**
  25954. * Creates a new instance DepthOfFieldEffect
  25955. * @param scene The scene the effect belongs to.
  25956. * @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.
  25957. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  25958. * @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)
  25959. */
  25960. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  25961. /**
  25962. * 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.
  25963. */
  25964. depthTexture: RenderTargetTexture;
  25965. /**
  25966. * Disposes each of the internal effects for a given camera.
  25967. * @param camera The camera to dispose the effect on.
  25968. */
  25969. disposeEffects(camera: Camera): void;
  25970. /**
  25971. * Internal
  25972. */
  25973. _updateEffects(): void;
  25974. /**
  25975. * Internal
  25976. * @returns if all the contained post processes are ready.
  25977. */
  25978. _isReady(): boolean;
  25979. }
  25980. }
  25981. declare module BABYLON {
  25982. /**
  25983. * Options to be set when merging outputs from the default pipeline.
  25984. */
  25985. class DepthOfFieldMergePostProcessOptions {
  25986. /**
  25987. * The original image to merge on top of
  25988. */
  25989. originalFromInput: PostProcess;
  25990. /**
  25991. * Parameters to perform the merge of the depth of field effect
  25992. */
  25993. depthOfField?: {
  25994. circleOfConfusion: PostProcess;
  25995. blurSteps: Array<PostProcess>;
  25996. };
  25997. /**
  25998. * Parameters to perform the merge of bloom effect
  25999. */
  26000. bloom?: {
  26001. blurred: PostProcess;
  26002. weight: number;
  26003. };
  26004. }
  26005. /**
  26006. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  26007. */
  26008. class DepthOfFieldMergePostProcess extends PostProcess {
  26009. private blurSteps;
  26010. /**
  26011. * Creates a new instance of DepthOfFieldMergePostProcess
  26012. * @param name The name of the effect.
  26013. * @param originalFromInput Post process which's input will be used for the merge.
  26014. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  26015. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  26016. * @param options The required width/height ratio to downsize to before computing the render pass.
  26017. * @param camera The camera to apply the render pass to.
  26018. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  26019. * @param engine The engine which the post process will be applied. (default: current engine)
  26020. * @param reusable If the post process can be reused on the same frame. (default: false)
  26021. * @param textureType Type of textures used when performing the post process. (default: 0)
  26022. * @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)
  26023. */
  26024. 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);
  26025. /**
  26026. * Updates the effect with the current post process compile time values and recompiles the shader.
  26027. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  26028. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  26029. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  26030. * @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
  26031. * @param onCompiled Called when the shader has been compiled.
  26032. * @param onError Called if there is an error when compiling a shader.
  26033. */
  26034. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  26035. }
  26036. }
  26037. declare module BABYLON {
  26038. class DisplayPassPostProcess extends PostProcess {
  26039. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  26040. }
  26041. }
  26042. declare module BABYLON {
  26043. /**
  26044. * 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.
  26045. */
  26046. class ExtractHighlightsPostProcess extends PostProcess {
  26047. /**
  26048. * The luminance threshold, pixels below this value will be set to black.
  26049. */
  26050. threshold: number;
  26051. /**
  26052. * Internal
  26053. */
  26054. _exposure: number;
  26055. /**
  26056. * Post process which has the input texture to be used when performing highlight extraction
  26057. */
  26058. _inputPostProcess: Nullable<PostProcess>;
  26059. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  26060. }
  26061. }
  26062. declare module BABYLON {
  26063. class FilterPostProcess extends PostProcess {
  26064. kernelMatrix: Matrix;
  26065. constructor(name: string, kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  26066. }
  26067. }
  26068. declare module BABYLON {
  26069. class FxaaPostProcess extends PostProcess {
  26070. texelWidth: number;
  26071. texelHeight: number;
  26072. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  26073. private _getDefines();
  26074. }
  26075. }
  26076. declare module BABYLON {
  26077. /**
  26078. * The GrainPostProcess adds noise to the image at mid luminance levels
  26079. */
  26080. class GrainPostProcess extends PostProcess {
  26081. /**
  26082. * The intensity of the grain added (default: 30)
  26083. */
  26084. intensity: number;
  26085. /**
  26086. * If the grain should be randomized on every frame
  26087. */
  26088. animated: boolean;
  26089. /**
  26090. * Creates a new instance of @see GrainPostProcess
  26091. * @param name The name of the effect.
  26092. * @param options The required width/height ratio to downsize to before computing the render pass.
  26093. * @param camera The camera to apply the render pass to.
  26094. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  26095. * @param engine The engine which the post process will be applied. (default: current engine)
  26096. * @param reusable If the post process can be reused on the same frame. (default: false)
  26097. * @param textureType Type of textures used when performing the post process. (default: 0)
  26098. * @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)
  26099. */
  26100. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  26101. }
  26102. }
  26103. declare module BABYLON {
  26104. class HighlightsPostProcess extends PostProcess {
  26105. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  26106. }
  26107. }
  26108. declare module BABYLON {
  26109. class ImageProcessingPostProcess extends PostProcess {
  26110. /**
  26111. * Default configuration related to image processing available in the PBR Material.
  26112. */
  26113. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  26114. /**
  26115. * Gets the image processing configuration used either in this material.
  26116. */
  26117. /**
  26118. * Sets the Default image processing configuration used either in the this material.
  26119. *
  26120. * If sets to null, the scene one is in use.
  26121. */
  26122. imageProcessingConfiguration: ImageProcessingConfiguration;
  26123. /**
  26124. * Keep track of the image processing observer to allow dispose and replace.
  26125. */
  26126. private _imageProcessingObserver;
  26127. /**
  26128. * Attaches a new image processing configuration to the PBR Material.
  26129. * @param configuration
  26130. */
  26131. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  26132. /**
  26133. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  26134. */
  26135. /**
  26136. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  26137. */
  26138. colorCurves: Nullable<ColorCurves>;
  26139. /**
  26140. * Gets wether the color curves effect is enabled.
  26141. */
  26142. /**
  26143. * Sets wether the color curves effect is enabled.
  26144. */
  26145. colorCurvesEnabled: boolean;
  26146. /**
  26147. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  26148. */
  26149. /**
  26150. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  26151. */
  26152. colorGradingTexture: Nullable<BaseTexture>;
  26153. /**
  26154. * Gets wether the color grading effect is enabled.
  26155. */
  26156. /**
  26157. * Gets wether the color grading effect is enabled.
  26158. */
  26159. colorGradingEnabled: boolean;
  26160. /**
  26161. * Gets exposure used in the effect.
  26162. */
  26163. /**
  26164. * Sets exposure used in the effect.
  26165. */
  26166. exposure: number;
  26167. /**
  26168. * Gets wether tonemapping is enabled or not.
  26169. */
  26170. /**
  26171. * Sets wether tonemapping is enabled or not
  26172. */
  26173. toneMappingEnabled: boolean;
  26174. /**
  26175. * Gets contrast used in the effect.
  26176. */
  26177. /**
  26178. * Sets contrast used in the effect.
  26179. */
  26180. contrast: number;
  26181. /**
  26182. * Gets Vignette stretch size.
  26183. */
  26184. /**
  26185. * Sets Vignette stretch size.
  26186. */
  26187. vignetteStretch: number;
  26188. /**
  26189. * Gets Vignette centre X Offset.
  26190. */
  26191. /**
  26192. * Sets Vignette centre X Offset.
  26193. */
  26194. vignetteCentreX: number;
  26195. /**
  26196. * Gets Vignette centre Y Offset.
  26197. */
  26198. /**
  26199. * Sets Vignette centre Y Offset.
  26200. */
  26201. vignetteCentreY: number;
  26202. /**
  26203. * Gets Vignette weight or intensity of the vignette effect.
  26204. */
  26205. /**
  26206. * Sets Vignette weight or intensity of the vignette effect.
  26207. */
  26208. vignetteWeight: number;
  26209. /**
  26210. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  26211. * if vignetteEnabled is set to true.
  26212. */
  26213. /**
  26214. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  26215. * if vignetteEnabled is set to true.
  26216. */
  26217. vignetteColor: Color4;
  26218. /**
  26219. * Gets Camera field of view used by the Vignette effect.
  26220. */
  26221. /**
  26222. * Sets Camera field of view used by the Vignette effect.
  26223. */
  26224. vignetteCameraFov: number;
  26225. /**
  26226. * Gets the vignette blend mode allowing different kind of effect.
  26227. */
  26228. /**
  26229. * Sets the vignette blend mode allowing different kind of effect.
  26230. */
  26231. vignetteBlendMode: number;
  26232. /**
  26233. * Gets wether the vignette effect is enabled.
  26234. */
  26235. /**
  26236. * Sets wether the vignette effect is enabled.
  26237. */
  26238. vignetteEnabled: boolean;
  26239. private _fromLinearSpace;
  26240. /**
  26241. * Gets wether the input of the processing is in Gamma or Linear Space.
  26242. */
  26243. /**
  26244. * Sets wether the input of the processing is in Gamma or Linear Space.
  26245. */
  26246. fromLinearSpace: boolean;
  26247. /**
  26248. * Defines cache preventing GC.
  26249. */
  26250. private _defines;
  26251. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  26252. getClassName(): string;
  26253. protected _updateParameters(): void;
  26254. dispose(camera?: Camera): void;
  26255. }
  26256. }
  26257. declare module BABYLON {
  26258. class PassPostProcess extends PostProcess {
  26259. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  26260. }
  26261. }
  26262. declare module BABYLON {
  26263. type PostProcessOptions = {
  26264. width: number;
  26265. height: number;
  26266. };
  26267. /**
  26268. * PostProcess can be used to apply a shader to a texture after it has been rendered
  26269. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  26270. */
  26271. class PostProcess {
  26272. /** Name of the PostProcess. */ name: string;
  26273. /**
  26274. * Width of the texture to apply the post process on
  26275. */
  26276. width: number;
  26277. /**
  26278. * Height of the texture to apply the post process on
  26279. */
  26280. height: number;
  26281. /**
  26282. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  26283. */
  26284. _outputTexture: Nullable<InternalTexture>;
  26285. /**
  26286. * Sampling mode used by the shader
  26287. * See https://doc.babylonjs.com/classes/3.1/texture
  26288. */
  26289. renderTargetSamplingMode: number;
  26290. /**
  26291. * Clear color to use when screen clearing
  26292. */
  26293. clearColor: Color4;
  26294. /**
  26295. * If the buffer needs to be cleared before applying the post process. (default: true)
  26296. * Should be set to false if shader will overwrite all previous pixels.
  26297. */
  26298. autoClear: boolean;
  26299. /**
  26300. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  26301. */
  26302. alphaMode: number;
  26303. /**
  26304. * Sets the setAlphaBlendConstants of the babylon engine
  26305. */
  26306. alphaConstants: Color4;
  26307. /**
  26308. * Animations to be used for the post processing
  26309. */
  26310. animations: Animation[];
  26311. /**
  26312. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  26313. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  26314. */
  26315. enablePixelPerfectMode: boolean;
  26316. /**
  26317. * Force the postprocess to be applied without taking in account viewport
  26318. */
  26319. forceFullscreenViewport: boolean;
  26320. /**
  26321. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  26322. */
  26323. scaleMode: number;
  26324. /**
  26325. * Force textures to be a power of two (default: false)
  26326. */
  26327. alwaysForcePOT: boolean;
  26328. /**
  26329. * Number of sample textures (default: 1)
  26330. */
  26331. samples: number;
  26332. /**
  26333. * Modify the scale of the post process to be the same as the viewport (default: false)
  26334. */
  26335. adaptScaleToCurrentViewport: boolean;
  26336. private _camera;
  26337. private _scene;
  26338. private _engine;
  26339. private _options;
  26340. private _reusable;
  26341. private _textureType;
  26342. /**
  26343. * Smart array of input and output textures for the post process.
  26344. */
  26345. _textures: SmartArray<InternalTexture>;
  26346. /**
  26347. * The index in _textures that corresponds to the output texture.
  26348. */
  26349. _currentRenderTextureInd: number;
  26350. private _effect;
  26351. private _samplers;
  26352. private _fragmentUrl;
  26353. private _vertexUrl;
  26354. private _parameters;
  26355. private _scaleRatio;
  26356. protected _indexParameters: any;
  26357. private _shareOutputWithPostProcess;
  26358. private _texelSize;
  26359. private _forcedOutputTexture;
  26360. /**
  26361. * An event triggered when the postprocess is activated.
  26362. */
  26363. onActivateObservable: Observable<Camera>;
  26364. private _onActivateObserver;
  26365. /**
  26366. * A function that is added to the onActivateObservable
  26367. */
  26368. onActivate: Nullable<(camera: Camera) => void>;
  26369. /**
  26370. * An event triggered when the postprocess changes its size.
  26371. */
  26372. onSizeChangedObservable: Observable<PostProcess>;
  26373. private _onSizeChangedObserver;
  26374. /**
  26375. * A function that is added to the onSizeChangedObservable
  26376. */
  26377. onSizeChanged: (postProcess: PostProcess) => void;
  26378. /**
  26379. * An event triggered when the postprocess applies its effect.
  26380. */
  26381. onApplyObservable: Observable<Effect>;
  26382. private _onApplyObserver;
  26383. /**
  26384. * A function that is added to the onApplyObservable
  26385. */
  26386. onApply: (effect: Effect) => void;
  26387. /**
  26388. * An event triggered before rendering the postprocess
  26389. */
  26390. onBeforeRenderObservable: Observable<Effect>;
  26391. private _onBeforeRenderObserver;
  26392. /**
  26393. * A function that is added to the onBeforeRenderObservable
  26394. */
  26395. onBeforeRender: (effect: Effect) => void;
  26396. /**
  26397. * An event triggered after rendering the postprocess
  26398. */
  26399. onAfterRenderObservable: Observable<Effect>;
  26400. private _onAfterRenderObserver;
  26401. /**
  26402. * A function that is added to the onAfterRenderObservable
  26403. */
  26404. onAfterRender: (efect: Effect) => void;
  26405. /**
  26406. * 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
  26407. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  26408. */
  26409. inputTexture: InternalTexture;
  26410. /**
  26411. * Gets the camera which post process is applied to.
  26412. * @returns The camera the post process is applied to.
  26413. */
  26414. getCamera(): Camera;
  26415. /**
  26416. * Gets the texel size of the postprocess.
  26417. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  26418. */
  26419. readonly texelSize: Vector2;
  26420. /**
  26421. * Creates a new instance PostProcess
  26422. * @param name The name of the PostProcess.
  26423. * @param fragmentUrl The url of the fragment shader to be used.
  26424. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  26425. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  26426. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  26427. * @param camera The camera to apply the render pass to.
  26428. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  26429. * @param engine The engine which the post process will be applied. (default: current engine)
  26430. * @param reusable If the post process can be reused on the same frame. (default: false)
  26431. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  26432. * @param textureType Type of textures used when performing the post process. (default: 0)
  26433. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  26434. * @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
  26435. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  26436. */
  26437. 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);
  26438. /**
  26439. * Gets the engine which this post process belongs to.
  26440. * @returns The engine the post process was enabled with.
  26441. */
  26442. getEngine(): Engine;
  26443. /**
  26444. * The effect that is created when initializing the post process.
  26445. * @returns The created effect corrisponding the the postprocess.
  26446. */
  26447. getEffect(): Effect;
  26448. /**
  26449. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  26450. * @param postProcess The post process to share the output with.
  26451. * @returns This post process.
  26452. */
  26453. shareOutputWith(postProcess: PostProcess): PostProcess;
  26454. /**
  26455. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  26456. * This should be called if the post process that shares output with this post process is disabled/disposed.
  26457. */
  26458. useOwnOutput(): void;
  26459. /**
  26460. * Updates the effect with the current post process compile time values and recompiles the shader.
  26461. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  26462. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  26463. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  26464. * @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
  26465. * @param onCompiled Called when the shader has been compiled.
  26466. * @param onError Called if there is an error when compiling a shader.
  26467. */
  26468. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  26469. /**
  26470. * The post process is reusable if it can be used multiple times within one frame.
  26471. * @returns If the post process is reusable
  26472. */
  26473. isReusable(): boolean;
  26474. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  26475. markTextureDirty(): void;
  26476. /**
  26477. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  26478. * 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.
  26479. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  26480. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  26481. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  26482. * @returns The target texture that was bound to be written to.
  26483. */
  26484. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  26485. /**
  26486. * If the post process is supported.
  26487. */
  26488. readonly isSupported: boolean;
  26489. /**
  26490. * The aspect ratio of the output texture.
  26491. */
  26492. readonly aspectRatio: number;
  26493. /**
  26494. * Get a value indicating if the post-process is ready to be used
  26495. * @returns true if the post-process is ready (shader is compiled)
  26496. */
  26497. isReady(): boolean;
  26498. /**
  26499. * Binds all textures and uniforms to the shader, this will be run on every pass.
  26500. * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
  26501. */
  26502. apply(): Nullable<Effect>;
  26503. private _disposeTextures();
  26504. /**
  26505. * Disposes the post process.
  26506. * @param camera The camera to dispose the post process on.
  26507. */
  26508. dispose(camera?: Camera): void;
  26509. }
  26510. }
  26511. declare module BABYLON {
  26512. /**
  26513. * PostProcessManager is used to manage one or more post processes or post process pipelines
  26514. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  26515. */
  26516. class PostProcessManager {
  26517. private _scene;
  26518. private _indexBuffer;
  26519. private _vertexBuffers;
  26520. /**
  26521. * Creates a new instance PostProcess
  26522. * @param scene The scene that the post process is associated with.
  26523. */
  26524. constructor(scene: Scene);
  26525. private _prepareBuffers();
  26526. private _buildIndexBuffer();
  26527. /**
  26528. * Rebuilds the vertex buffers of the manager.
  26529. */
  26530. _rebuild(): void;
  26531. /**
  26532. * Prepares a frame to be run through a post process.
  26533. * @param sourceTexture The input texture to the post procesess. (default: null)
  26534. * @param postProcesses An array of post processes to be run. (default: null)
  26535. * @returns True if the post processes were able to be run.
  26536. */
  26537. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  26538. /**
  26539. * Manually render a set of post processes to a texture.
  26540. * @param postProcesses An array of post processes to be run.
  26541. * @param targetTexture The target texture to render to.
  26542. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  26543. */
  26544. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean): void;
  26545. /**
  26546. * Finalize the result of the output of the postprocesses.
  26547. * @param doNotPresent If true the result will not be displayed to the screen.
  26548. * @param targetTexture The target texture to render to.
  26549. * @param faceIndex The index of the face to bind the target texture to.
  26550. * @param postProcesses The array of post processes to render.
  26551. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  26552. */
  26553. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  26554. /**
  26555. * Disposes of the post process manager.
  26556. */
  26557. dispose(): void;
  26558. }
  26559. }
  26560. declare module BABYLON {
  26561. class RefractionPostProcess extends PostProcess {
  26562. color: Color3;
  26563. depth: number;
  26564. colorLevel: number;
  26565. private _refTexture;
  26566. private _ownRefractionTexture;
  26567. /**
  26568. * Gets or sets the refraction texture
  26569. * Please note that you are responsible for disposing the texture if you set it manually
  26570. */
  26571. refractionTexture: Texture;
  26572. constructor(name: string, refractionTextureUrl: string, color: Color3, depth: number, colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  26573. dispose(camera: Camera): void;
  26574. }
  26575. }
  26576. declare module BABYLON {
  26577. /**
  26578. * The SharpenPostProcess applies a sharpen kernel to every pixel
  26579. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  26580. */
  26581. class SharpenPostProcess extends PostProcess {
  26582. /**
  26583. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  26584. */
  26585. colorAmount: number;
  26586. /**
  26587. * How much sharpness should be applied (default: 0.3)
  26588. */
  26589. edgeAmount: number;
  26590. /**
  26591. * Creates a new instance ConvolutionPostProcess
  26592. * @param name The name of the effect.
  26593. * @param options The required width/height ratio to downsize to before computing the render pass.
  26594. * @param camera The camera to apply the render pass to.
  26595. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  26596. * @param engine The engine which the post process will be applied. (default: current engine)
  26597. * @param reusable If the post process can be reused on the same frame. (default: false)
  26598. * @param textureType Type of textures used when performing the post process. (default: 0)
  26599. * @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)
  26600. */
  26601. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  26602. }
  26603. }
  26604. declare module BABYLON {
  26605. class StereoscopicInterlacePostProcess extends PostProcess {
  26606. private _stepSize;
  26607. private _passedProcess;
  26608. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  26609. }
  26610. }
  26611. declare module BABYLON {
  26612. /** Defines operator used for tonemapping */
  26613. enum TonemappingOperator {
  26614. /** Hable */
  26615. Hable = 0,
  26616. /** Reinhard */
  26617. Reinhard = 1,
  26618. /** HejiDawson */
  26619. HejiDawson = 2,
  26620. /** Photographic */
  26621. Photographic = 3,
  26622. }
  26623. /**
  26624. * Defines a post process to apply tone mapping
  26625. */
  26626. class TonemapPostProcess extends PostProcess {
  26627. private _operator;
  26628. /** Defines the required exposure adjustement */
  26629. exposureAdjustment: number;
  26630. /**
  26631. * Creates a new TonemapPostProcess
  26632. * @param name defines the name of the postprocess
  26633. * @param _operator defines the operator to use
  26634. * @param exposureAdjustment defines the required exposure adjustement
  26635. * @param camera defines the camera to use (can be null)
  26636. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  26637. * @param engine defines the hosting engine (can be ignore if camera is set)
  26638. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  26639. */
  26640. constructor(name: string, _operator: TonemappingOperator,
  26641. /** Defines the required exposure adjustement */
  26642. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  26643. }
  26644. }
  26645. declare module BABYLON {
  26646. class VolumetricLightScatteringPostProcess extends PostProcess {
  26647. private _volumetricLightScatteringPass;
  26648. private _volumetricLightScatteringRTT;
  26649. private _viewPort;
  26650. private _screenCoordinates;
  26651. private _cachedDefines;
  26652. /**
  26653. * If not undefined, the mesh position is computed from the attached node position
  26654. */
  26655. attachedNode: {
  26656. position: Vector3;
  26657. };
  26658. /**
  26659. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  26660. */
  26661. customMeshPosition: Vector3;
  26662. /**
  26663. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  26664. */
  26665. useCustomMeshPosition: boolean;
  26666. /**
  26667. * If the post-process should inverse the light scattering direction
  26668. */
  26669. invert: boolean;
  26670. /**
  26671. * The internal mesh used by the post-process
  26672. */
  26673. mesh: Mesh;
  26674. useDiffuseColor: boolean;
  26675. /**
  26676. * Array containing the excluded meshes not rendered in the internal pass
  26677. */
  26678. excludedMeshes: AbstractMesh[];
  26679. /**
  26680. * Controls the overall intensity of the post-process
  26681. */
  26682. exposure: number;
  26683. /**
  26684. * Dissipates each sample's contribution in range [0, 1]
  26685. */
  26686. decay: number;
  26687. /**
  26688. * Controls the overall intensity of each sample
  26689. */
  26690. weight: number;
  26691. /**
  26692. * Controls the density of each sample
  26693. */
  26694. density: number;
  26695. /**
  26696. * @constructor
  26697. * @param {string} name - The post-process name
  26698. * @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)
  26699. * @param {BABYLON.Camera} camera - The camera that the post-process will be attached to
  26700. * @param {BABYLON.Mesh} mesh - The mesh used to create the light scattering
  26701. * @param {number} samples - The post-process quality, default 100
  26702. * @param {number} samplingMode - The post-process filtering mode
  26703. * @param {BABYLON.Engine} engine - The babylon engine
  26704. * @param {boolean} reusable - If the post-process is reusable
  26705. * @param {BABYLON.Scene} scene - The constructor needs a scene reference to initialize internal components. If "camera" is null (RenderPipelineà, "scene" must be provided
  26706. */
  26707. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  26708. getClassName(): string;
  26709. private _isReady(subMesh, useInstances);
  26710. /**
  26711. * Sets the new light position for light scattering effect
  26712. * @param {BABYLON.Vector3} The new custom light position
  26713. */
  26714. setCustomMeshPosition(position: Vector3): void;
  26715. /**
  26716. * Returns the light position for light scattering effect
  26717. * @return {BABYLON.Vector3} The custom light position
  26718. */
  26719. getCustomMeshPosition(): Vector3;
  26720. /**
  26721. * Disposes the internal assets and detaches the post-process from the camera
  26722. */
  26723. dispose(camera: Camera): void;
  26724. /**
  26725. * Returns the render target texture used by the post-process
  26726. * @return {BABYLON.RenderTargetTexture} The render target texture used by the post-process
  26727. */
  26728. getPass(): RenderTargetTexture;
  26729. private _meshExcluded(mesh);
  26730. private _createPass(scene, ratio);
  26731. private _updateMeshScreenCoordinates(scene);
  26732. /**
  26733. * Creates a default mesh for the Volumeric Light Scattering post-process
  26734. * @param {string} The mesh name
  26735. * @param {BABYLON.Scene} The scene where to create the mesh
  26736. * @return {BABYLON.Mesh} the default mesh
  26737. */
  26738. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  26739. }
  26740. }
  26741. declare module BABYLON {
  26742. class VRDistortionCorrectionPostProcess extends PostProcess {
  26743. private _isRightEye;
  26744. private _distortionFactors;
  26745. private _postProcessScaleFactor;
  26746. private _lensCenterOffset;
  26747. private _scaleIn;
  26748. private _scaleFactor;
  26749. private _lensCenter;
  26750. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  26751. }
  26752. }
  26753. declare module BABYLON {
  26754. class Sprite {
  26755. name: string;
  26756. position: Vector3;
  26757. color: Color4;
  26758. width: number;
  26759. height: number;
  26760. angle: number;
  26761. cellIndex: number;
  26762. invertU: number;
  26763. invertV: number;
  26764. disposeWhenFinishedAnimating: boolean;
  26765. animations: Animation[];
  26766. isPickable: boolean;
  26767. actionManager: ActionManager;
  26768. private _animationStarted;
  26769. private _loopAnimation;
  26770. private _fromIndex;
  26771. private _toIndex;
  26772. private _delay;
  26773. private _direction;
  26774. private _manager;
  26775. private _time;
  26776. private _onAnimationEnd;
  26777. size: number;
  26778. constructor(name: string, manager: SpriteManager);
  26779. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  26780. stopAnimation(): void;
  26781. _animate(deltaTime: number): void;
  26782. dispose(): void;
  26783. }
  26784. }
  26785. declare module BABYLON {
  26786. class SpriteManager {
  26787. name: string;
  26788. sprites: Sprite[];
  26789. renderingGroupId: number;
  26790. layerMask: number;
  26791. fogEnabled: boolean;
  26792. isPickable: boolean;
  26793. cellWidth: number;
  26794. cellHeight: number;
  26795. /**
  26796. * An event triggered when the manager is disposed.
  26797. */
  26798. onDisposeObservable: Observable<SpriteManager>;
  26799. private _onDisposeObserver;
  26800. onDispose: () => void;
  26801. private _capacity;
  26802. private _spriteTexture;
  26803. private _epsilon;
  26804. private _scene;
  26805. private _vertexData;
  26806. private _buffer;
  26807. private _vertexBuffers;
  26808. private _indexBuffer;
  26809. private _effectBase;
  26810. private _effectFog;
  26811. texture: Texture;
  26812. constructor(name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  26813. private _appendSpriteVertex(index, sprite, offsetX, offsetY, rowSize);
  26814. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  26815. render(): void;
  26816. dispose(): void;
  26817. }
  26818. }
  26819. declare module BABYLON {
  26820. /**
  26821. * @hidden
  26822. **/
  26823. class _AlphaState {
  26824. private _isAlphaBlendDirty;
  26825. private _isBlendFunctionParametersDirty;
  26826. private _isBlendEquationParametersDirty;
  26827. private _isBlendConstantsDirty;
  26828. private _alphaBlend;
  26829. private _blendFunctionParameters;
  26830. private _blendEquationParameters;
  26831. private _blendConstants;
  26832. /**
  26833. * Initializes the state.
  26834. */
  26835. constructor();
  26836. readonly isDirty: boolean;
  26837. alphaBlend: boolean;
  26838. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  26839. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  26840. setAlphaEquationParameters(rgb: number, alpha: number): void;
  26841. reset(): void;
  26842. apply(gl: WebGLRenderingContext): void;
  26843. }
  26844. }
  26845. declare module BABYLON {
  26846. /**
  26847. * @hidden
  26848. **/
  26849. class _DepthCullingState {
  26850. private _isDepthTestDirty;
  26851. private _isDepthMaskDirty;
  26852. private _isDepthFuncDirty;
  26853. private _isCullFaceDirty;
  26854. private _isCullDirty;
  26855. private _isZOffsetDirty;
  26856. private _isFrontFaceDirty;
  26857. private _depthTest;
  26858. private _depthMask;
  26859. private _depthFunc;
  26860. private _cull;
  26861. private _cullFace;
  26862. private _zOffset;
  26863. private _frontFace;
  26864. /**
  26865. * Initializes the state.
  26866. */
  26867. constructor();
  26868. readonly isDirty: boolean;
  26869. zOffset: number;
  26870. cullFace: Nullable<number>;
  26871. cull: Nullable<boolean>;
  26872. depthFunc: Nullable<number>;
  26873. depthMask: boolean;
  26874. depthTest: boolean;
  26875. frontFace: Nullable<number>;
  26876. reset(): void;
  26877. apply(gl: WebGLRenderingContext): void;
  26878. }
  26879. }
  26880. declare module BABYLON {
  26881. /**
  26882. * @hidden
  26883. **/
  26884. class _StencilState {
  26885. private _isStencilTestDirty;
  26886. private _isStencilMaskDirty;
  26887. private _isStencilFuncDirty;
  26888. private _isStencilOpDirty;
  26889. private _stencilTest;
  26890. private _stencilMask;
  26891. private _stencilFunc;
  26892. private _stencilFuncRef;
  26893. private _stencilFuncMask;
  26894. private _stencilOpStencilFail;
  26895. private _stencilOpDepthFail;
  26896. private _stencilOpStencilDepthPass;
  26897. readonly isDirty: boolean;
  26898. stencilFunc: number;
  26899. stencilFuncRef: number;
  26900. stencilFuncMask: number;
  26901. stencilOpStencilFail: number;
  26902. stencilOpDepthFail: number;
  26903. stencilOpStencilDepthPass: number;
  26904. stencilMask: number;
  26905. stencilTest: boolean;
  26906. constructor();
  26907. reset(): void;
  26908. apply(gl: WebGLRenderingContext): void;
  26909. }
  26910. }
  26911. declare module BABYLON {
  26912. /**
  26913. * Class used to evalaute queries containing `and` and `or` operators
  26914. */
  26915. class AndOrNotEvaluator {
  26916. /**
  26917. * Evaluate a query
  26918. * @param query defines the query to evaluate
  26919. * @param evaluateCallback defines the callback used to filter result
  26920. * @returns true if the query matches
  26921. */
  26922. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  26923. private static _HandleParenthesisContent(parenthesisContent, evaluateCallback);
  26924. private static _SimplifyNegation(booleanString);
  26925. }
  26926. }
  26927. declare module BABYLON {
  26928. /**
  26929. * Defines the list of states available for a task inside a {BABYLON.AssetsManager}
  26930. */
  26931. enum AssetTaskState {
  26932. /**
  26933. * Initialization
  26934. */
  26935. INIT = 0,
  26936. /**
  26937. * Running
  26938. */
  26939. RUNNING = 1,
  26940. /**
  26941. * Done
  26942. */
  26943. DONE = 2,
  26944. /**
  26945. * Error
  26946. */
  26947. ERROR = 3,
  26948. }
  26949. /**
  26950. * Define an abstract asset task used with a {BABYLON.AssetsManager} class to load assets into a scene
  26951. */
  26952. abstract class AbstractAssetTask {
  26953. /**
  26954. * Task name
  26955. */ name: string;
  26956. /**
  26957. * Callback called when the task is successful
  26958. */
  26959. onSuccess: (task: any) => void;
  26960. /**
  26961. * Callback called when the task is not successful
  26962. */
  26963. onError: (task: any, message?: string, exception?: any) => void;
  26964. /**
  26965. * Creates a new {BABYLON.AssetsManager}
  26966. * @param name defines the name of the task
  26967. */
  26968. constructor(
  26969. /**
  26970. * Task name
  26971. */ name: string);
  26972. private _isCompleted;
  26973. private _taskState;
  26974. private _errorObject;
  26975. /**
  26976. * Get if the task is completed
  26977. */
  26978. readonly isCompleted: boolean;
  26979. /**
  26980. * Gets the current state of the task
  26981. */
  26982. readonly taskState: AssetTaskState;
  26983. /**
  26984. * Gets the current error object (if task is in error)
  26985. */
  26986. readonly errorObject: {
  26987. message?: string;
  26988. exception?: any;
  26989. };
  26990. /**
  26991. * Internal only
  26992. * @hidden
  26993. */
  26994. _setErrorObject(message?: string, exception?: any): void;
  26995. /**
  26996. * Execute the current task
  26997. * @param scene defines the scene where you want your assets to be loaded
  26998. * @param onSuccess is a callback called when the task is successfully executed
  26999. * @param onError is a callback called if an error occurs
  27000. */
  27001. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  27002. /**
  27003. * Execute the current task
  27004. * @param scene defines the scene where you want your assets to be loaded
  27005. * @param onSuccess is a callback called when the task is successfully executed
  27006. * @param onError is a callback called if an error occurs
  27007. */
  27008. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  27009. private onErrorCallback(onError, message?, exception?);
  27010. private onDoneCallback(onSuccess, onError);
  27011. }
  27012. /**
  27013. * Define the interface used by progress events raised during assets loading
  27014. */
  27015. interface IAssetsProgressEvent {
  27016. /**
  27017. * Defines the number of remaining tasks to process
  27018. */
  27019. remainingCount: number;
  27020. /**
  27021. * Defines the total number of tasks
  27022. */
  27023. totalCount: number;
  27024. /**
  27025. * Defines the task that was just processed
  27026. */
  27027. task: AbstractAssetTask;
  27028. }
  27029. /**
  27030. * Class used to share progress information about assets loading
  27031. */
  27032. class AssetsProgressEvent implements IAssetsProgressEvent {
  27033. /**
  27034. * Defines the number of remaining tasks to process
  27035. */
  27036. remainingCount: number;
  27037. /**
  27038. * Defines the total number of tasks
  27039. */
  27040. totalCount: number;
  27041. /**
  27042. * Defines the task that was just processed
  27043. */
  27044. task: AbstractAssetTask;
  27045. /**
  27046. * Creates a {BABYLON.AssetsProgressEvent}
  27047. * @param remainingCount defines the number of remaining tasks to process
  27048. * @param totalCount defines the total number of tasks
  27049. * @param task defines the task that was just processed
  27050. */
  27051. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  27052. }
  27053. /**
  27054. * Define a task used by {BABYLON.AssetsManager} to load meshes
  27055. */
  27056. class MeshAssetTask extends AbstractAssetTask {
  27057. /**
  27058. * Defines the name of the task
  27059. */
  27060. name: string;
  27061. /**
  27062. * Defines the list of mesh's names you want to load
  27063. */
  27064. meshesNames: any;
  27065. /**
  27066. * Defines the root url to use as a base to load your meshes and associated resources
  27067. */
  27068. rootUrl: string;
  27069. /**
  27070. * Defines the filename of the scene to load from
  27071. */
  27072. sceneFilename: string;
  27073. /**
  27074. * Gets the list of loaded meshes
  27075. */
  27076. loadedMeshes: Array<AbstractMesh>;
  27077. /**
  27078. * Gets the list of loaded particle systems
  27079. */
  27080. loadedParticleSystems: Array<ParticleSystem>;
  27081. /**
  27082. * Gets the list of loaded skeletons
  27083. */
  27084. loadedSkeletons: Array<Skeleton>;
  27085. /**
  27086. * Callback called when the task is successful
  27087. */
  27088. onSuccess: (task: MeshAssetTask) => void;
  27089. /**
  27090. * Callback called when the task is successful
  27091. */
  27092. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  27093. /**
  27094. * Creates a new {BABYLON.MeshAssetTask}
  27095. * @param name defines the name of the task
  27096. * @param meshesNames defines the list of mesh's names you want to load
  27097. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  27098. * @param sceneFilename defines the filename of the scene to load from
  27099. */
  27100. constructor(
  27101. /**
  27102. * Defines the name of the task
  27103. */
  27104. name: string,
  27105. /**
  27106. * Defines the list of mesh's names you want to load
  27107. */
  27108. meshesNames: any,
  27109. /**
  27110. * Defines the root url to use as a base to load your meshes and associated resources
  27111. */
  27112. rootUrl: string,
  27113. /**
  27114. * Defines the filename of the scene to load from
  27115. */
  27116. sceneFilename: string);
  27117. /**
  27118. * Execute the current task
  27119. * @param scene defines the scene where you want your assets to be loaded
  27120. * @param onSuccess is a callback called when the task is successfully executed
  27121. * @param onError is a callback called if an error occurs
  27122. */
  27123. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  27124. }
  27125. /**
  27126. * Define a task used by {BABYLON.AssetsManager} to load text content
  27127. */
  27128. class TextFileAssetTask extends AbstractAssetTask {
  27129. /**
  27130. * Defines the name of the task
  27131. */
  27132. name: string;
  27133. /**
  27134. * Defines the location of the file to load
  27135. */
  27136. url: string;
  27137. /**
  27138. * Gets the loaded text string
  27139. */
  27140. text: string;
  27141. /**
  27142. * Callback called when the task is successful
  27143. */
  27144. onSuccess: (task: TextFileAssetTask) => void;
  27145. /**
  27146. * Callback called when the task is successful
  27147. */
  27148. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  27149. /**
  27150. * Creates a new TextFileAssetTask object
  27151. * @param name defines the name of the task
  27152. * @param url defines the location of the file to load
  27153. */
  27154. constructor(
  27155. /**
  27156. * Defines the name of the task
  27157. */
  27158. name: string,
  27159. /**
  27160. * Defines the location of the file to load
  27161. */
  27162. url: string);
  27163. /**
  27164. * Execute the current task
  27165. * @param scene defines the scene where you want your assets to be loaded
  27166. * @param onSuccess is a callback called when the task is successfully executed
  27167. * @param onError is a callback called if an error occurs
  27168. */
  27169. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  27170. }
  27171. /**
  27172. * Define a task used by {BABYLON.AssetsManager} to load binary data
  27173. */
  27174. class BinaryFileAssetTask extends AbstractAssetTask {
  27175. /**
  27176. * Defines the name of the task
  27177. */
  27178. name: string;
  27179. /**
  27180. * Defines the location of the file to load
  27181. */
  27182. url: string;
  27183. /**
  27184. * Gets the lodaded data (as an array buffer)
  27185. */
  27186. data: ArrayBuffer;
  27187. /**
  27188. * Callback called when the task is successful
  27189. */
  27190. onSuccess: (task: BinaryFileAssetTask) => void;
  27191. /**
  27192. * Callback called when the task is successful
  27193. */
  27194. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  27195. /**
  27196. * Creates a new BinaryFileAssetTask object
  27197. * @param name defines the name of the new task
  27198. * @param url defines the location of the file to load
  27199. */
  27200. constructor(
  27201. /**
  27202. * Defines the name of the task
  27203. */
  27204. name: string,
  27205. /**
  27206. * Defines the location of the file to load
  27207. */
  27208. url: string);
  27209. /**
  27210. * Execute the current task
  27211. * @param scene defines the scene where you want your assets to be loaded
  27212. * @param onSuccess is a callback called when the task is successfully executed
  27213. * @param onError is a callback called if an error occurs
  27214. */
  27215. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  27216. }
  27217. /**
  27218. * Define a task used by {BABYLON.AssetsManager} to load images
  27219. */
  27220. class ImageAssetTask extends AbstractAssetTask {
  27221. /**
  27222. * Defines the name of the task
  27223. */
  27224. name: string;
  27225. /**
  27226. * Defines the location of the image to load
  27227. */
  27228. url: string;
  27229. /**
  27230. * Gets the loaded images
  27231. */
  27232. image: HTMLImageElement;
  27233. /**
  27234. * Callback called when the task is successful
  27235. */
  27236. onSuccess: (task: ImageAssetTask) => void;
  27237. /**
  27238. * Callback called when the task is successful
  27239. */
  27240. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  27241. /**
  27242. * Creates a new ImageAssetTask
  27243. * @param name defines the name of the task
  27244. * @param url defines the location of the image to load
  27245. */
  27246. constructor(
  27247. /**
  27248. * Defines the name of the task
  27249. */
  27250. name: string,
  27251. /**
  27252. * Defines the location of the image to load
  27253. */
  27254. url: string);
  27255. /**
  27256. * Execute the current task
  27257. * @param scene defines the scene where you want your assets to be loaded
  27258. * @param onSuccess is a callback called when the task is successfully executed
  27259. * @param onError is a callback called if an error occurs
  27260. */
  27261. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  27262. }
  27263. /**
  27264. * Defines the interface used by texture loading tasks
  27265. */
  27266. interface ITextureAssetTask<TEX extends BaseTexture> {
  27267. /**
  27268. * Gets the loaded texture
  27269. */
  27270. texture: TEX;
  27271. }
  27272. /**
  27273. * Define a task used by {BABYLON.AssetsManager} to load 2D textures
  27274. */
  27275. class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  27276. /**
  27277. * Defines the name of the task
  27278. */
  27279. name: string;
  27280. /**
  27281. * Defines the location of the file to load
  27282. */
  27283. url: string;
  27284. /**
  27285. * Defines if mipmap should not be generated (default is false)
  27286. */
  27287. noMipmap: boolean | undefined;
  27288. /**
  27289. * Defines if texture must be inverted on Y axis (default is false)
  27290. */
  27291. invertY: boolean | undefined;
  27292. /**
  27293. * Defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  27294. */
  27295. samplingMode: number;
  27296. /**
  27297. * Gets the loaded texture
  27298. */
  27299. texture: Texture;
  27300. /**
  27301. * Callback called when the task is successful
  27302. */
  27303. onSuccess: (task: TextureAssetTask) => void;
  27304. /**
  27305. * Callback called when the task is successful
  27306. */
  27307. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  27308. /**
  27309. * Creates a new TextureAssetTask object
  27310. * @param name defines the name of the task
  27311. * @param url defines the location of the file to load
  27312. * @param noMipmap defines if mipmap should not be generated (default is false)
  27313. * @param invertY defines if texture must be inverted on Y axis (default is false)
  27314. * @param samplingMode defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  27315. */
  27316. constructor(
  27317. /**
  27318. * Defines the name of the task
  27319. */
  27320. name: string,
  27321. /**
  27322. * Defines the location of the file to load
  27323. */
  27324. url: string,
  27325. /**
  27326. * Defines if mipmap should not be generated (default is false)
  27327. */
  27328. noMipmap?: boolean | undefined,
  27329. /**
  27330. * Defines if texture must be inverted on Y axis (default is false)
  27331. */
  27332. invertY?: boolean | undefined,
  27333. /**
  27334. * Defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  27335. */
  27336. samplingMode?: number);
  27337. /**
  27338. * Execute the current task
  27339. * @param scene defines the scene where you want your assets to be loaded
  27340. * @param onSuccess is a callback called when the task is successfully executed
  27341. * @param onError is a callback called if an error occurs
  27342. */
  27343. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  27344. }
  27345. /**
  27346. * Define a task used by {BABYLON.AssetsManager} to load cube textures
  27347. */
  27348. class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  27349. /**
  27350. * Defines the name of the task
  27351. */
  27352. name: string;
  27353. /**
  27354. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  27355. */
  27356. url: string;
  27357. /**
  27358. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  27359. */
  27360. extensions: string[] | undefined;
  27361. /**
  27362. * Defines if mipmaps should not be generated (default is false)
  27363. */
  27364. noMipmap: boolean | undefined;
  27365. /**
  27366. * Defines the explicit list of files (undefined by default)
  27367. */
  27368. files: string[] | undefined;
  27369. /**
  27370. * Gets the loaded texture
  27371. */
  27372. texture: CubeTexture;
  27373. /**
  27374. * Callback called when the task is successful
  27375. */
  27376. onSuccess: (task: CubeTextureAssetTask) => void;
  27377. /**
  27378. * Callback called when the task is successful
  27379. */
  27380. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  27381. /**
  27382. * Creates a new CubeTextureAssetTask
  27383. * @param name defines the name of the task
  27384. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  27385. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  27386. * @param noMipmap defines if mipmaps should not be generated (default is false)
  27387. * @param files defines the explicit list of files (undefined by default)
  27388. */
  27389. constructor(
  27390. /**
  27391. * Defines the name of the task
  27392. */
  27393. name: string,
  27394. /**
  27395. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  27396. */
  27397. url: string,
  27398. /**
  27399. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  27400. */
  27401. extensions?: string[] | undefined,
  27402. /**
  27403. * Defines if mipmaps should not be generated (default is false)
  27404. */
  27405. noMipmap?: boolean | undefined,
  27406. /**
  27407. * Defines the explicit list of files (undefined by default)
  27408. */
  27409. files?: string[] | undefined);
  27410. /**
  27411. * Execute the current task
  27412. * @param scene defines the scene where you want your assets to be loaded
  27413. * @param onSuccess is a callback called when the task is successfully executed
  27414. * @param onError is a callback called if an error occurs
  27415. */
  27416. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  27417. }
  27418. /**
  27419. * Define a task used by {BABYLON.AssetsManager} to load HDR cube textures
  27420. */
  27421. class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  27422. /**
  27423. * Defines the name of the task
  27424. */
  27425. name: string;
  27426. /**
  27427. * Defines the location of the file to load
  27428. */
  27429. url: string;
  27430. /**
  27431. * Defines the desired size (the more it increases the longer the generation will be)
  27432. */
  27433. size: number;
  27434. /**
  27435. * Defines if mipmaps should not be generated (default is false)
  27436. */
  27437. noMipmap: boolean;
  27438. /**
  27439. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  27440. */
  27441. generateHarmonics: boolean;
  27442. /**
  27443. * 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)
  27444. */
  27445. gammaSpace: boolean;
  27446. /**
  27447. * Internal Use Only
  27448. */
  27449. reserved: boolean;
  27450. /**
  27451. * Gets the loaded texture
  27452. */
  27453. texture: HDRCubeTexture;
  27454. /**
  27455. * Callback called when the task is successful
  27456. */
  27457. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  27458. /**
  27459. * Callback called when the task is successful
  27460. */
  27461. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  27462. /**
  27463. * Creates a new HDRCubeTextureAssetTask object
  27464. * @param name defines the name of the task
  27465. * @param url defines the location of the file to load
  27466. * @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.
  27467. * @param noMipmap defines if mipmaps should not be generated (default is false)
  27468. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  27469. * @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)
  27470. * @param reserved Internal use only
  27471. */
  27472. constructor(
  27473. /**
  27474. * Defines the name of the task
  27475. */
  27476. name: string,
  27477. /**
  27478. * Defines the location of the file to load
  27479. */
  27480. url: string,
  27481. /**
  27482. * Defines the desired size (the more it increases the longer the generation will be)
  27483. */
  27484. size: number,
  27485. /**
  27486. * Defines if mipmaps should not be generated (default is false)
  27487. */
  27488. noMipmap?: boolean,
  27489. /**
  27490. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  27491. */
  27492. generateHarmonics?: boolean,
  27493. /**
  27494. * 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)
  27495. */
  27496. gammaSpace?: boolean,
  27497. /**
  27498. * Internal Use Only
  27499. */
  27500. reserved?: boolean);
  27501. /**
  27502. * Execute the current task
  27503. * @param scene defines the scene where you want your assets to be loaded
  27504. * @param onSuccess is a callback called when the task is successfully executed
  27505. * @param onError is a callback called if an error occurs
  27506. */
  27507. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  27508. }
  27509. /**
  27510. * This class can be used to easily import assets into a scene
  27511. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  27512. */
  27513. class AssetsManager {
  27514. private _scene;
  27515. private _isLoading;
  27516. protected _tasks: AbstractAssetTask[];
  27517. protected _waitingTasksCount: number;
  27518. protected _totalTasksCount: number;
  27519. /**
  27520. * Callback called when all tasks are processed
  27521. */
  27522. onFinish: (tasks: AbstractAssetTask[]) => void;
  27523. /**
  27524. * Callback called when a task is successful
  27525. */
  27526. onTaskSuccess: (task: AbstractAssetTask) => void;
  27527. /**
  27528. * Callback called when a task had an error
  27529. */
  27530. onTaskError: (task: AbstractAssetTask) => void;
  27531. /**
  27532. * Callback called when a task is done (whatever the result is)
  27533. */
  27534. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  27535. /**
  27536. * Observable called when all tasks are processed
  27537. */
  27538. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  27539. /**
  27540. * Observable called when a task had an error
  27541. */
  27542. onTaskErrorObservable: Observable<AbstractAssetTask>;
  27543. /**
  27544. * Observable called when a task is successful
  27545. */
  27546. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  27547. /**
  27548. * Observable called when a task is done (whatever the result is)
  27549. */
  27550. onProgressObservable: Observable<IAssetsProgressEvent>;
  27551. /**
  27552. * Gets or sets a boolean defining if the {BABYLON.AssetsManager} should use the default loading screen
  27553. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  27554. */
  27555. useDefaultLoadingScreen: boolean;
  27556. /**
  27557. * Creates a new AssetsManager
  27558. * @param scene defines the scene to work on
  27559. */
  27560. constructor(scene: Scene);
  27561. /**
  27562. * Add a {BABYLON.MeshAssetTask} to the list of active tasks
  27563. * @param taskName defines the name of the new task
  27564. * @param meshesNames defines the name of meshes to load
  27565. * @param rootUrl defines the root url to use to locate files
  27566. * @param sceneFilename defines the filename of the scene file
  27567. * @returns a new {BABYLON.MeshAssetTask} object
  27568. */
  27569. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  27570. /**
  27571. * Add a {BABYLON.TextFileAssetTask} to the list of active tasks
  27572. * @param taskName defines the name of the new task
  27573. * @param url defines the url of the file to load
  27574. * @returns a new {BABYLON.TextFileAssetTask} object
  27575. */
  27576. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  27577. /**
  27578. * Add a {BABYLON.BinaryFileAssetTask} to the list of active tasks
  27579. * @param taskName defines the name of the new task
  27580. * @param url defines the url of the file to load
  27581. * @returns a new {BABYLON.BinaryFileAssetTask} object
  27582. */
  27583. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  27584. /**
  27585. * Add a {BABYLON.ImageAssetTask} to the list of active tasks
  27586. * @param taskName defines the name of the new task
  27587. * @param url defines the url of the file to load
  27588. * @returns a new {BABYLON.ImageAssetTask} object
  27589. */
  27590. addImageTask(taskName: string, url: string): ImageAssetTask;
  27591. /**
  27592. * Add a {BABYLON.TextureAssetTask} to the list of active tasks
  27593. * @param taskName defines the name of the new task
  27594. * @param url defines the url of the file to load
  27595. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  27596. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  27597. * @param samplingMode defines the sampling mode to use (BABYLON.Texture.TRILINEAR_SAMPLINGMODE by default)
  27598. * @returns a new {BABYLON.TextureAssetTask} object
  27599. */
  27600. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  27601. /**
  27602. * Add a {BABYLON.CubeTextureAssetTask} to the list of active tasks
  27603. * @param taskName defines the name of the new task
  27604. * @param url defines the url of the file to load
  27605. * @param extensions defines the extension to use to load the cube map (can be null)
  27606. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  27607. * @param files defines the list of files to load (can be null)
  27608. * @returns a new {BABYLON.CubeTextureAssetTask} object
  27609. */
  27610. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  27611. /**
  27612. *
  27613. * Add a {BABYLON.HDRCubeTextureAssetTask} to the list of active tasks
  27614. * @param taskName defines the name of the new task
  27615. * @param url defines the url of the file to load
  27616. * @param size defines the size you want for the cubemap (can be null)
  27617. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  27618. * @param generateHarmonics defines if you want to automatically generate (true by default)
  27619. * @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)
  27620. * @param reserved Internal use only
  27621. * @returns a new {BABYLON.HDRCubeTextureAssetTask} object
  27622. */
  27623. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  27624. private _decreaseWaitingTasksCount(task);
  27625. private _runTask(task);
  27626. /**
  27627. * Reset the {BABYLON.AssetsManager} and remove all tasks
  27628. * @return the current instance of the {BABYLON.AssetsManager}
  27629. */
  27630. reset(): AssetsManager;
  27631. /**
  27632. * Start the loading process
  27633. * @return the current instance of the {BABYLON.AssetsManager}
  27634. */
  27635. load(): AssetsManager;
  27636. }
  27637. }
  27638. declare module BABYLON {
  27639. /**
  27640. * Class used to enable access to IndexedDB
  27641. * @see @https://developer.mozilla.org/en-US/docs/Web/API/IndexedDB_API
  27642. */
  27643. class Database {
  27644. private callbackManifestChecked;
  27645. private currentSceneUrl;
  27646. private db;
  27647. private _enableSceneOffline;
  27648. private _enableTexturesOffline;
  27649. private manifestVersionFound;
  27650. private mustUpdateRessources;
  27651. private hasReachedQuota;
  27652. private isSupported;
  27653. private idbFactory;
  27654. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  27655. static IsUASupportingBlobStorage: boolean;
  27656. /** Gets a boolean indicating if Database storate is enabled */
  27657. static IDBStorageEnabled: boolean;
  27658. /**
  27659. * Gets a boolean indicating if scene must be saved in the database
  27660. */
  27661. readonly enableSceneOffline: boolean;
  27662. /**
  27663. * Gets a boolean indicating if textures must be saved in the database
  27664. */
  27665. readonly enableTexturesOffline: boolean;
  27666. /**
  27667. * Creates a new Database
  27668. * @param urlToScene defines the url to load the scene
  27669. * @param callbackManifestChecked defines the callback to use when manifest is checked
  27670. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  27671. */
  27672. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  27673. private static _ParseURL;
  27674. private static _ReturnFullUrlLocation;
  27675. private _checkManifestFile();
  27676. /**
  27677. * Open the database and make it available
  27678. * @param successCallback defines the callback to call on success
  27679. * @param errorCallback defines the callback to call on error
  27680. */
  27681. openAsync(successCallback: () => void, errorCallback: () => void): void;
  27682. /**
  27683. * Loads an image from the database
  27684. * @param url defines the url to load from
  27685. * @param image defines the target DOM image
  27686. */
  27687. loadImageFromDB(url: string, image: HTMLImageElement): void;
  27688. private _loadImageFromDBAsync(url, image, notInDBCallback);
  27689. private _saveImageIntoDBAsync(url, image);
  27690. private _checkVersionFromDB(url, versionLoaded);
  27691. private _loadVersionFromDBAsync(url, callback, updateInDBCallback);
  27692. private _saveVersionIntoDBAsync(url, callback);
  27693. /**
  27694. * Loads a file from database
  27695. * @param url defines the URL to load from
  27696. * @param sceneLoaded defines a callback to call on success
  27697. * @param progressCallBack defines a callback to call when progress changed
  27698. * @param errorCallback defines a callback to call on error
  27699. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  27700. */
  27701. loadFileFromDB(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  27702. private _loadFileFromDBAsync(url, callback, notInDBCallback, useArrayBuffer?);
  27703. private _saveFileIntoDBAsync(url, callback, progressCallback?, useArrayBuffer?);
  27704. }
  27705. }
  27706. declare module BABYLON {
  27707. interface DDSInfo {
  27708. width: number;
  27709. height: number;
  27710. mipmapCount: number;
  27711. isFourCC: boolean;
  27712. isRGB: boolean;
  27713. isLuminance: boolean;
  27714. isCube: boolean;
  27715. isCompressed: boolean;
  27716. dxgiFormat: number;
  27717. textureType: number;
  27718. /** Sphericle polynomial created for the dds texture */
  27719. sphericalPolynomial?: SphericalPolynomial;
  27720. }
  27721. class DDSTools {
  27722. static StoreLODInAlphaChannel: boolean;
  27723. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  27724. private static _FloatView;
  27725. private static _Int32View;
  27726. private static _ToHalfFloat(value);
  27727. private static _FromHalfFloat(value);
  27728. private static _GetHalfFloatAsFloatRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, lod);
  27729. private static _GetHalfFloatRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, lod);
  27730. private static _GetFloatRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, lod);
  27731. private static _GetFloatAsUIntRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, lod);
  27732. private static _GetHalfFloatAsUIntRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, lod);
  27733. private static _GetRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, rOffset, gOffset, bOffset, aOffset);
  27734. private static _ExtractLongWordOrder(value);
  27735. private static _GetRGBArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, rOffset, gOffset, bOffset);
  27736. private static _GetLuminanceArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer);
  27737. static UploadDDSLevels(engine: Engine, gl: WebGLRenderingContext, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  27738. }
  27739. }
  27740. declare module BABYLON {
  27741. function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  27742. function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27743. function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27744. function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27745. function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27746. function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27747. function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27748. function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27749. function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27750. function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27751. function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27752. function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27753. /**
  27754. * Decorator used to define property that can be serialized as reference to a camera
  27755. * @param sourceName defines the name of the property to decorate
  27756. */
  27757. function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27758. class SerializationHelper {
  27759. static Serialize<T>(entity: T, serializationObject?: any): any;
  27760. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  27761. static Clone<T>(creationFunction: () => T, source: T): T;
  27762. static Instanciate<T>(creationFunction: () => T, source: T): T;
  27763. }
  27764. }
  27765. declare module BABYLON {
  27766. /**
  27767. * Wrapper class for promise with external resolve and reject.
  27768. */
  27769. class Deferred<T> {
  27770. /**
  27771. * The promise associated with this deferred object.
  27772. */
  27773. readonly promise: Promise<T>;
  27774. private _resolve;
  27775. private _reject;
  27776. /**
  27777. * The resolve method of the promise associated with this deferred object.
  27778. */
  27779. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  27780. /**
  27781. * The reject method of the promise associated with this deferred object.
  27782. */
  27783. readonly reject: (reason?: any) => void;
  27784. /**
  27785. * Constructor for this deferred object.
  27786. */
  27787. constructor();
  27788. }
  27789. }
  27790. declare module BABYLON {
  27791. class FilesInput {
  27792. static FilesToLoad: {
  27793. [key: string]: File;
  27794. };
  27795. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  27796. private _engine;
  27797. private _currentScene;
  27798. private _sceneLoadedCallback;
  27799. private _progressCallback;
  27800. private _additionalRenderLoopLogicCallback;
  27801. private _textureLoadingCallback;
  27802. private _startingProcessingFilesCallback;
  27803. private _onReloadCallback;
  27804. private _errorCallback;
  27805. private _elementToMonitor;
  27806. private _sceneFileToLoad;
  27807. private _filesToLoad;
  27808. 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);
  27809. private _dragEnterHandler;
  27810. private _dragOverHandler;
  27811. private _dropHandler;
  27812. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  27813. dispose(): void;
  27814. private renderFunction();
  27815. private drag(e);
  27816. private drop(eventDrop);
  27817. private _traverseFolder(folder, files, remaining, callback);
  27818. private _processFiles(files);
  27819. loadFiles(event: any): void;
  27820. private _processReload();
  27821. reload(): void;
  27822. }
  27823. }
  27824. declare module BABYLON {
  27825. /**
  27826. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  27827. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  27828. */
  27829. class KhronosTextureContainer {
  27830. arrayBuffer: any;
  27831. static HEADER_LEN: number;
  27832. static COMPRESSED_2D: number;
  27833. static COMPRESSED_3D: number;
  27834. static TEX_2D: number;
  27835. static TEX_3D: number;
  27836. glType: number;
  27837. glTypeSize: number;
  27838. glFormat: number;
  27839. glInternalFormat: number;
  27840. glBaseInternalFormat: number;
  27841. pixelWidth: number;
  27842. pixelHeight: number;
  27843. pixelDepth: number;
  27844. numberOfArrayElements: number;
  27845. numberOfFaces: number;
  27846. numberOfMipmapLevels: number;
  27847. bytesOfKeyValueData: number;
  27848. loadType: number;
  27849. /**
  27850. * @param {ArrayBuffer} arrayBuffer- contents of the KTX container file
  27851. * @param {number} facesExpected- should be either 1 or 6, based whether a cube texture or or
  27852. * @param {boolean} threeDExpected- provision for indicating that data should be a 3D texture, not implemented
  27853. * @param {boolean} textureArrayExpected- provision for indicating that data should be a texture array, not implemented
  27854. */
  27855. constructor(arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  27856. switchEndainness(val: number): number;
  27857. /**
  27858. * It is assumed that the texture has already been created & is currently bound
  27859. */
  27860. uploadLevels(gl: WebGLRenderingContext, loadMipmaps: boolean): void;
  27861. private _upload2DCompressedLevels(gl, loadMipmaps);
  27862. }
  27863. }
  27864. declare module BABYLON {
  27865. /**
  27866. * A class serves as a medium between the observable and its observers
  27867. */
  27868. class EventState {
  27869. /**
  27870. * Create a new EventState
  27871. * @param mask defines the mask associated with this state
  27872. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  27873. * @param target defines the original target of the state
  27874. * @param currentTarget defines the current target of the state
  27875. */
  27876. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  27877. /**
  27878. * Initialize the current event state
  27879. * @param mask defines the mask associated with this state
  27880. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  27881. * @param target defines the original target of the state
  27882. * @param currentTarget defines the current target of the state
  27883. * @returns the current event state
  27884. */
  27885. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  27886. /**
  27887. * An Observer can set this property to true to prevent subsequent observers of being notified
  27888. */
  27889. skipNextObservers: boolean;
  27890. /**
  27891. * Get the mask value that were used to trigger the event corresponding to this EventState object
  27892. */
  27893. mask: number;
  27894. /**
  27895. * The object that originally notified the event
  27896. */
  27897. target?: any;
  27898. /**
  27899. * The current object in the bubbling phase
  27900. */
  27901. currentTarget?: any;
  27902. /**
  27903. * This will be populated with the return value of the last function that was executed.
  27904. * If it is the first function in the callback chain it will be the event data.
  27905. */
  27906. lastReturnValue?: any;
  27907. }
  27908. /**
  27909. * Represent an Observer registered to a given Observable object.
  27910. */
  27911. class Observer<T> {
  27912. /**
  27913. * Defines the callback to call when the observer is notified
  27914. */
  27915. callback: (eventData: T, eventState: EventState) => void;
  27916. /**
  27917. * Defines the mask of the observer (used to filter notifications)
  27918. */
  27919. mask: number;
  27920. /**
  27921. * Defines the current scope used to restore the JS context
  27922. */
  27923. scope: any;
  27924. /** @hidden */
  27925. _willBeUnregistered: boolean;
  27926. /**
  27927. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  27928. */
  27929. unregisterOnNextCall: boolean;
  27930. /**
  27931. * Creates a new observer
  27932. * @param callback defines the callback to call when the observer is notified
  27933. * @param mask defines the mask of the observer (used to filter notifications)
  27934. * @param scope defines the current scope used to restore the JS context
  27935. */
  27936. constructor(
  27937. /**
  27938. * Defines the callback to call when the observer is notified
  27939. */
  27940. callback: (eventData: T, eventState: EventState) => void,
  27941. /**
  27942. * Defines the mask of the observer (used to filter notifications)
  27943. */
  27944. mask: number,
  27945. /**
  27946. * Defines the current scope used to restore the JS context
  27947. */
  27948. scope?: any);
  27949. }
  27950. /**
  27951. * Represent a list of observers registered to multiple Observables object.
  27952. */
  27953. class MultiObserver<T> {
  27954. private _observers;
  27955. private _observables;
  27956. /**
  27957. * Release associated resources
  27958. */
  27959. dispose(): void;
  27960. /**
  27961. * Raise a callback when one of the observable will notify
  27962. * @param observables defines a list of observables to watch
  27963. * @param callback defines the callback to call on notification
  27964. * @param mask defines the mask used to filter notifications
  27965. * @param scope defines the current scope used to restore the JS context
  27966. * @returns the new MultiObserver
  27967. */
  27968. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  27969. }
  27970. /**
  27971. * The Observable class is a simple implementation of the Observable pattern.
  27972. *
  27973. * 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.
  27974. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  27975. * 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).
  27976. * 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.
  27977. */
  27978. class Observable<T> {
  27979. private _observers;
  27980. private _eventState;
  27981. private _onObserverAdded;
  27982. /**
  27983. * Creates a new observable
  27984. * @param onObserverAdded defines a callback to call when a new observer is added
  27985. */
  27986. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  27987. /**
  27988. * Create a new Observer with the specified callback
  27989. * @param callback the callback that will be executed for that Observer
  27990. * @param mask the mask used to filter observers
  27991. * @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.
  27992. * @param scope optional scope for the callback to be called from
  27993. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  27994. * @returns the new observer created for the callback
  27995. */
  27996. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  27997. /**
  27998. * Create a new Observer with the specified callback and unregisters after the next notification
  27999. * @param callback the callback that will be executed for that Observer
  28000. * @returns the new observer created for the callback
  28001. */
  28002. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  28003. /**
  28004. * Remove an Observer from the Observable object
  28005. * @param observer the instance of the Observer to remove
  28006. * @returns false if it doesn't belong to this Observable
  28007. */
  28008. remove(observer: Nullable<Observer<T>>): boolean;
  28009. /**
  28010. * Remove a callback from the Observable object
  28011. * @param callback the callback to remove
  28012. * @param scope optional scope. If used only the callbacks with this scope will be removed
  28013. * @returns false if it doesn't belong to this Observable
  28014. */
  28015. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  28016. private _deferUnregister(observer);
  28017. /**
  28018. * Notify all Observers by calling their respective callback with the given data
  28019. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  28020. * @param eventData defines the data to send to all observers
  28021. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  28022. * @param target defines the original target of the state
  28023. * @param currentTarget defines the current target of the state
  28024. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  28025. */
  28026. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  28027. /**
  28028. * Calling this will execute each callback, expecting it to be a promise or return a value.
  28029. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  28030. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  28031. * and it is crucial that all callbacks will be executed.
  28032. * The order of the callbacks is kept, callbacks are not executed parallel.
  28033. *
  28034. * @param eventData The data to be sent to each callback
  28035. * @param mask is used to filter observers defaults to -1
  28036. * @param target defines the callback target (see EventState)
  28037. * @param currentTarget defines he current object in the bubbling phase
  28038. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  28039. */
  28040. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  28041. /**
  28042. * Notify a specific observer
  28043. * @param observer defines the observer to notify
  28044. * @param eventData defines the data to be sent to each callback
  28045. * @param mask is used to filter observers defaults to -1
  28046. */
  28047. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  28048. /**
  28049. * Gets a boolean indicating if the observable has at least one observer
  28050. * @returns true is the Observable has at least one Observer registered
  28051. */
  28052. hasObservers(): boolean;
  28053. /**
  28054. * Clear the list of observers
  28055. */
  28056. clear(): void;
  28057. /**
  28058. * Clone the current observable
  28059. * @returns a new observable
  28060. */
  28061. clone(): Observable<T>;
  28062. /**
  28063. * Does this observable handles observer registered with a given mask
  28064. * @param mask defines the mask to be tested
  28065. * @return whether or not one observer registered with the given mask is handeled
  28066. **/
  28067. hasSpecificMask(mask?: number): boolean;
  28068. }
  28069. }
  28070. declare module BABYLON {
  28071. /**
  28072. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  28073. */
  28074. class PerformanceMonitor {
  28075. private _enabled;
  28076. private _rollingFrameTime;
  28077. private _lastFrameTimeMs;
  28078. /**
  28079. * constructor
  28080. * @param frameSampleSize The number of samples required to saturate the sliding window
  28081. */
  28082. constructor(frameSampleSize?: number);
  28083. /**
  28084. * Samples current frame
  28085. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  28086. */
  28087. sampleFrame(timeMs?: number): void;
  28088. /**
  28089. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  28090. * @return Average frame time in milliseconds
  28091. */
  28092. readonly averageFrameTime: number;
  28093. /**
  28094. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  28095. * @return Frame time variance in milliseconds squared
  28096. */
  28097. readonly averageFrameTimeVariance: number;
  28098. /**
  28099. * Returns the frame time of the most recent frame
  28100. * @return Frame time in milliseconds
  28101. */
  28102. readonly instantaneousFrameTime: number;
  28103. /**
  28104. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  28105. * @return Framerate in frames per second
  28106. */
  28107. readonly averageFPS: number;
  28108. /**
  28109. * Returns the average framerate in frames per second using the most recent frame time
  28110. * @return Framerate in frames per second
  28111. */
  28112. readonly instantaneousFPS: number;
  28113. /**
  28114. * Returns true if enough samples have been taken to completely fill the sliding window
  28115. * @return true if saturated
  28116. */
  28117. readonly isSaturated: boolean;
  28118. /**
  28119. * Enables contributions to the sliding window sample set
  28120. */
  28121. enable(): void;
  28122. /**
  28123. * Disables contributions to the sliding window sample set
  28124. * Samples will not be interpolated over the disabled period
  28125. */
  28126. disable(): void;
  28127. /**
  28128. * Returns true if sampling is enabled
  28129. * @return true if enabled
  28130. */
  28131. readonly isEnabled: boolean;
  28132. /**
  28133. * Resets performance monitor
  28134. */
  28135. reset(): void;
  28136. }
  28137. /**
  28138. * RollingAverage
  28139. *
  28140. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  28141. */
  28142. class RollingAverage {
  28143. /**
  28144. * Current average
  28145. */
  28146. average: number;
  28147. /**
  28148. * Current variance
  28149. */
  28150. variance: number;
  28151. protected _samples: Array<number>;
  28152. protected _sampleCount: number;
  28153. protected _pos: number;
  28154. protected _m2: number;
  28155. /**
  28156. * constructor
  28157. * @param length The number of samples required to saturate the sliding window
  28158. */
  28159. constructor(length: number);
  28160. /**
  28161. * Adds a sample to the sample set
  28162. * @param v The sample value
  28163. */
  28164. add(v: number): void;
  28165. /**
  28166. * Returns previously added values or null if outside of history or outside the sliding window domain
  28167. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  28168. * @return Value previously recorded with add() or null if outside of range
  28169. */
  28170. history(i: number): number;
  28171. /**
  28172. * Returns true if enough samples have been taken to completely fill the sliding window
  28173. * @return true if sample-set saturated
  28174. */
  28175. isSaturated(): boolean;
  28176. /**
  28177. * Resets the rolling average (equivalent to 0 samples taken so far)
  28178. */
  28179. reset(): void;
  28180. /**
  28181. * Wraps a value around the sample range boundaries
  28182. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  28183. * @return Wrapped position in sample range
  28184. */
  28185. protected _wrapPosition(i: number): number;
  28186. }
  28187. }
  28188. declare module BABYLON {
  28189. /**
  28190. * Helper class that provides a small promise polyfill
  28191. */
  28192. class PromisePolyfill {
  28193. /**
  28194. * Static function used to check if the polyfill is required
  28195. * If this is the case then the function will inject the polyfill to window.Promise
  28196. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  28197. */
  28198. static Apply(force?: boolean): void;
  28199. }
  28200. }
  28201. declare module BABYLON {
  28202. /**
  28203. * Defines the root class used to create scene optimization to use with SceneOptimizer
  28204. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  28205. */
  28206. class SceneOptimization {
  28207. /**
  28208. * Defines the priority of this optimization (0 by default which means first in the list)
  28209. */
  28210. priority: number;
  28211. /**
  28212. * Gets a string describing the action executed by the current optimization
  28213. * @returns description string
  28214. */
  28215. getDescription(): string;
  28216. /**
  28217. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  28218. * @param scene defines the current scene where to apply this optimization
  28219. * @param optimizer defines the current optimizer
  28220. * @returns true if everything that can be done was applied
  28221. */
  28222. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  28223. /**
  28224. * Creates the SceneOptimization object
  28225. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  28226. * @param desc defines the description associated with the optimization
  28227. */
  28228. constructor(
  28229. /**
  28230. * Defines the priority of this optimization (0 by default which means first in the list)
  28231. */
  28232. priority?: number);
  28233. }
  28234. /**
  28235. * Defines an optimization used to reduce the size of render target textures
  28236. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  28237. */
  28238. class TextureOptimization extends SceneOptimization {
  28239. /**
  28240. * Defines the priority of this optimization (0 by default which means first in the list)
  28241. */
  28242. priority: number;
  28243. /**
  28244. * 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
  28245. */
  28246. maximumSize: number;
  28247. /**
  28248. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  28249. */
  28250. step: number;
  28251. /**
  28252. * Gets a string describing the action executed by the current optimization
  28253. * @returns description string
  28254. */
  28255. getDescription(): string;
  28256. /**
  28257. * Creates the TextureOptimization object
  28258. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  28259. * @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
  28260. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  28261. */
  28262. constructor(
  28263. /**
  28264. * Defines the priority of this optimization (0 by default which means first in the list)
  28265. */
  28266. priority?: number,
  28267. /**
  28268. * 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
  28269. */
  28270. maximumSize?: number,
  28271. /**
  28272. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  28273. */
  28274. step?: number);
  28275. /**
  28276. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  28277. * @param scene defines the current scene where to apply this optimization
  28278. * @param optimizer defines the current optimizer
  28279. * @returns true if everything that can be done was applied
  28280. */
  28281. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  28282. }
  28283. /**
  28284. * Defines an optimization used to increase or decrease the rendering resolution
  28285. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  28286. */
  28287. class HardwareScalingOptimization extends SceneOptimization {
  28288. /**
  28289. * Defines the priority of this optimization (0 by default which means first in the list)
  28290. */
  28291. priority: number;
  28292. /**
  28293. * Defines the maximum scale to use (2 by default)
  28294. */
  28295. maximumScale: number;
  28296. /**
  28297. * Defines the step to use between two passes (0.5 by default)
  28298. */
  28299. step: number;
  28300. private _currentScale;
  28301. private _directionOffset;
  28302. /**
  28303. * Gets a string describing the action executed by the current optimization
  28304. * @return description string
  28305. */
  28306. getDescription(): string;
  28307. /**
  28308. * Creates the HardwareScalingOptimization object
  28309. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  28310. * @param maximumScale defines the maximum scale to use (2 by default)
  28311. * @param step defines the step to use between two passes (0.5 by default)
  28312. */
  28313. constructor(
  28314. /**
  28315. * Defines the priority of this optimization (0 by default which means first in the list)
  28316. */
  28317. priority?: number,
  28318. /**
  28319. * Defines the maximum scale to use (2 by default)
  28320. */
  28321. maximumScale?: number,
  28322. /**
  28323. * Defines the step to use between two passes (0.5 by default)
  28324. */
  28325. step?: number);
  28326. /**
  28327. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  28328. * @param scene defines the current scene where to apply this optimization
  28329. * @param optimizer defines the current optimizer
  28330. * @returns true if everything that can be done was applied
  28331. */
  28332. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  28333. }
  28334. /**
  28335. * Defines an optimization used to remove shadows
  28336. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  28337. */
  28338. class ShadowsOptimization extends SceneOptimization {
  28339. /**
  28340. * Gets a string describing the action executed by the current optimization
  28341. * @return description string
  28342. */
  28343. getDescription(): string;
  28344. /**
  28345. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  28346. * @param scene defines the current scene where to apply this optimization
  28347. * @param optimizer defines the current optimizer
  28348. * @returns true if everything that can be done was applied
  28349. */
  28350. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  28351. }
  28352. /**
  28353. * Defines an optimization used to turn post-processes off
  28354. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  28355. */
  28356. class PostProcessesOptimization extends SceneOptimization {
  28357. /**
  28358. * Gets a string describing the action executed by the current optimization
  28359. * @return description string
  28360. */
  28361. getDescription(): string;
  28362. /**
  28363. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  28364. * @param scene defines the current scene where to apply this optimization
  28365. * @param optimizer defines the current optimizer
  28366. * @returns true if everything that can be done was applied
  28367. */
  28368. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  28369. }
  28370. /**
  28371. * Defines an optimization used to turn lens flares off
  28372. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  28373. */
  28374. class LensFlaresOptimization extends SceneOptimization {
  28375. /**
  28376. * Gets a string describing the action executed by the current optimization
  28377. * @return description string
  28378. */
  28379. getDescription(): string;
  28380. /**
  28381. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  28382. * @param scene defines the current scene where to apply this optimization
  28383. * @param optimizer defines the current optimizer
  28384. * @returns true if everything that can be done was applied
  28385. */
  28386. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  28387. }
  28388. /**
  28389. * Defines an optimization based on user defined callback.
  28390. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  28391. */
  28392. class CustomOptimization extends SceneOptimization {
  28393. /**
  28394. * Callback called to apply the custom optimization.
  28395. */
  28396. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  28397. /**
  28398. * Callback called to get custom description
  28399. */
  28400. onGetDescription: () => string;
  28401. /**
  28402. * Gets a string describing the action executed by the current optimization
  28403. * @returns description string
  28404. */
  28405. getDescription(): string;
  28406. /**
  28407. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  28408. * @param scene defines the current scene where to apply this optimization
  28409. * @param optimizer defines the current optimizer
  28410. * @returns true if everything that can be done was applied
  28411. */
  28412. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  28413. }
  28414. /**
  28415. * Defines an optimization used to turn particles off
  28416. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  28417. */
  28418. class ParticlesOptimization extends SceneOptimization {
  28419. /**
  28420. * Gets a string describing the action executed by the current optimization
  28421. * @return description string
  28422. */
  28423. getDescription(): string;
  28424. /**
  28425. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  28426. * @param scene defines the current scene where to apply this optimization
  28427. * @param optimizer defines the current optimizer
  28428. * @returns true if everything that can be done was applied
  28429. */
  28430. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  28431. }
  28432. /**
  28433. * Defines an optimization used to turn render targets off
  28434. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  28435. */
  28436. class RenderTargetsOptimization extends SceneOptimization {
  28437. /**
  28438. * Gets a string describing the action executed by the current optimization
  28439. * @return description string
  28440. */
  28441. getDescription(): string;
  28442. /**
  28443. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  28444. * @param scene defines the current scene where to apply this optimization
  28445. * @param optimizer defines the current optimizer
  28446. * @returns true if everything that can be done was applied
  28447. */
  28448. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  28449. }
  28450. /**
  28451. * Defines an optimization used to merge meshes with compatible materials
  28452. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  28453. */
  28454. class MergeMeshesOptimization extends SceneOptimization {
  28455. private static _UpdateSelectionTree;
  28456. /**
  28457. * Gets or sets a boolean which defines if optimization octree has to be updated
  28458. */
  28459. /**
  28460. * Gets or sets a boolean which defines if optimization octree has to be updated
  28461. */
  28462. static UpdateSelectionTree: boolean;
  28463. /**
  28464. * Gets a string describing the action executed by the current optimization
  28465. * @return description string
  28466. */
  28467. getDescription(): string;
  28468. private _canBeMerged;
  28469. /**
  28470. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  28471. * @param scene defines the current scene where to apply this optimization
  28472. * @param optimizer defines the current optimizer
  28473. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  28474. * @returns true if everything that can be done was applied
  28475. */
  28476. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  28477. }
  28478. /**
  28479. * Defines a list of options used by SceneOptimizer
  28480. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  28481. */
  28482. class SceneOptimizerOptions {
  28483. /**
  28484. * Defines the target frame rate to reach (60 by default)
  28485. */
  28486. targetFrameRate: number;
  28487. /**
  28488. * Defines the interval between two checkes (2000ms by default)
  28489. */
  28490. trackerDuration: number;
  28491. /**
  28492. * Gets the list of optimizations to apply
  28493. */
  28494. optimizations: SceneOptimization[];
  28495. /**
  28496. * Creates a new list of options used by SceneOptimizer
  28497. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  28498. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  28499. */
  28500. constructor(
  28501. /**
  28502. * Defines the target frame rate to reach (60 by default)
  28503. */
  28504. targetFrameRate?: number,
  28505. /**
  28506. * Defines the interval between two checkes (2000ms by default)
  28507. */
  28508. trackerDuration?: number);
  28509. /**
  28510. * Add a new optimization
  28511. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  28512. * @returns the current SceneOptimizerOptions
  28513. */
  28514. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  28515. /**
  28516. * Add a new custom optimization
  28517. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  28518. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  28519. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  28520. * @returns the current SceneOptimizerOptions
  28521. */
  28522. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  28523. /**
  28524. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  28525. * @param targetFrameRate defines the target frame rate (60 by default)
  28526. * @returns a SceneOptimizerOptions object
  28527. */
  28528. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  28529. /**
  28530. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  28531. * @param targetFrameRate defines the target frame rate (60 by default)
  28532. * @returns a SceneOptimizerOptions object
  28533. */
  28534. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  28535. /**
  28536. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  28537. * @param targetFrameRate defines the target frame rate (60 by default)
  28538. * @returns a SceneOptimizerOptions object
  28539. */
  28540. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  28541. }
  28542. /**
  28543. * Class used to run optimizations in order to reach a target frame rate
  28544. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  28545. */
  28546. class SceneOptimizer implements IDisposable {
  28547. private _isRunning;
  28548. private _options;
  28549. private _scene;
  28550. private _currentPriorityLevel;
  28551. private _targetFrameRate;
  28552. private _trackerDuration;
  28553. private _currentFrameRate;
  28554. private _sceneDisposeObserver;
  28555. private _improvementMode;
  28556. /**
  28557. * Defines an observable called when the optimizer reaches the target frame rate
  28558. */
  28559. onSuccessObservable: Observable<SceneOptimizer>;
  28560. /**
  28561. * Defines an observable called when the optimizer enables an optimization
  28562. */
  28563. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  28564. /**
  28565. * Defines an observable called when the optimizer is not able to reach the target frame rate
  28566. */
  28567. onFailureObservable: Observable<SceneOptimizer>;
  28568. /**
  28569. * Gets a boolean indicating if the optimizer is in improvement mode
  28570. */
  28571. readonly isInImprovementMode: boolean;
  28572. /**
  28573. * Gets the current priority level (0 at start)
  28574. */
  28575. readonly currentPriorityLevel: number;
  28576. /**
  28577. * Gets the current frame rate checked by the SceneOptimizer
  28578. */
  28579. readonly currentFrameRate: number;
  28580. /**
  28581. * Gets or sets the current target frame rate (60 by default)
  28582. */
  28583. /**
  28584. * Gets or sets the current target frame rate (60 by default)
  28585. */
  28586. targetFrameRate: number;
  28587. /**
  28588. * Gets or sets the current interval between two checks (every 2000ms by default)
  28589. */
  28590. /**
  28591. * Gets or sets the current interval between two checks (every 2000ms by default)
  28592. */
  28593. trackerDuration: number;
  28594. /**
  28595. * Gets the list of active optimizations
  28596. */
  28597. readonly optimizations: SceneOptimization[];
  28598. /**
  28599. * Creates a new SceneOptimizer
  28600. * @param scene defines the scene to work on
  28601. * @param options defines the options to use with the SceneOptimizer
  28602. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  28603. * @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)
  28604. */
  28605. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  28606. /**
  28607. * Stops the current optimizer
  28608. */
  28609. stop(): void;
  28610. /**
  28611. * Reset the optimizer to initial step (current priority level = 0)
  28612. */
  28613. reset(): void;
  28614. /**
  28615. * Start the optimizer. By default it will try to reach a specific framerate
  28616. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  28617. */
  28618. start(): void;
  28619. private _checkCurrentState();
  28620. /**
  28621. * Release all resources
  28622. */
  28623. dispose(): void;
  28624. /**
  28625. * Helper function to create a SceneOptimizer with one single line of code
  28626. * @param scene defines the scene to work on
  28627. * @param options defines the options to use with the SceneOptimizer
  28628. * @param onSuccess defines a callback to call on success
  28629. * @param onFailure defines a callback to call on failure
  28630. * @returns the new SceneOptimizer object
  28631. */
  28632. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  28633. }
  28634. }
  28635. declare module BABYLON {
  28636. class SceneSerializer {
  28637. static ClearCache(): void;
  28638. static Serialize(scene: Scene): any;
  28639. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  28640. }
  28641. }
  28642. declare module BABYLON {
  28643. class SmartArray<T> {
  28644. data: Array<T>;
  28645. length: number;
  28646. protected _id: number;
  28647. [index: number]: T;
  28648. constructor(capacity: number);
  28649. push(value: T): void;
  28650. forEach(func: (content: T) => void): void;
  28651. sort(compareFn: (a: T, b: T) => number): void;
  28652. reset(): void;
  28653. dispose(): void;
  28654. concat(array: any): void;
  28655. indexOf(value: T): number;
  28656. contains(value: T): boolean;
  28657. private static _GlobalId;
  28658. }
  28659. class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  28660. private _duplicateId;
  28661. [index: number]: T;
  28662. push(value: T): void;
  28663. pushNoDuplicate(value: T): boolean;
  28664. reset(): void;
  28665. concatWithNoDuplicate(array: any): void;
  28666. }
  28667. }
  28668. declare module BABYLON {
  28669. /**
  28670. * This class implement a typical dictionary using a string as key and the generic type T as value.
  28671. * The underlying implementation relies on an associative array to ensure the best performances.
  28672. * The value can be anything including 'null' but except 'undefined'
  28673. */
  28674. class StringDictionary<T> {
  28675. /**
  28676. * This will clear this dictionary and copy the content from the 'source' one.
  28677. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  28678. * @param source the dictionary to take the content from and copy to this dictionary
  28679. */
  28680. copyFrom(source: StringDictionary<T>): void;
  28681. /**
  28682. * Get a value based from its key
  28683. * @param key the given key to get the matching value from
  28684. * @return the value if found, otherwise undefined is returned
  28685. */
  28686. get(key: string): T | undefined;
  28687. /**
  28688. * Get a value from its key or add it if it doesn't exist.
  28689. * This method will ensure you that a given key/data will be present in the dictionary.
  28690. * @param key the given key to get the matching value from
  28691. * @param factory the factory that will create the value if the key is not present in the dictionary.
  28692. * The factory will only be invoked if there's no data for the given key.
  28693. * @return the value corresponding to the key.
  28694. */
  28695. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  28696. /**
  28697. * Get a value from its key if present in the dictionary otherwise add it
  28698. * @param key the key to get the value from
  28699. * @param val if there's no such key/value pair in the dictionary add it with this value
  28700. * @return the value corresponding to the key
  28701. */
  28702. getOrAdd(key: string, val: T): T;
  28703. /**
  28704. * Check if there's a given key in the dictionary
  28705. * @param key the key to check for
  28706. * @return true if the key is present, false otherwise
  28707. */
  28708. contains(key: string): boolean;
  28709. /**
  28710. * Add a new key and its corresponding value
  28711. * @param key the key to add
  28712. * @param value the value corresponding to the key
  28713. * @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
  28714. */
  28715. add(key: string, value: T): boolean;
  28716. set(key: string, value: T): boolean;
  28717. /**
  28718. * Get the element of the given key and remove it from the dictionary
  28719. * @param key
  28720. */
  28721. getAndRemove(key: string): Nullable<T>;
  28722. /**
  28723. * Remove a key/value from the dictionary.
  28724. * @param key the key to remove
  28725. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  28726. */
  28727. remove(key: string): boolean;
  28728. /**
  28729. * Clear the whole content of the dictionary
  28730. */
  28731. clear(): void;
  28732. readonly count: number;
  28733. /**
  28734. * Execute a callback on each key/val of the dictionary.
  28735. * Note that you can remove any element in this dictionary in the callback implementation
  28736. * @param callback the callback to execute on a given key/value pair
  28737. */
  28738. forEach(callback: (key: string, val: T) => void): void;
  28739. /**
  28740. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  28741. * If the callback returns null or undefined the method will iterate to the next key/value pair
  28742. * Note that you can remove any element in this dictionary in the callback implementation
  28743. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  28744. */
  28745. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  28746. private _count;
  28747. private _data;
  28748. }
  28749. }
  28750. declare module BABYLON {
  28751. class Tags {
  28752. static EnableFor(obj: any): void;
  28753. static DisableFor(obj: any): void;
  28754. static HasTags(obj: any): boolean;
  28755. static GetTags(obj: any, asString?: boolean): any;
  28756. static AddTagsTo(obj: any, tagsString: string): void;
  28757. static _AddTagTo(obj: any, tag: string): void;
  28758. static RemoveTagsFrom(obj: any, tagsString: string): void;
  28759. static _RemoveTagFrom(obj: any, tag: string): void;
  28760. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  28761. }
  28762. }
  28763. declare module BABYLON {
  28764. class TextureTools {
  28765. /**
  28766. * Uses the GPU to create a copy texture rescaled at a given size
  28767. * @param texture Texture to copy from
  28768. * @param width Desired width
  28769. * @param height Desired height
  28770. * @return Generated texture
  28771. */
  28772. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  28773. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  28774. private static _environmentBRDFBase64Texture;
  28775. }
  28776. }
  28777. declare module BABYLON {
  28778. class TGATools {
  28779. private static _TYPE_INDEXED;
  28780. private static _TYPE_RGB;
  28781. private static _TYPE_GREY;
  28782. private static _TYPE_RLE_INDEXED;
  28783. private static _TYPE_RLE_RGB;
  28784. private static _TYPE_RLE_GREY;
  28785. private static _ORIGIN_MASK;
  28786. private static _ORIGIN_SHIFT;
  28787. private static _ORIGIN_BL;
  28788. private static _ORIGIN_BR;
  28789. private static _ORIGIN_UL;
  28790. private static _ORIGIN_UR;
  28791. static GetTGAHeader(data: Uint8Array): any;
  28792. static UploadContent(gl: WebGLRenderingContext, data: Uint8Array): void;
  28793. 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;
  28794. 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;
  28795. 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;
  28796. 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;
  28797. 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;
  28798. 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;
  28799. }
  28800. }
  28801. declare module BABYLON {
  28802. interface IAnimatable {
  28803. animations: Array<Animation>;
  28804. }
  28805. class LoadFileError extends Error {
  28806. request: XMLHttpRequest | undefined;
  28807. private static _setPrototypeOf;
  28808. constructor(message: string, request?: XMLHttpRequest | undefined);
  28809. }
  28810. class RetryStrategy {
  28811. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: XMLHttpRequest, retryIndex: number) => number;
  28812. }
  28813. interface IFileRequest {
  28814. /**
  28815. * Raised when the request is complete (success or error).
  28816. */
  28817. onCompleteObservable: Observable<IFileRequest>;
  28818. /**
  28819. * Aborts the request for a file.
  28820. */
  28821. abort: () => void;
  28822. }
  28823. class Tools {
  28824. static BaseUrl: string;
  28825. static DefaultRetryStrategy: (url: string, request: XMLHttpRequest, retryIndex: number) => number;
  28826. /**
  28827. * Default behaviour for cors in the application.
  28828. * It can be a string if the expected behavior is identical in the entire app.
  28829. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  28830. */
  28831. static CorsBehavior: string | ((url: string | string[]) => string);
  28832. static UseFallbackTexture: boolean;
  28833. /**
  28834. * Use this object to register external classes like custom textures or material
  28835. * to allow the laoders to instantiate them
  28836. */
  28837. static RegisteredExternalClasses: {
  28838. [key: string]: Object;
  28839. };
  28840. static fallbackTexture: string;
  28841. /**
  28842. * Interpolates between a and b via alpha
  28843. * @param a The lower value (returned when alpha = 0)
  28844. * @param b The upper value (returned when alpha = 1)
  28845. * @param alpha The interpolation-factor
  28846. * @return The mixed value
  28847. */
  28848. static Mix(a: number, b: number, alpha: number): number;
  28849. static Instantiate(className: string): any;
  28850. /**
  28851. * Provides a slice function that will work even on IE
  28852. * @param data defines the array to slice
  28853. * @param start defines the start of the data (optional)
  28854. * @param end defines the end of the data (optional)
  28855. * @returns the new sliced array
  28856. */
  28857. static Slice<T>(data: T, start?: number, end?: number): T;
  28858. static SetImmediate(action: () => void): void;
  28859. static IsExponentOfTwo(value: number): boolean;
  28860. private static _tmpFloatArray;
  28861. /**
  28862. * Returns the nearest 32-bit single precision float representation of a Number
  28863. * @param value A Number. If the parameter is of a different type, it will get converted
  28864. * to a number or to NaN if it cannot be converted
  28865. * @returns number
  28866. */
  28867. static FloatRound(value: number): number;
  28868. /**
  28869. * Find the next highest power of two.
  28870. * @param x Number to start search from.
  28871. * @return Next highest power of two.
  28872. */
  28873. static CeilingPOT(x: number): number;
  28874. /**
  28875. * Find the next lowest power of two.
  28876. * @param x Number to start search from.
  28877. * @return Next lowest power of two.
  28878. */
  28879. static FloorPOT(x: number): number;
  28880. /**
  28881. * Find the nearest power of two.
  28882. * @param x Number to start search from.
  28883. * @return Next nearest power of two.
  28884. */
  28885. static NearestPOT(x: number): number;
  28886. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  28887. static GetFilename(path: string): string;
  28888. /**
  28889. * Extracts the "folder" part of a path (everything before the filename).
  28890. * @param uri The URI to extract the info from
  28891. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  28892. * @returns The "folder" part of the path
  28893. */
  28894. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  28895. static GetDOMTextContent(element: HTMLElement): string;
  28896. static ToDegrees(angle: number): number;
  28897. static ToRadians(angle: number): number;
  28898. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  28899. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  28900. minimum: Vector3;
  28901. maximum: Vector3;
  28902. };
  28903. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  28904. minimum: Vector3;
  28905. maximum: Vector3;
  28906. };
  28907. static Vector2ArrayFeeder(array: Array<Vector2> | Float32Array): (i: number) => Nullable<Vector2>;
  28908. static ExtractMinAndMaxVector2(feeder: (index: number) => Vector2, bias?: Nullable<Vector2>): {
  28909. minimum: Vector2;
  28910. maximum: Vector2;
  28911. };
  28912. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  28913. static GetPointerPrefix(): string;
  28914. /**
  28915. * @param func - the function to be called
  28916. * @param requester - the object that will request the next frame. Falls back to window.
  28917. */
  28918. static QueueNewFrame(func: () => void, requester?: any): number;
  28919. static RequestFullscreen(element: HTMLElement): void;
  28920. static ExitFullscreen(): void;
  28921. static SetCorsBehavior(url: string | string[], element: {
  28922. crossOrigin: string | null;
  28923. }): void;
  28924. static CleanUrl(url: string): string;
  28925. static PreprocessUrl: (url: string) => string;
  28926. /**
  28927. * Loads an image as an HTMLImageElement.
  28928. * @param input url string, ArrayBuffer, or Blob to load
  28929. * @param onLoad callback called when the image successfully loads
  28930. * @param onError callback called when the image fails to load
  28931. * @param database database for caching
  28932. * @returns the HTMLImageElement of the loaded image
  28933. */
  28934. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, database: Nullable<Database>): HTMLImageElement;
  28935. 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;
  28936. /**
  28937. * Load a script (identified by an url). When the url returns, the
  28938. * content of this file is added into a new script element, attached to the DOM (body element)
  28939. */
  28940. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void): void;
  28941. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  28942. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  28943. static FileAsURL(content: string): string;
  28944. static Format(value: number, decimals?: number): string;
  28945. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  28946. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  28947. static IsEmpty(obj: any): boolean;
  28948. static RegisterTopRootEvents(events: {
  28949. name: string;
  28950. handler: Nullable<(e: FocusEvent) => any>;
  28951. }[]): void;
  28952. static UnregisterTopRootEvents(events: {
  28953. name: string;
  28954. handler: Nullable<(e: FocusEvent) => any>;
  28955. }[]): void;
  28956. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  28957. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  28958. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  28959. /**
  28960. * Generates an image screenshot from the specified camera.
  28961. *
  28962. * @param engine The engine to use for rendering
  28963. * @param camera The camera to use for rendering
  28964. * @param size This parameter can be set to a single number or to an object with the
  28965. * following (optional) properties: precision, width, height. If a single number is passed,
  28966. * it will be used for both width and height. If an object is passed, the screenshot size
  28967. * will be derived from the parameters. The precision property is a multiplier allowing
  28968. * rendering at a higher or lower resolution.
  28969. * @param successCallback The callback receives a single parameter which contains the
  28970. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  28971. * src parameter of an <img> to display it.
  28972. * @param mimeType The MIME type of the screenshot image (default: image/png).
  28973. * Check your browser for supported MIME types.
  28974. * @param samples Texture samples (default: 1)
  28975. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  28976. * @param fileName A name for for the downloaded file.
  28977. * @constructor
  28978. */
  28979. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  28980. static ValidateXHRData(xhr: XMLHttpRequest, dataType?: number): boolean;
  28981. /**
  28982. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  28983. * Be aware Math.random() could cause collisions, but:
  28984. * "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"
  28985. */
  28986. static RandomId(): string;
  28987. /**
  28988. * Test if the given uri is a base64 string.
  28989. * @param uri The uri to test
  28990. * @return True if the uri is a base64 string or false otherwise.
  28991. */
  28992. static IsBase64(uri: string): boolean;
  28993. /**
  28994. * Decode the given base64 uri.
  28995. * @param uri The uri to decode
  28996. * @return The decoded base64 data.
  28997. */
  28998. static DecodeBase64(uri: string): ArrayBuffer;
  28999. private static _NoneLogLevel;
  29000. private static _MessageLogLevel;
  29001. private static _WarningLogLevel;
  29002. private static _ErrorLogLevel;
  29003. private static _LogCache;
  29004. static errorsCount: number;
  29005. static OnNewCacheEntry: (entry: string) => void;
  29006. static readonly NoneLogLevel: number;
  29007. static readonly MessageLogLevel: number;
  29008. static readonly WarningLogLevel: number;
  29009. static readonly ErrorLogLevel: number;
  29010. static readonly AllLogLevel: number;
  29011. private static _AddLogEntry(entry);
  29012. private static _FormatMessage(message);
  29013. private static _LogDisabled(message);
  29014. private static _LogEnabled(message);
  29015. private static _WarnDisabled(message);
  29016. private static _WarnEnabled(message);
  29017. private static _ErrorDisabled(message);
  29018. private static _ErrorEnabled(message);
  29019. static Log: (message: string) => void;
  29020. static Warn: (message: string) => void;
  29021. static Error: (message: string) => void;
  29022. static readonly LogCache: string;
  29023. static ClearLogCache(): void;
  29024. static LogLevels: number;
  29025. static IsWindowObjectExist(): boolean;
  29026. private static _PerformanceNoneLogLevel;
  29027. private static _PerformanceUserMarkLogLevel;
  29028. private static _PerformanceConsoleLogLevel;
  29029. private static _performance;
  29030. static readonly PerformanceNoneLogLevel: number;
  29031. static readonly PerformanceUserMarkLogLevel: number;
  29032. static readonly PerformanceConsoleLogLevel: number;
  29033. static PerformanceLogLevel: number;
  29034. static _StartPerformanceCounterDisabled(counterName: string, condition?: boolean): void;
  29035. static _EndPerformanceCounterDisabled(counterName: string, condition?: boolean): void;
  29036. static _StartUserMark(counterName: string, condition?: boolean): void;
  29037. static _EndUserMark(counterName: string, condition?: boolean): void;
  29038. static _StartPerformanceConsole(counterName: string, condition?: boolean): void;
  29039. static _EndPerformanceConsole(counterName: string, condition?: boolean): void;
  29040. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  29041. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  29042. static readonly Now: number;
  29043. /**
  29044. * This method will return the name of the class used to create the instance of the given object.
  29045. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  29046. * @param object the object to get the class name from
  29047. * @return the name of the class, will be "object" for a custom data type not using the @className decorator
  29048. */
  29049. static GetClassName(object: any, isType?: boolean): string;
  29050. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  29051. /**
  29052. * This method will return the name of the full name of the class, including its owning module (if any).
  29053. * 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).
  29054. * @param object the object to get the class name from
  29055. * @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.
  29056. */
  29057. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  29058. /**
  29059. * 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.
  29060. * @param array
  29061. */
  29062. static arrayOrStringFeeder(array: any): (i: number) => number;
  29063. /**
  29064. * Compute the hashCode of a stream of number
  29065. * To compute the HashCode on a string or an Array of data types implementing the getHashCode() method, use the arrayOrStringFeeder method.
  29066. * @param feeder a callback that will be called until it returns null, each valid returned values will be used to compute the hash code.
  29067. * @return the hash code computed
  29068. */
  29069. static hashCodeFromStream(feeder: (index: number) => number): number;
  29070. /**
  29071. * Returns a promise that resolves after the given amount of time.
  29072. * @param delay Number of milliseconds to delay
  29073. * @returns Promise that resolves after the given amount of time
  29074. */
  29075. static DelayAsync(delay: number): Promise<void>;
  29076. }
  29077. /**
  29078. * This class is used to track a performance counter which is number based.
  29079. * The user has access to many properties which give statistics of different nature
  29080. *
  29081. * The implementer can track two kinds of Performance Counter: time and count
  29082. * 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.
  29083. * 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.
  29084. */
  29085. class PerfCounter {
  29086. static Enabled: boolean;
  29087. /**
  29088. * Returns the smallest value ever
  29089. */
  29090. readonly min: number;
  29091. /**
  29092. * Returns the biggest value ever
  29093. */
  29094. readonly max: number;
  29095. /**
  29096. * Returns the average value since the performance counter is running
  29097. */
  29098. readonly average: number;
  29099. /**
  29100. * Returns the average value of the last second the counter was monitored
  29101. */
  29102. readonly lastSecAverage: number;
  29103. /**
  29104. * Returns the current value
  29105. */
  29106. readonly current: number;
  29107. readonly total: number;
  29108. readonly count: number;
  29109. constructor();
  29110. /**
  29111. * Call this method to start monitoring a new frame.
  29112. * 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.
  29113. */
  29114. fetchNewFrame(): void;
  29115. /**
  29116. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  29117. * @param newCount the count value to add to the monitored count
  29118. * @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.
  29119. */
  29120. addCount(newCount: number, fetchResult: boolean): void;
  29121. /**
  29122. * Start monitoring this performance counter
  29123. */
  29124. beginMonitoring(): void;
  29125. /**
  29126. * Compute the time lapsed since the previous beginMonitoring() call.
  29127. * @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
  29128. */
  29129. endMonitoring(newFrame?: boolean): void;
  29130. private _fetchResult();
  29131. private _startMonitoringTime;
  29132. private _min;
  29133. private _max;
  29134. private _average;
  29135. private _current;
  29136. private _totalValueCount;
  29137. private _totalAccumulated;
  29138. private _lastSecAverage;
  29139. private _lastSecAccumulated;
  29140. private _lastSecTime;
  29141. private _lastSecValueCount;
  29142. }
  29143. /**
  29144. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  29145. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  29146. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  29147. * @param name The name of the class, case should be preserved
  29148. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  29149. */
  29150. function className(name: string, module?: string): (target: Object) => void;
  29151. /**
  29152. * An implementation of a loop for asynchronous functions.
  29153. */
  29154. class AsyncLoop {
  29155. iterations: number;
  29156. private _fn;
  29157. private _successCallback;
  29158. index: number;
  29159. private _done;
  29160. /**
  29161. * Constroctor.
  29162. * @param iterations the number of iterations.
  29163. * @param _fn the function to run each iteration
  29164. * @param _successCallback the callback that will be called upon succesful execution
  29165. * @param offset starting offset.
  29166. */
  29167. constructor(iterations: number, _fn: (asyncLoop: AsyncLoop) => void, _successCallback: () => void, offset?: number);
  29168. /**
  29169. * Execute the next iteration. Must be called after the last iteration was finished.
  29170. */
  29171. executeNext(): void;
  29172. /**
  29173. * Break the loop and run the success callback.
  29174. */
  29175. breakLoop(): void;
  29176. /**
  29177. * Helper function
  29178. */
  29179. static Run(iterations: number, _fn: (asyncLoop: AsyncLoop) => void, _successCallback: () => void, offset?: number): AsyncLoop;
  29180. /**
  29181. * A for-loop that will run a given number of iterations synchronous and the rest async.
  29182. * @param iterations total number of iterations
  29183. * @param syncedIterations number of synchronous iterations in each async iteration.
  29184. * @param fn the function to call each iteration.
  29185. * @param callback a success call back that will be called when iterating stops.
  29186. * @param breakFunction a break condition (optional)
  29187. * @param timeout timeout settings for the setTimeout function. default - 0.
  29188. * @constructor
  29189. */
  29190. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): void;
  29191. }
  29192. }
  29193. declare module BABYLON {
  29194. /**
  29195. * Defines the potential axis of a Joystick
  29196. */
  29197. enum JoystickAxis {
  29198. /** X axis */
  29199. X = 0,
  29200. /** Y axis */
  29201. Y = 1,
  29202. /** Z axis */
  29203. Z = 2,
  29204. }
  29205. /**
  29206. * Class used to define virtual joystick (used in touch mode)
  29207. */
  29208. class VirtualJoystick {
  29209. /**
  29210. * Gets or sets a boolean indicating that left and right values must be inverted
  29211. */
  29212. reverseLeftRight: boolean;
  29213. /**
  29214. * Gets or sets a boolean indicating that up and down values must be inverted
  29215. */
  29216. reverseUpDown: boolean;
  29217. /**
  29218. * Gets the offset value for the position (ie. the change of the position value)
  29219. */
  29220. deltaPosition: Vector3;
  29221. /**
  29222. * Gets a boolean indicating if the virtual joystick was pressed
  29223. */
  29224. pressed: boolean;
  29225. private static _globalJoystickIndex;
  29226. private static vjCanvas;
  29227. private static vjCanvasContext;
  29228. private static vjCanvasWidth;
  29229. private static vjCanvasHeight;
  29230. private static halfWidth;
  29231. private _action;
  29232. private _axisTargetedByLeftAndRight;
  29233. private _axisTargetedByUpAndDown;
  29234. private _joystickSensibility;
  29235. private _inversedSensibility;
  29236. private _joystickPointerID;
  29237. private _joystickColor;
  29238. private _joystickPointerPos;
  29239. private _joystickPreviousPointerPos;
  29240. private _joystickPointerStartPos;
  29241. private _deltaJoystickVector;
  29242. private _leftJoystick;
  29243. private _touches;
  29244. private _onPointerDownHandlerRef;
  29245. private _onPointerMoveHandlerRef;
  29246. private _onPointerUpHandlerRef;
  29247. private _onResize;
  29248. /**
  29249. * Creates a new virtual joystick
  29250. * @param leftJoystick defines that the joystick is for left hand (false by default)
  29251. */
  29252. constructor(leftJoystick?: boolean);
  29253. /**
  29254. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  29255. * @param newJoystickSensibility defines the new sensibility
  29256. */
  29257. setJoystickSensibility(newJoystickSensibility: number): void;
  29258. private _onPointerDown(e);
  29259. private _onPointerMove(e);
  29260. private _onPointerUp(e);
  29261. /**
  29262. * Change the color of the virtual joystick
  29263. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  29264. */
  29265. setJoystickColor(newColor: string): void;
  29266. /**
  29267. * Defines a callback to call when the joystick is touched
  29268. * @param action defines the callback
  29269. */
  29270. setActionOnTouch(action: () => any): void;
  29271. /**
  29272. * Defines which axis you'd like to control for left & right
  29273. * @param axis defines the axis to use
  29274. */
  29275. setAxisForLeftRight(axis: JoystickAxis): void;
  29276. /**
  29277. * Defines which axis you'd like to control for up & down
  29278. * @param axis defines the axis to use
  29279. */
  29280. setAxisForUpDown(axis: JoystickAxis): void;
  29281. private _drawVirtualJoystick();
  29282. /**
  29283. * Release internal HTML canvas
  29284. */
  29285. releaseCanvas(): void;
  29286. }
  29287. }
  29288. declare module BABYLON {
  29289. /**
  29290. * Helper class to push actions to a pool of workers.
  29291. */
  29292. class WorkerPool implements IDisposable {
  29293. private _workerInfos;
  29294. private _pendingActions;
  29295. /**
  29296. * Constructor
  29297. * @param workers Array of workers to use for actions
  29298. */
  29299. constructor(workers: Array<Worker>);
  29300. /**
  29301. * Terminates all workers and clears any pending actions.
  29302. */
  29303. dispose(): void;
  29304. /**
  29305. * Pushes an action to the worker pool. If all the workers are active, the action will be
  29306. * pended until a worker has completed its action.
  29307. * @param action The action to perform. Call onComplete when the action is complete.
  29308. */
  29309. push(action: (worker: Worker, onComplete: () => void) => void): void;
  29310. private _execute(workerInfo, action);
  29311. }
  29312. }
  29313. declare module BABYLON {
  29314. class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  29315. readonly name: string;
  29316. private _zoomStopsAnimation;
  29317. private _idleRotationSpeed;
  29318. private _idleRotationWaitTime;
  29319. private _idleRotationSpinupTime;
  29320. /**
  29321. * Gets the flag that indicates if user zooming should stop animation.
  29322. */
  29323. /**
  29324. * Sets the flag that indicates if user zooming should stop animation.
  29325. */
  29326. zoomStopsAnimation: boolean;
  29327. /**
  29328. * Gets the default speed at which the camera rotates around the model.
  29329. */
  29330. /**
  29331. * Sets the default speed at which the camera rotates around the model.
  29332. */
  29333. idleRotationSpeed: number;
  29334. /**
  29335. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  29336. */
  29337. /**
  29338. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  29339. */
  29340. idleRotationWaitTime: number;
  29341. /**
  29342. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  29343. */
  29344. /**
  29345. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  29346. */
  29347. idleRotationSpinupTime: number;
  29348. /**
  29349. * Gets a value indicating if the camera is currently rotating because of this behavior
  29350. */
  29351. readonly rotationInProgress: boolean;
  29352. private _onPrePointerObservableObserver;
  29353. private _onAfterCheckInputsObserver;
  29354. private _attachedCamera;
  29355. private _isPointerDown;
  29356. private _lastFrameTime;
  29357. private _lastInteractionTime;
  29358. private _cameraRotationSpeed;
  29359. init(): void;
  29360. attach(camera: ArcRotateCamera): void;
  29361. detach(): void;
  29362. /**
  29363. * Returns true if user is scrolling.
  29364. * @return true if user is scrolling.
  29365. */
  29366. private _userIsZooming();
  29367. private _lastFrameRadius;
  29368. private _shouldAnimationStopForInteraction();
  29369. /**
  29370. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  29371. */
  29372. private _applyUserInteraction();
  29373. private _userIsMoving();
  29374. }
  29375. }
  29376. declare module BABYLON {
  29377. /**
  29378. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  29379. */
  29380. class BouncingBehavior implements Behavior<ArcRotateCamera> {
  29381. readonly name: string;
  29382. /**
  29383. * The easing function used by animations
  29384. */
  29385. static EasingFunction: BackEase;
  29386. /**
  29387. * The easing mode used by animations
  29388. */
  29389. static EasingMode: number;
  29390. /**
  29391. * The duration of the animation, in milliseconds
  29392. */
  29393. transitionDuration: number;
  29394. /**
  29395. * Length of the distance animated by the transition when lower radius is reached
  29396. */
  29397. lowerRadiusTransitionRange: number;
  29398. /**
  29399. * Length of the distance animated by the transition when upper radius is reached
  29400. */
  29401. upperRadiusTransitionRange: number;
  29402. private _autoTransitionRange;
  29403. /**
  29404. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  29405. */
  29406. /**
  29407. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  29408. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  29409. */
  29410. autoTransitionRange: boolean;
  29411. private _attachedCamera;
  29412. private _onAfterCheckInputsObserver;
  29413. private _onMeshTargetChangedObserver;
  29414. init(): void;
  29415. attach(camera: ArcRotateCamera): void;
  29416. detach(): void;
  29417. private _radiusIsAnimating;
  29418. private _radiusBounceTransition;
  29419. private _animatables;
  29420. private _cachedWheelPrecision;
  29421. /**
  29422. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  29423. * @param radiusLimit The limit to check against.
  29424. * @return Bool to indicate if at limit.
  29425. */
  29426. private _isRadiusAtLimit(radiusLimit);
  29427. /**
  29428. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  29429. * @param radiusDelta The delta by which to animate to. Can be negative.
  29430. */
  29431. private _applyBoundRadiusAnimation(radiusDelta);
  29432. /**
  29433. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  29434. */
  29435. protected _clearAnimationLocks(): void;
  29436. /**
  29437. * Stops and removes all animations that have been applied to the camera
  29438. */
  29439. stopAllAnimations(): void;
  29440. }
  29441. }
  29442. declare module BABYLON {
  29443. class FramingBehavior implements Behavior<ArcRotateCamera> {
  29444. readonly name: string;
  29445. private _mode;
  29446. private _radiusScale;
  29447. private _positionScale;
  29448. private _defaultElevation;
  29449. private _elevationReturnTime;
  29450. private _elevationReturnWaitTime;
  29451. private _zoomStopsAnimation;
  29452. private _framingTime;
  29453. /**
  29454. * The easing function used by animations
  29455. */
  29456. static EasingFunction: ExponentialEase;
  29457. /**
  29458. * The easing mode used by animations
  29459. */
  29460. static EasingMode: number;
  29461. /**
  29462. * Gets current mode used by the behavior.
  29463. */
  29464. /**
  29465. * Sets the current mode used by the behavior
  29466. */
  29467. mode: number;
  29468. /**
  29469. * Gets the scale applied to the radius
  29470. */
  29471. /**
  29472. * Sets the scale applied to the radius (1 by default)
  29473. */
  29474. radiusScale: number;
  29475. /**
  29476. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  29477. */
  29478. /**
  29479. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  29480. */
  29481. positionScale: number;
  29482. /**
  29483. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  29484. * behaviour is triggered, in radians.
  29485. */
  29486. /**
  29487. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  29488. * behaviour is triggered, in radians.
  29489. */
  29490. defaultElevation: number;
  29491. /**
  29492. * Gets the time (in milliseconds) taken to return to the default beta position.
  29493. * Negative value indicates camera should not return to default.
  29494. */
  29495. /**
  29496. * Sets the time (in milliseconds) taken to return to the default beta position.
  29497. * Negative value indicates camera should not return to default.
  29498. */
  29499. elevationReturnTime: number;
  29500. /**
  29501. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  29502. */
  29503. /**
  29504. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  29505. */
  29506. elevationReturnWaitTime: number;
  29507. /**
  29508. * Gets the flag that indicates if user zooming should stop animation.
  29509. */
  29510. /**
  29511. * Sets the flag that indicates if user zooming should stop animation.
  29512. */
  29513. zoomStopsAnimation: boolean;
  29514. /**
  29515. * Gets the transition time when framing the mesh, in milliseconds
  29516. */
  29517. /**
  29518. * Sets the transition time when framing the mesh, in milliseconds
  29519. */
  29520. framingTime: number;
  29521. private _onPrePointerObservableObserver;
  29522. private _onAfterCheckInputsObserver;
  29523. private _onMeshTargetChangedObserver;
  29524. private _attachedCamera;
  29525. private _isPointerDown;
  29526. private _lastInteractionTime;
  29527. init(): void;
  29528. attach(camera: ArcRotateCamera): void;
  29529. detach(): void;
  29530. private _animatables;
  29531. private _betaIsAnimating;
  29532. private _betaTransition;
  29533. private _radiusTransition;
  29534. private _vectorTransition;
  29535. /**
  29536. * Targets the given mesh and updates zoom level accordingly.
  29537. * @param mesh The mesh to target.
  29538. * @param radius Optional. If a cached radius position already exists, overrides default.
  29539. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  29540. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  29541. * @param onAnimationEnd Callback triggered at the end of the framing animation
  29542. */
  29543. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  29544. /**
  29545. * Targets the given mesh with its children and updates zoom level accordingly.
  29546. * @param mesh The mesh to target.
  29547. * @param radius Optional. If a cached radius position already exists, overrides default.
  29548. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  29549. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  29550. * @param onAnimationEnd Callback triggered at the end of the framing animation
  29551. */
  29552. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  29553. /**
  29554. * Targets the given meshes with their children and updates zoom level accordingly.
  29555. * @param meshes The mesh to target.
  29556. * @param radius Optional. If a cached radius position already exists, overrides default.
  29557. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  29558. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  29559. * @param onAnimationEnd Callback triggered at the end of the framing animation
  29560. */
  29561. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  29562. /**
  29563. * Targets the given mesh and updates zoom level accordingly.
  29564. * @param mesh The mesh to target.
  29565. * @param radius Optional. If a cached radius position already exists, overrides default.
  29566. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  29567. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  29568. * @param onAnimationEnd Callback triggered at the end of the framing animation
  29569. */
  29570. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  29571. /**
  29572. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  29573. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  29574. * frustum width.
  29575. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  29576. * to fully enclose the mesh in the viewing frustum.
  29577. */
  29578. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  29579. /**
  29580. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  29581. * is automatically returned to its default position (expected to be above ground plane).
  29582. */
  29583. private _maintainCameraAboveGround();
  29584. /**
  29585. * Returns the frustum slope based on the canvas ratio and camera FOV
  29586. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  29587. */
  29588. private _getFrustumSlope();
  29589. /**
  29590. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  29591. */
  29592. private _clearAnimationLocks();
  29593. /**
  29594. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  29595. */
  29596. private _applyUserInteraction();
  29597. /**
  29598. * Stops and removes all animations that have been applied to the camera
  29599. */
  29600. stopAllAnimations(): void;
  29601. /**
  29602. * Gets a value indicating if the user is moving the camera
  29603. */
  29604. readonly isUserIsMoving: boolean;
  29605. /**
  29606. * The camera can move all the way towards the mesh.
  29607. */
  29608. static IgnoreBoundsSizeMode: number;
  29609. /**
  29610. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  29611. */
  29612. static FitFrustumSidesMode: number;
  29613. }
  29614. }
  29615. declare module BABYLON {
  29616. /**
  29617. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  29618. */
  29619. class PointerDragBehavior implements Behavior<Mesh> {
  29620. private options;
  29621. private _attachedNode;
  29622. private _dragPlane;
  29623. private _scene;
  29624. private _pointerObserver;
  29625. private static _planeScene;
  29626. private _draggingID;
  29627. /**
  29628. * Fires each time the attached mesh is dragged with the pointer
  29629. */
  29630. onDragObservable: Observable<{
  29631. delta: Vector3;
  29632. dragPlanePoint: Vector3;
  29633. }>;
  29634. /**
  29635. * Fires each time a drag begins (eg. mouse down on mesh)
  29636. */
  29637. onDragStartObservable: Observable<{
  29638. dragPlanePoint: Vector3;
  29639. }>;
  29640. /**
  29641. * Fires each time a drag ends (eg. mouse release after drag)
  29642. */
  29643. onDragEndObservable: Observable<{
  29644. dragPlanePoint: Vector3;
  29645. }>;
  29646. /**
  29647. * If the attached mesh should be moved when dragged
  29648. */
  29649. moveAttached: boolean;
  29650. /**
  29651. * Mesh with the position where the drag plane should be placed
  29652. */
  29653. _dragPlaneParent: Nullable<Mesh>;
  29654. /**
  29655. * Creates a pointer drag behavior that can be attached to a mesh
  29656. * @param options The drag axis or normal of the plane that will be dragged across. pointerObservableScene can be used to listen to drag events from another scene(eg. if the attached mesh is in an overlay scene).
  29657. */
  29658. constructor(options: {
  29659. dragAxis?: Vector3;
  29660. dragPlaneNormal?: Vector3;
  29661. pointerObservableScene?: Scene;
  29662. });
  29663. /**
  29664. * The name of the behavior
  29665. */
  29666. readonly name: string;
  29667. /**
  29668. * Initializes the behavior
  29669. */
  29670. init(): void;
  29671. /**
  29672. * Attaches the drag behavior the passed in mesh
  29673. * @param ownerNode The mesh that will be dragged around once attached
  29674. */
  29675. attach(ownerNode: Mesh): void;
  29676. private _pickWithRayOnDragPlane(ray);
  29677. private _updateDragPlanePosition(ray);
  29678. /**
  29679. * Detaches the behavior from the mesh
  29680. */
  29681. detach(): void;
  29682. }
  29683. }
  29684. declare module BABYLON {
  29685. interface IOctreeContainer<T> {
  29686. blocks: Array<OctreeBlock<T>>;
  29687. }
  29688. class Octree<T> {
  29689. maxDepth: number;
  29690. blocks: Array<OctreeBlock<T>>;
  29691. dynamicContent: T[];
  29692. private _maxBlockCapacity;
  29693. private _selectionContent;
  29694. private _creationFunc;
  29695. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number, maxDepth?: number);
  29696. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  29697. addMesh(entry: T): void;
  29698. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  29699. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  29700. intersectsRay(ray: Ray): SmartArray<T>;
  29701. 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;
  29702. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  29703. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  29704. }
  29705. }
  29706. declare module BABYLON {
  29707. class OctreeBlock<T> {
  29708. entries: T[];
  29709. blocks: Array<OctreeBlock<T>>;
  29710. private _depth;
  29711. private _maxDepth;
  29712. private _capacity;
  29713. private _minPoint;
  29714. private _maxPoint;
  29715. private _boundingVectors;
  29716. private _creationFunc;
  29717. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  29718. readonly capacity: number;
  29719. readonly minPoint: Vector3;
  29720. readonly maxPoint: Vector3;
  29721. addEntry(entry: T): void;
  29722. addEntries(entries: T[]): void;
  29723. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  29724. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  29725. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  29726. createInnerBlocks(): void;
  29727. }
  29728. }
  29729. declare module BABYLON {
  29730. class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  29731. camera: ArcRotateCamera;
  29732. gamepad: Nullable<Gamepad>;
  29733. private _onGamepadConnectedObserver;
  29734. private _onGamepadDisconnectedObserver;
  29735. gamepadRotationSensibility: number;
  29736. gamepadMoveSensibility: number;
  29737. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  29738. detachControl(element: Nullable<HTMLElement>): void;
  29739. checkInputs(): void;
  29740. getClassName(): string;
  29741. getSimpleName(): string;
  29742. }
  29743. }
  29744. declare module BABYLON {
  29745. class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  29746. camera: ArcRotateCamera;
  29747. private _keys;
  29748. keysUp: number[];
  29749. keysDown: number[];
  29750. keysLeft: number[];
  29751. keysRight: number[];
  29752. keysReset: number[];
  29753. panningSensibility: number;
  29754. zoomingSensibility: number;
  29755. useAltToZoom: boolean;
  29756. private _ctrlPressed;
  29757. private _altPressed;
  29758. private _onCanvasBlurObserver;
  29759. private _onKeyboardObserver;
  29760. private _engine;
  29761. private _scene;
  29762. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  29763. detachControl(element: Nullable<HTMLElement>): void;
  29764. checkInputs(): void;
  29765. getClassName(): string;
  29766. getSimpleName(): string;
  29767. }
  29768. }
  29769. declare module BABYLON {
  29770. class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  29771. camera: ArcRotateCamera;
  29772. private _wheel;
  29773. private _observer;
  29774. wheelPrecision: number;
  29775. /**
  29776. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  29777. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  29778. */
  29779. wheelDeltaPercentage: number;
  29780. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  29781. detachControl(element: Nullable<HTMLElement>): void;
  29782. getClassName(): string;
  29783. getSimpleName(): string;
  29784. }
  29785. }
  29786. declare module BABYLON {
  29787. class ArcRotateCameraPointersInput implements ICameraInput<ArcRotateCamera> {
  29788. camera: ArcRotateCamera;
  29789. buttons: number[];
  29790. angularSensibilityX: number;
  29791. angularSensibilityY: number;
  29792. pinchPrecision: number;
  29793. /**
  29794. * pinchDeltaPercentage will be used instead of pinchPrecision if different from 0.
  29795. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  29796. */
  29797. pinchDeltaPercentage: number;
  29798. panningSensibility: number;
  29799. multiTouchPanning: boolean;
  29800. multiTouchPanAndZoom: boolean;
  29801. private _isPanClick;
  29802. pinchInwards: boolean;
  29803. private _pointerInput;
  29804. private _observer;
  29805. private _onMouseMove;
  29806. private _onGestureStart;
  29807. private _onGesture;
  29808. private _MSGestureHandler;
  29809. private _onLostFocus;
  29810. private _onContextMenu;
  29811. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  29812. detachControl(element: Nullable<HTMLElement>): void;
  29813. getClassName(): string;
  29814. getSimpleName(): string;
  29815. }
  29816. }
  29817. declare module BABYLON {
  29818. class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  29819. camera: ArcRotateCamera;
  29820. alphaCorrection: number;
  29821. betaCorrection: number;
  29822. gammaCorrection: number;
  29823. private _alpha;
  29824. private _gamma;
  29825. private _dirty;
  29826. private _deviceOrientationHandler;
  29827. constructor();
  29828. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  29829. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  29830. checkInputs(): void;
  29831. detachControl(element: Nullable<HTMLElement>): void;
  29832. getClassName(): string;
  29833. getSimpleName(): string;
  29834. }
  29835. }
  29836. declare module BABYLON {
  29837. /**
  29838. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  29839. * Screen rotation is taken into account.
  29840. */
  29841. class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  29842. private _camera;
  29843. private _screenOrientationAngle;
  29844. private _constantTranform;
  29845. private _screenQuaternion;
  29846. private _alpha;
  29847. private _beta;
  29848. private _gamma;
  29849. constructor();
  29850. camera: FreeCamera;
  29851. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  29852. private _orientationChanged;
  29853. private _deviceOrientation;
  29854. detachControl(element: Nullable<HTMLElement>): void;
  29855. checkInputs(): void;
  29856. getClassName(): string;
  29857. getSimpleName(): string;
  29858. }
  29859. }
  29860. declare module BABYLON {
  29861. class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  29862. camera: FreeCamera;
  29863. gamepad: Nullable<Gamepad>;
  29864. private _onGamepadConnectedObserver;
  29865. private _onGamepadDisconnectedObserver;
  29866. gamepadAngularSensibility: number;
  29867. gamepadMoveSensibility: number;
  29868. private _cameraTransform;
  29869. private _deltaTransform;
  29870. private _vector3;
  29871. private _vector2;
  29872. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  29873. detachControl(element: Nullable<HTMLElement>): void;
  29874. checkInputs(): void;
  29875. getClassName(): string;
  29876. getSimpleName(): string;
  29877. }
  29878. }
  29879. declare module BABYLON {
  29880. class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  29881. camera: FreeCamera;
  29882. private _keys;
  29883. private _onCanvasBlurObserver;
  29884. private _onKeyboardObserver;
  29885. private _engine;
  29886. private _scene;
  29887. keysUp: number[];
  29888. keysDown: number[];
  29889. keysLeft: number[];
  29890. keysRight: number[];
  29891. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  29892. detachControl(element: Nullable<HTMLElement>): void;
  29893. checkInputs(): void;
  29894. getClassName(): string;
  29895. _onLostFocus(e: FocusEvent): void;
  29896. getSimpleName(): string;
  29897. }
  29898. }
  29899. declare module BABYLON {
  29900. class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  29901. touchEnabled: boolean;
  29902. camera: FreeCamera;
  29903. buttons: number[];
  29904. angularSensibility: number;
  29905. private _pointerInput;
  29906. private _onMouseMove;
  29907. private _observer;
  29908. private previousPosition;
  29909. constructor(touchEnabled?: boolean);
  29910. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  29911. detachControl(element: Nullable<HTMLElement>): void;
  29912. getClassName(): string;
  29913. getSimpleName(): string;
  29914. }
  29915. }
  29916. declare module BABYLON {
  29917. class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  29918. camera: FreeCamera;
  29919. private _offsetX;
  29920. private _offsetY;
  29921. private _pointerPressed;
  29922. private _pointerInput;
  29923. private _observer;
  29924. private _onLostFocus;
  29925. touchAngularSensibility: number;
  29926. touchMoveSensibility: number;
  29927. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  29928. detachControl(element: Nullable<HTMLElement>): void;
  29929. checkInputs(): void;
  29930. getClassName(): string;
  29931. getSimpleName(): string;
  29932. }
  29933. }
  29934. declare module BABYLON {
  29935. class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  29936. camera: FreeCamera;
  29937. private _leftjoystick;
  29938. private _rightjoystick;
  29939. getLeftJoystick(): VirtualJoystick;
  29940. getRightJoystick(): VirtualJoystick;
  29941. checkInputs(): void;
  29942. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  29943. detachControl(element: Nullable<HTMLElement>): void;
  29944. getClassName(): string;
  29945. getSimpleName(): string;
  29946. }
  29947. }
  29948. declare module BABYLON {
  29949. class VRCameraMetrics {
  29950. hResolution: number;
  29951. vResolution: number;
  29952. hScreenSize: number;
  29953. vScreenSize: number;
  29954. vScreenCenter: number;
  29955. eyeToScreenDistance: number;
  29956. lensSeparationDistance: number;
  29957. interpupillaryDistance: number;
  29958. distortionK: number[];
  29959. chromaAbCorrection: number[];
  29960. postProcessScaleFactor: number;
  29961. lensCenterOffset: number;
  29962. compensateDistortion: boolean;
  29963. readonly aspectRatio: number;
  29964. readonly aspectRatioFov: number;
  29965. readonly leftHMatrix: Matrix;
  29966. readonly rightHMatrix: Matrix;
  29967. readonly leftPreViewMatrix: Matrix;
  29968. readonly rightPreViewMatrix: Matrix;
  29969. static GetDefault(): VRCameraMetrics;
  29970. }
  29971. }
  29972. declare module BABYLON {
  29973. class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  29974. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  29975. getClassName(): string;
  29976. }
  29977. class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  29978. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  29979. getClassName(): string;
  29980. }
  29981. class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  29982. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  29983. getClassName(): string;
  29984. }
  29985. }
  29986. declare module BABYLON {
  29987. /**
  29988. * Options to modify the vr teleportation behavior.
  29989. */
  29990. interface VRTeleportationOptions {
  29991. /**
  29992. * The name of the mesh which should be used as the teleportation floor. (default: null)
  29993. */
  29994. floorMeshName?: string;
  29995. /**
  29996. * A list of meshes to be used as the teleportation floor. (default: empty)
  29997. */
  29998. floorMeshes?: Mesh[];
  29999. }
  30000. /**
  30001. * Options to modify the vr experience helper's behavior.
  30002. */
  30003. interface VRExperienceHelperOptions extends WebVROptions {
  30004. /**
  30005. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  30006. */
  30007. createDeviceOrientationCamera?: boolean;
  30008. /**
  30009. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  30010. */
  30011. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  30012. /**
  30013. * Uses the main button on the controller to toggle the laser casted. (default: true)
  30014. */
  30015. laserToggle?: boolean;
  30016. /**
  30017. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  30018. */
  30019. floorMeshes?: Mesh[];
  30020. }
  30021. /**
  30022. * Helps to quickly add VR support to an existing scene.
  30023. * See http://doc.babylonjs.com/how_to/webvr_helper
  30024. */
  30025. class VRExperienceHelper {
  30026. /** Options to modify the vr experience helper's behavior. */ webVROptions: VRExperienceHelperOptions;
  30027. private _scene;
  30028. private _position;
  30029. private _btnVR;
  30030. private _btnVRDisplayed;
  30031. private _webVRsupported;
  30032. private _webVRready;
  30033. private _webVRrequesting;
  30034. private _webVRpresenting;
  30035. private _fullscreenVRpresenting;
  30036. private _canvas;
  30037. private _webVRCamera;
  30038. private _vrDeviceOrientationCamera;
  30039. private _deviceOrientationCamera;
  30040. private _existingCamera;
  30041. private _onKeyDown;
  30042. private _onVrDisplayPresentChange;
  30043. private _onVRDisplayChanged;
  30044. private _onVRRequestPresentStart;
  30045. private _onVRRequestPresentComplete;
  30046. /**
  30047. * Observable raised when entering VR.
  30048. */
  30049. onEnteringVRObservable: Observable<VRExperienceHelper>;
  30050. /**
  30051. * Observable raised when exiting VR.
  30052. */
  30053. onExitingVRObservable: Observable<VRExperienceHelper>;
  30054. /**
  30055. * Observable raised when controller mesh is loaded.
  30056. */
  30057. onControllerMeshLoadedObservable: Observable<WebVRController>;
  30058. /** Return this.onEnteringVRObservable
  30059. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  30060. */
  30061. readonly onEnteringVR: Observable<VRExperienceHelper>;
  30062. /** Return this.onExitingVRObservable
  30063. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  30064. */
  30065. readonly onExitingVR: Observable<VRExperienceHelper>;
  30066. /** Return this.onControllerMeshLoadedObservable
  30067. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  30068. */
  30069. readonly onControllerMeshLoaded: Observable<WebVRController>;
  30070. private _rayLength;
  30071. private _useCustomVRButton;
  30072. private _teleportationRequested;
  30073. private _teleportActive;
  30074. private _floorMeshName;
  30075. private _floorMeshesCollection;
  30076. private _rotationAllowed;
  30077. private _teleportBackwardsVector;
  30078. private _teleportationTarget;
  30079. private _isDefaultTeleportationTarget;
  30080. private _postProcessMove;
  30081. private _teleportationFillColor;
  30082. private _teleportationBorderColor;
  30083. private _rotationAngle;
  30084. private _haloCenter;
  30085. private _cameraGazer;
  30086. private _padSensibilityUp;
  30087. private _padSensibilityDown;
  30088. private leftController;
  30089. private rightController;
  30090. /**
  30091. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  30092. */
  30093. onNewMeshSelected: Observable<AbstractMesh>;
  30094. /**
  30095. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  30096. */
  30097. onNewMeshPicked: Observable<PickingInfo>;
  30098. private _circleEase;
  30099. /**
  30100. * Observable raised before camera teleportation
  30101. */
  30102. onBeforeCameraTeleport: Observable<Vector3>;
  30103. /**
  30104. * Observable raised after camera teleportation
  30105. */
  30106. onAfterCameraTeleport: Observable<Vector3>;
  30107. /**
  30108. * Observable raised when current selected mesh gets unselected
  30109. */
  30110. onSelectedMeshUnselected: Observable<AbstractMesh>;
  30111. private _raySelectionPredicate;
  30112. /**
  30113. * To be optionaly changed by user to define custom ray selection
  30114. */
  30115. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  30116. /**
  30117. * To be optionaly changed by user to define custom selection logic (after ray selection)
  30118. */
  30119. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  30120. /**
  30121. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  30122. */
  30123. teleportationEnabled: boolean;
  30124. private _defaultHeight;
  30125. private _teleportationInitialized;
  30126. private _interactionsEnabled;
  30127. private _interactionsRequested;
  30128. private _displayGaze;
  30129. private _displayLaserPointer;
  30130. /**
  30131. * The mesh used to display where the user is going to teleport.
  30132. */
  30133. /**
  30134. * Sets the mesh to be used to display where the user is going to teleport.
  30135. */
  30136. teleportationTarget: Mesh;
  30137. /**
  30138. * The mesh used to display where the user is selecting,
  30139. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  30140. * See http://doc.babylonjs.com/resources/baking_transformations
  30141. */
  30142. gazeTrackerMesh: Mesh;
  30143. /**
  30144. * If the ray of the gaze should be displayed.
  30145. */
  30146. /**
  30147. * Sets if the ray of the gaze should be displayed.
  30148. */
  30149. displayGaze: boolean;
  30150. /**
  30151. * If the ray of the LaserPointer should be displayed.
  30152. */
  30153. /**
  30154. * Sets if the ray of the LaserPointer should be displayed.
  30155. */
  30156. displayLaserPointer: boolean;
  30157. /**
  30158. * The deviceOrientationCamera used as the camera when not in VR.
  30159. */
  30160. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  30161. /**
  30162. * Based on the current WebVR support, returns the current VR camera used.
  30163. */
  30164. readonly currentVRCamera: Nullable<Camera>;
  30165. /**
  30166. * The webVRCamera which is used when in VR.
  30167. */
  30168. readonly webVRCamera: WebVRFreeCamera;
  30169. /**
  30170. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  30171. */
  30172. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  30173. private readonly _teleportationRequestInitiated;
  30174. /**
  30175. * Instantiates a VRExperienceHelper.
  30176. * Helps to quickly add VR support to an existing scene.
  30177. * @param scene The scene the VRExperienceHelper belongs to.
  30178. * @param webVROptions Options to modify the vr experience helper's behavior.
  30179. */
  30180. constructor(scene: Scene, /** Options to modify the vr experience helper's behavior. */ webVROptions?: VRExperienceHelperOptions);
  30181. private _onDefaultMeshLoaded(webVRController);
  30182. private _onResize;
  30183. private _onFullscreenChange;
  30184. /**
  30185. * Gets a value indicating if we are currently in VR mode.
  30186. */
  30187. readonly isInVRMode: boolean;
  30188. private onVrDisplayPresentChange();
  30189. private onVRDisplayChanged(eventArgs);
  30190. private moveButtonToBottomRight();
  30191. private displayVRButton();
  30192. private updateButtonVisibility();
  30193. /**
  30194. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  30195. * Otherwise, will use the fullscreen API.
  30196. */
  30197. enterVR(): void;
  30198. /**
  30199. * Attempt to exit VR, or fullscreen.
  30200. */
  30201. exitVR(): void;
  30202. /**
  30203. * The position of the vr experience helper.
  30204. */
  30205. /**
  30206. * Sets the position of the vr experience helper.
  30207. */
  30208. position: Vector3;
  30209. /**
  30210. * Enables controllers and user interactions suck as selecting and object or clicking on an object.
  30211. */
  30212. enableInteractions(): void;
  30213. private beforeRender;
  30214. private _isTeleportationFloor(mesh);
  30215. /**
  30216. * Adds a floor mesh to be used for teleportation.
  30217. * @param floorMesh the mesh to be used for teleportation.
  30218. */
  30219. addFloorMesh(floorMesh: Mesh): void;
  30220. /**
  30221. * Removes a floor mesh from being used for teleportation.
  30222. * @param floorMesh the mesh to be removed.
  30223. */
  30224. removeFloorMesh(floorMesh: Mesh): void;
  30225. /**
  30226. * Enables interactions and teleportation using the VR controllers and gaze.
  30227. * @param vrTeleportationOptions options to modify teleportation behavior.
  30228. */
  30229. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  30230. private _onNewGamepadConnected;
  30231. private _tryEnableInteractionOnController;
  30232. private _onNewGamepadDisconnected;
  30233. private _enableInteractionOnController(controller);
  30234. private _checkTeleportWithRay(stateObject, gazer);
  30235. private _checkRotate(stateObject, gazer);
  30236. private _checkTeleportBackwards(stateObject, gazer);
  30237. private _enableTeleportationOnController(controller);
  30238. private _createTeleportationCircles();
  30239. private _displayTeleportationTarget();
  30240. private _hideTeleportationTarget();
  30241. private _rotateCamera(right);
  30242. private _moveTeleportationSelectorTo(hit, gazer, ray);
  30243. private _workingVector;
  30244. private _workingQuaternion;
  30245. private _workingMatrix;
  30246. private _teleportCamera(location);
  30247. private _convertNormalToDirectionOfRay(normal, ray);
  30248. private _castRayAndSelectObject(gazer);
  30249. private _notifySelectedMeshUnselected(mesh);
  30250. /**
  30251. * Sets the color of the laser ray from the vr controllers.
  30252. * @param color new color for the ray.
  30253. */
  30254. changeLaserColor(color: Color3): void;
  30255. /**
  30256. * Sets the color of the ray from the vr headsets gaze.
  30257. * @param color new color for the ray.
  30258. */
  30259. changeGazeColor(color: Color3): void;
  30260. /**
  30261. * Exits VR and disposes of the vr experience helper
  30262. */
  30263. dispose(): void;
  30264. /**
  30265. * Gets the name of the VRExperienceHelper class
  30266. * @returns "VRExperienceHelper"
  30267. */
  30268. getClassName(): string;
  30269. }
  30270. }
  30271. declare module BABYLON {
  30272. /**
  30273. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  30274. * IMPORTANT!! The data is right-hand data.
  30275. * @export
  30276. * @interface DevicePose
  30277. */
  30278. interface DevicePose {
  30279. /**
  30280. * The position of the device, values in array are [x,y,z].
  30281. */
  30282. readonly position: Nullable<Float32Array>;
  30283. /**
  30284. * The linearVelocity of the device, values in array are [x,y,z].
  30285. */
  30286. readonly linearVelocity: Nullable<Float32Array>;
  30287. /**
  30288. * The linearAcceleration of the device, values in array are [x,y,z].
  30289. */
  30290. readonly linearAcceleration: Nullable<Float32Array>;
  30291. /**
  30292. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  30293. */
  30294. readonly orientation: Nullable<Float32Array>;
  30295. /**
  30296. * The angularVelocity of the device, values in array are [x,y,z].
  30297. */
  30298. readonly angularVelocity: Nullable<Float32Array>;
  30299. /**
  30300. * The angularAcceleration of the device, values in array are [x,y,z].
  30301. */
  30302. readonly angularAcceleration: Nullable<Float32Array>;
  30303. }
  30304. /**
  30305. * Interface representing a pose controlled object in Babylon.
  30306. * A pose controlled object has both regular pose values as well as pose values
  30307. * from an external device such as a VR head mounted display
  30308. */
  30309. interface PoseControlled {
  30310. /**
  30311. * The position of the object in babylon space.
  30312. */
  30313. position: Vector3;
  30314. /**
  30315. * The rotation quaternion of the object in babylon space.
  30316. */
  30317. rotationQuaternion: Quaternion;
  30318. /**
  30319. * The position of the device in babylon space.
  30320. */
  30321. devicePosition?: Vector3;
  30322. /**
  30323. * The rotation quaternion of the device in babylon space.
  30324. */
  30325. deviceRotationQuaternion: Quaternion;
  30326. /**
  30327. * The raw pose coming from the device.
  30328. */
  30329. rawPose: Nullable<DevicePose>;
  30330. /**
  30331. * The scale of the device to be used when translating from device space to babylon space.
  30332. */
  30333. deviceScaleFactor: number;
  30334. /**
  30335. * Updates the poseControlled values based on the input device pose.
  30336. * @param poseData the pose data to update the object with
  30337. */
  30338. updateFromDevice(poseData: DevicePose): void;
  30339. }
  30340. /**
  30341. * Set of options to customize the webVRCamera
  30342. */
  30343. interface WebVROptions {
  30344. /**
  30345. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  30346. */
  30347. trackPosition?: boolean;
  30348. /**
  30349. * Sets the scale of the vrDevice in babylon space. (default: 1)
  30350. */
  30351. positionScale?: number;
  30352. /**
  30353. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  30354. */
  30355. displayName?: string;
  30356. /**
  30357. * Should the native controller meshes be initialized. (default: true)
  30358. */
  30359. controllerMeshes?: boolean;
  30360. /**
  30361. * Creating a default HemiLight only on controllers. (default: true)
  30362. */
  30363. defaultLightingOnControllers?: boolean;
  30364. /**
  30365. * If you don't want to use the default VR button of the helper. (default: false)
  30366. */
  30367. useCustomVRButton?: boolean;
  30368. /**
  30369. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  30370. */
  30371. customVRButton?: HTMLButtonElement;
  30372. /**
  30373. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  30374. */
  30375. rayLength?: number;
  30376. /**
  30377. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  30378. */
  30379. defaultHeight?: number;
  30380. }
  30381. /**
  30382. * This represents a WebVR camera.
  30383. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  30384. * @example http://doc.babylonjs.com/how_to/webvr_camera
  30385. */
  30386. class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  30387. private webVROptions;
  30388. /**
  30389. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  30390. */
  30391. _vrDevice: any;
  30392. /**
  30393. * The rawPose of the vrDevice.
  30394. */
  30395. rawPose: Nullable<DevicePose>;
  30396. private _onVREnabled;
  30397. private _specsVersion;
  30398. private _attached;
  30399. private _frameData;
  30400. protected _descendants: Array<Node>;
  30401. private _deviceRoomPosition;
  30402. private _deviceRoomRotationQuaternion;
  30403. private _standingMatrix;
  30404. /**
  30405. * Represents device position in babylon space.
  30406. */
  30407. devicePosition: Vector3;
  30408. /**
  30409. * Represents device rotation in babylon space.
  30410. */
  30411. deviceRotationQuaternion: Quaternion;
  30412. /**
  30413. * The scale of the device to be used when translating from device space to babylon space.
  30414. */
  30415. deviceScaleFactor: number;
  30416. private _deviceToWorld;
  30417. private _worldToDevice;
  30418. /**
  30419. * References to the webVR controllers for the vrDevice.
  30420. */
  30421. controllers: Array<WebVRController>;
  30422. /**
  30423. * Emits an event when a controller is attached.
  30424. */
  30425. onControllersAttachedObservable: Observable<WebVRController[]>;
  30426. /**
  30427. * Emits an event when a controller's mesh has been loaded;
  30428. */
  30429. onControllerMeshLoadedObservable: Observable<WebVRController>;
  30430. /**
  30431. * If the rig cameras be used as parent instead of this camera.
  30432. */
  30433. rigParenting: boolean;
  30434. private _lightOnControllers;
  30435. private _defaultHeight?;
  30436. /**
  30437. * Instantiates a WebVRFreeCamera.
  30438. * @param name The name of the WebVRFreeCamera
  30439. * @param position The starting anchor position for the camera
  30440. * @param scene The scene the camera belongs to
  30441. * @param webVROptions a set of customizable options for the webVRCamera
  30442. */
  30443. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  30444. /**
  30445. * Gets the device distance from the ground in meters.
  30446. * @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.
  30447. */
  30448. deviceDistanceToRoomGround(): number;
  30449. /**
  30450. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  30451. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  30452. */
  30453. useStandingMatrix(callback?: (bool: boolean) => void): void;
  30454. /**
  30455. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  30456. * @returns A promise with a boolean set to if the standing matrix is supported.
  30457. */
  30458. useStandingMatrixAsync(): Promise<boolean>;
  30459. /**
  30460. * Disposes the camera
  30461. */
  30462. dispose(): void;
  30463. /**
  30464. * Gets a vrController by name.
  30465. * @param name The name of the controller to retreive
  30466. * @returns the controller matching the name specified or null if not found
  30467. */
  30468. getControllerByName(name: string): Nullable<WebVRController>;
  30469. private _leftController;
  30470. /**
  30471. * The controller corrisponding to the users left hand.
  30472. */
  30473. readonly leftController: Nullable<WebVRController>;
  30474. private _rightController;
  30475. /**
  30476. * The controller corrisponding to the users right hand.
  30477. */
  30478. readonly rightController: Nullable<WebVRController>;
  30479. /**
  30480. * Casts a ray forward from the vrCamera's gaze.
  30481. * @param length Length of the ray (default: 100)
  30482. * @returns the ray corrisponding to the gaze
  30483. */
  30484. getForwardRay(length?: number): Ray;
  30485. /**
  30486. * Updates the camera based on device's frame data
  30487. */
  30488. _checkInputs(): void;
  30489. /**
  30490. * Updates the poseControlled values based on the input device pose.
  30491. * @param poseData Pose coming from the device
  30492. */
  30493. updateFromDevice(poseData: DevicePose): void;
  30494. /**
  30495. * WebVR's attach control will start broadcasting frames to the device.
  30496. * Note that in certain browsers (chrome for example) this function must be called
  30497. * within a user-interaction callback. Example:
  30498. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  30499. *
  30500. * @param element html element to attach the vrDevice to
  30501. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  30502. */
  30503. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  30504. /**
  30505. * Detaches the camera from the html element and disables VR
  30506. *
  30507. * @param element html element to detach from
  30508. */
  30509. detachControl(element: HTMLElement): void;
  30510. /**
  30511. * @returns the name of this class
  30512. */
  30513. getClassName(): string;
  30514. /**
  30515. * Calls resetPose on the vrDisplay
  30516. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  30517. */
  30518. resetToCurrentRotation(): void;
  30519. /**
  30520. * Updates the rig cameras (left and right eye)
  30521. */
  30522. _updateRigCameras(): void;
  30523. private _workingVector;
  30524. private _oneVector;
  30525. private _workingMatrix;
  30526. private updateCacheCalled;
  30527. /**
  30528. * Updates the cached values of the camera
  30529. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  30530. */
  30531. _updateCache(ignoreParentClass?: boolean): void;
  30532. /**
  30533. * Updates the current device position and rotation in the babylon world
  30534. */
  30535. update(): void;
  30536. /**
  30537. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  30538. * @returns an identity matrix
  30539. */
  30540. _getViewMatrix(): Matrix;
  30541. /**
  30542. * This function is called by the two RIG cameras.
  30543. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  30544. */
  30545. protected _getWebVRViewMatrix(): Matrix;
  30546. protected _getWebVRProjectionMatrix(): Matrix;
  30547. private _onGamepadConnectedObserver;
  30548. private _onGamepadDisconnectedObserver;
  30549. /**
  30550. * Initializes the controllers and their meshes
  30551. */
  30552. initControllers(): void;
  30553. }
  30554. }
  30555. declare module BABYLON {
  30556. /**
  30557. * Google Daydream controller
  30558. */
  30559. class DaydreamController extends WebVRController {
  30560. /**
  30561. * Base Url for the controller model.
  30562. */
  30563. static MODEL_BASE_URL: string;
  30564. /**
  30565. * File name for the controller model.
  30566. */
  30567. static MODEL_FILENAME: string;
  30568. /**
  30569. * Gamepad Id prefix used to identify Daydream Controller.
  30570. */
  30571. static readonly GAMEPAD_ID_PREFIX: string;
  30572. /**
  30573. * Creates a new DaydreamController from a gamepad
  30574. * @param vrGamepad the gamepad that the controller should be created from
  30575. */
  30576. constructor(vrGamepad: any);
  30577. /**
  30578. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  30579. * @param scene scene in which to add meshes
  30580. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  30581. */
  30582. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  30583. /**
  30584. * Called once for each button that changed state since the last frame
  30585. * @param buttonIdx Which button index changed
  30586. * @param state New state of the button
  30587. * @param changes Which properties on the state changed since last frame
  30588. */
  30589. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  30590. }
  30591. }
  30592. declare module BABYLON {
  30593. /**
  30594. * Gear VR Controller
  30595. */
  30596. class GearVRController extends WebVRController {
  30597. /**
  30598. * Base Url for the controller model.
  30599. */
  30600. static MODEL_BASE_URL: string;
  30601. /**
  30602. * File name for the controller model.
  30603. */
  30604. static MODEL_FILENAME: string;
  30605. /**
  30606. * Gamepad Id prefix used to identify this controller.
  30607. */
  30608. static readonly GAMEPAD_ID_PREFIX: string;
  30609. private readonly _buttonIndexToObservableNameMap;
  30610. /**
  30611. * Creates a new GearVRController from a gamepad
  30612. * @param vrGamepad the gamepad that the controller should be created from
  30613. */
  30614. constructor(vrGamepad: any);
  30615. /**
  30616. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  30617. * @param scene scene in which to add meshes
  30618. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  30619. */
  30620. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  30621. /**
  30622. * Called once for each button that changed state since the last frame
  30623. * @param buttonIdx Which button index changed
  30624. * @param state New state of the button
  30625. * @param changes Which properties on the state changed since last frame
  30626. */
  30627. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  30628. }
  30629. }
  30630. declare module BABYLON {
  30631. /**
  30632. * Generic Controller
  30633. */
  30634. class GenericController extends WebVRController {
  30635. /**
  30636. * Base Url for the controller model.
  30637. */
  30638. static readonly MODEL_BASE_URL: string;
  30639. /**
  30640. * File name for the controller model.
  30641. */
  30642. static readonly MODEL_FILENAME: string;
  30643. /**
  30644. * Creates a new GenericController from a gamepad
  30645. * @param vrGamepad the gamepad that the controller should be created from
  30646. */
  30647. constructor(vrGamepad: any);
  30648. /**
  30649. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  30650. * @param scene scene in which to add meshes
  30651. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  30652. */
  30653. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  30654. /**
  30655. * Called once for each button that changed state since the last frame
  30656. * @param buttonIdx Which button index changed
  30657. * @param state New state of the button
  30658. * @param changes Which properties on the state changed since last frame
  30659. */
  30660. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  30661. }
  30662. }
  30663. declare module BABYLON {
  30664. /**
  30665. * Oculus Touch Controller
  30666. */
  30667. class OculusTouchController extends WebVRController {
  30668. /**
  30669. * Base Url for the controller model.
  30670. */
  30671. static MODEL_BASE_URL: string;
  30672. /**
  30673. * File name for the left controller model.
  30674. */
  30675. static MODEL_LEFT_FILENAME: string;
  30676. /**
  30677. * File name for the right controller model.
  30678. */
  30679. static MODEL_RIGHT_FILENAME: string;
  30680. /**
  30681. * Fired when the secondary trigger on this controller is modified
  30682. */
  30683. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  30684. /**
  30685. * Fired when the thumb rest on this controller is modified
  30686. */
  30687. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  30688. /**
  30689. * Creates a new OculusTouchController from a gamepad
  30690. * @param vrGamepad the gamepad that the controller should be created from
  30691. */
  30692. constructor(vrGamepad: any);
  30693. /**
  30694. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  30695. * @param scene scene in which to add meshes
  30696. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  30697. */
  30698. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  30699. /**
  30700. * Fired when the A button on this controller is modified
  30701. */
  30702. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  30703. /**
  30704. * Fired when the B button on this controller is modified
  30705. */
  30706. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  30707. /**
  30708. * Fired when the X button on this controller is modified
  30709. */
  30710. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  30711. /**
  30712. * Fired when the Y button on this controller is modified
  30713. */
  30714. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  30715. /**
  30716. * Called once for each button that changed state since the last frame
  30717. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  30718. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  30719. * 2) secondary trigger (same)
  30720. * 3) A (right) X (left), touch, pressed = value
  30721. * 4) B / Y
  30722. * 5) thumb rest
  30723. * @param buttonIdx Which button index changed
  30724. * @param state New state of the button
  30725. * @param changes Which properties on the state changed since last frame
  30726. */
  30727. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  30728. }
  30729. }
  30730. declare module BABYLON {
  30731. /**
  30732. * Defines the types of pose enabled controllers that are supported
  30733. */
  30734. enum PoseEnabledControllerType {
  30735. /**
  30736. * HTC Vive
  30737. */
  30738. VIVE = 0,
  30739. /**
  30740. * Oculus Rift
  30741. */
  30742. OCULUS = 1,
  30743. /**
  30744. * Windows mixed reality
  30745. */
  30746. WINDOWS = 2,
  30747. /**
  30748. * Samsung gear VR
  30749. */
  30750. GEAR_VR = 3,
  30751. /**
  30752. * Google Daydream
  30753. */
  30754. DAYDREAM = 4,
  30755. /**
  30756. * Generic
  30757. */
  30758. GENERIC = 5,
  30759. }
  30760. /**
  30761. * Defines the MutableGamepadButton interface for the state of a gamepad button
  30762. */
  30763. interface MutableGamepadButton {
  30764. /**
  30765. * Value of the button/trigger
  30766. */
  30767. value: number;
  30768. /**
  30769. * If the button/trigger is currently touched
  30770. */
  30771. touched: boolean;
  30772. /**
  30773. * If the button/trigger is currently pressed
  30774. */
  30775. pressed: boolean;
  30776. }
  30777. /**
  30778. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  30779. * @hidden
  30780. */
  30781. interface ExtendedGamepadButton extends GamepadButton {
  30782. /**
  30783. * If the button/trigger is currently pressed
  30784. */
  30785. readonly pressed: boolean;
  30786. /**
  30787. * If the button/trigger is currently touched
  30788. */
  30789. readonly touched: boolean;
  30790. /**
  30791. * Value of the button/trigger
  30792. */
  30793. readonly value: number;
  30794. }
  30795. /**
  30796. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  30797. */
  30798. class PoseEnabledControllerHelper {
  30799. /**
  30800. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  30801. * @param vrGamepad the gamepad to initialized
  30802. * @returns a vr controller of the type the gamepad identified as
  30803. */
  30804. static InitiateController(vrGamepad: any): OculusTouchController | WindowsMotionController | ViveController | GearVRController | DaydreamController | GenericController;
  30805. }
  30806. /**
  30807. * Defines the PoseEnabledController object that contains state of a vr capable controller
  30808. */
  30809. class PoseEnabledController extends Gamepad implements PoseControlled {
  30810. private _deviceRoomPosition;
  30811. private _deviceRoomRotationQuaternion;
  30812. /**
  30813. * The device position in babylon space
  30814. */
  30815. devicePosition: Vector3;
  30816. /**
  30817. * The device rotation in babylon space
  30818. */
  30819. deviceRotationQuaternion: Quaternion;
  30820. /**
  30821. * The scale factor of the device in babylon space
  30822. */
  30823. deviceScaleFactor: number;
  30824. /**
  30825. * (Likely devicePosition should be used instead) The device position in its room space
  30826. */
  30827. position: Vector3;
  30828. /**
  30829. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  30830. */
  30831. rotationQuaternion: Quaternion;
  30832. /**
  30833. * The type of controller (Eg. Windows mixed reality)
  30834. */
  30835. controllerType: PoseEnabledControllerType;
  30836. protected _calculatedPosition: Vector3;
  30837. private _calculatedRotation;
  30838. /**
  30839. * The raw pose from the device
  30840. */
  30841. rawPose: DevicePose;
  30842. /**
  30843. * Internal, the mesh attached to the controller
  30844. */
  30845. _mesh: Nullable<AbstractMesh>;
  30846. private _poseControlledCamera;
  30847. private _leftHandSystemQuaternion;
  30848. /**
  30849. * Internal, matrix used to convert room space to babylon space
  30850. */
  30851. _deviceToWorld: Matrix;
  30852. /**
  30853. * Node to be used when casting a ray from the controller
  30854. */
  30855. _pointingPoseNode: Nullable<AbstractMesh>;
  30856. /**
  30857. * Name of the child mesh that can be used to cast a ray from the controller
  30858. */
  30859. static readonly POINTING_POSE: string;
  30860. /**
  30861. * Creates a new PoseEnabledController from a gamepad
  30862. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  30863. */
  30864. constructor(browserGamepad: any);
  30865. private _workingMatrix;
  30866. /**
  30867. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  30868. */
  30869. update(): void;
  30870. /**
  30871. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  30872. * @param poseData raw pose fromthe device
  30873. */
  30874. updateFromDevice(poseData: DevicePose): void;
  30875. /**
  30876. * @hidden
  30877. */
  30878. _meshAttachedObservable: Observable<AbstractMesh>;
  30879. /**
  30880. * Attaches a mesh to the controller
  30881. * @param mesh the mesh to be attached
  30882. */
  30883. attachToMesh(mesh: AbstractMesh): void;
  30884. /**
  30885. * Attaches the controllers mesh to a camera
  30886. * @param camera the camera the mesh should be attached to
  30887. */
  30888. attachToPoseControlledCamera(camera: TargetCamera): void;
  30889. /**
  30890. * Disposes of the controller
  30891. */
  30892. dispose(): void;
  30893. /**
  30894. * The mesh that is attached to the controller
  30895. */
  30896. readonly mesh: Nullable<AbstractMesh>;
  30897. /**
  30898. * Gets the ray of the controller in the direction the controller is pointing
  30899. * @param length the length the resulting ray should be
  30900. * @returns a ray in the direction the controller is pointing
  30901. */
  30902. getForwardRay(length?: number): Ray;
  30903. }
  30904. }
  30905. declare module BABYLON {
  30906. /**
  30907. * Vive Controller
  30908. */
  30909. class ViveController extends WebVRController {
  30910. /**
  30911. * Base Url for the controller model.
  30912. */
  30913. static MODEL_BASE_URL: string;
  30914. /**
  30915. * File name for the controller model.
  30916. */
  30917. static MODEL_FILENAME: string;
  30918. /**
  30919. * Creates a new ViveController from a gamepad
  30920. * @param vrGamepad the gamepad that the controller should be created from
  30921. */
  30922. constructor(vrGamepad: any);
  30923. /**
  30924. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  30925. * @param scene scene in which to add meshes
  30926. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  30927. */
  30928. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  30929. /**
  30930. * Fired when the left button on this controller is modified
  30931. */
  30932. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  30933. /**
  30934. * Fired when the right button on this controller is modified
  30935. */
  30936. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  30937. /**
  30938. * Fired when the menu button on this controller is modified
  30939. */
  30940. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  30941. /**
  30942. * Called once for each button that changed state since the last frame
  30943. * Vive mapping:
  30944. * 0: touchpad
  30945. * 1: trigger
  30946. * 2: left AND right buttons
  30947. * 3: menu button
  30948. * @param buttonIdx Which button index changed
  30949. * @param state New state of the button
  30950. * @param changes Which properties on the state changed since last frame
  30951. */
  30952. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  30953. }
  30954. }
  30955. declare module BABYLON {
  30956. /**
  30957. * Defines the WebVRController object that represents controllers tracked in 3D space
  30958. */
  30959. abstract class WebVRController extends PoseEnabledController {
  30960. /**
  30961. * Internal, the default controller model for the controller
  30962. */
  30963. protected _defaultModel: AbstractMesh;
  30964. /**
  30965. * Fired when the trigger state has changed
  30966. */
  30967. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  30968. /**
  30969. * Fired when the main button state has changed
  30970. */
  30971. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  30972. /**
  30973. * Fired when the secondary button state has changed
  30974. */
  30975. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  30976. /**
  30977. * Fired when the pad state has changed
  30978. */
  30979. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  30980. /**
  30981. * Fired when controllers stick values have changed
  30982. */
  30983. onPadValuesChangedObservable: Observable<StickValues>;
  30984. /**
  30985. * Array of button availible on the controller
  30986. */
  30987. protected _buttons: Array<MutableGamepadButton>;
  30988. private _onButtonStateChange;
  30989. /**
  30990. * Fired when a controller button's state has changed
  30991. * @param callback the callback containing the button that was modified
  30992. */
  30993. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  30994. /**
  30995. * X and Y axis corrisponding to the controllers joystick
  30996. */
  30997. pad: StickValues;
  30998. /**
  30999. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  31000. */
  31001. hand: string;
  31002. /**
  31003. * The default controller model for the controller
  31004. */
  31005. readonly defaultModel: AbstractMesh;
  31006. /**
  31007. * Creates a new WebVRController from a gamepad
  31008. * @param vrGamepad the gamepad that the WebVRController should be created from
  31009. */
  31010. constructor(vrGamepad: any);
  31011. /**
  31012. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  31013. */
  31014. update(): void;
  31015. /**
  31016. * Function to be called when a button is modified
  31017. */
  31018. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  31019. /**
  31020. * Loads a mesh and attaches it to the controller
  31021. * @param scene the scene the mesh should be added to
  31022. * @param meshLoaded callback for when the mesh has been loaded
  31023. */
  31024. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  31025. private _setButtonValue(newState, currentState, buttonIndex);
  31026. private _changes;
  31027. private _checkChanges(newState, currentState);
  31028. /**
  31029. * Disposes of th webVRCOntroller
  31030. */
  31031. dispose(): void;
  31032. }
  31033. }
  31034. declare module BABYLON {
  31035. /**
  31036. * Defines the WindowsMotionController object that the state of the windows motion controller
  31037. */
  31038. class WindowsMotionController extends WebVRController {
  31039. /**
  31040. * The base url used to load the left and right controller models
  31041. */
  31042. static MODEL_BASE_URL: string;
  31043. /**
  31044. * The name of the left controller model file
  31045. */
  31046. static MODEL_LEFT_FILENAME: string;
  31047. /**
  31048. * The name of the right controller model file
  31049. */
  31050. static MODEL_RIGHT_FILENAME: string;
  31051. /**
  31052. * The controller name prefix for this controller type
  31053. */
  31054. static readonly GAMEPAD_ID_PREFIX: string;
  31055. /**
  31056. * The controller id pattern for this controller type
  31057. */
  31058. private static readonly GAMEPAD_ID_PATTERN;
  31059. private _loadedMeshInfo;
  31060. private readonly _mapping;
  31061. /**
  31062. * Fired when the trackpad on this controller is clicked
  31063. */
  31064. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  31065. /**
  31066. * Fired when the trackpad on this controller is modified
  31067. */
  31068. onTrackpadValuesChangedObservable: Observable<StickValues>;
  31069. /**
  31070. * The current x and y values of this controller's trackpad
  31071. */
  31072. trackpad: StickValues;
  31073. /**
  31074. * Creates a new WindowsMotionController from a gamepad
  31075. * @param vrGamepad the gamepad that the controller should be created from
  31076. */
  31077. constructor(vrGamepad: any);
  31078. /**
  31079. * Fired when the trigger on this controller is modified
  31080. */
  31081. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  31082. /**
  31083. * Fired when the menu button on this controller is modified
  31084. */
  31085. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  31086. /**
  31087. * Fired when the grip button on this controller is modified
  31088. */
  31089. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  31090. /**
  31091. * Fired when the thumbstick button on this controller is modified
  31092. */
  31093. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  31094. /**
  31095. * Fired when the touchpad button on this controller is modified
  31096. */
  31097. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  31098. /**
  31099. * Fired when the touchpad values on this controller are modified
  31100. */
  31101. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  31102. /**
  31103. * Called once per frame by the engine.
  31104. */
  31105. update(): void;
  31106. /**
  31107. * Called once for each button that changed state since the last frame
  31108. * @param buttonIdx Which button index changed
  31109. * @param state New state of the button
  31110. * @param changes Which properties on the state changed since last frame
  31111. */
  31112. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  31113. /**
  31114. * Moves the buttons on the controller mesh based on their current state
  31115. * @param buttonName the name of the button to move
  31116. * @param buttonValue the value of the button which determines the buttons new position
  31117. */
  31118. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  31119. /**
  31120. * Moves the axis on the controller mesh based on its current state
  31121. * @param axis the index of the axis
  31122. * @param axisValue the value of the axis which determines the meshes new position
  31123. * @hidden
  31124. */
  31125. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  31126. /**
  31127. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  31128. * @param scene scene in which to add meshes
  31129. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  31130. */
  31131. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  31132. /**
  31133. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  31134. * can be transformed by button presses and axes values, based on this._mapping.
  31135. *
  31136. * @param scene scene in which the meshes exist
  31137. * @param meshes list of meshes that make up the controller model to process
  31138. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  31139. */
  31140. private processModel(scene, meshes);
  31141. private createMeshInfo(rootNode);
  31142. /**
  31143. * Gets the ray of the controller in the direction the controller is pointing
  31144. * @param length the length the resulting ray should be
  31145. * @returns a ray in the direction the controller is pointing
  31146. */
  31147. getForwardRay(length?: number): Ray;
  31148. /**
  31149. * Disposes of the controller
  31150. */
  31151. dispose(): void;
  31152. }
  31153. }
  31154. declare module BABYLON {
  31155. /**
  31156. * Interface to implement to create a shadow generator compatible with BJS.
  31157. */
  31158. interface IShadowGenerator {
  31159. /**
  31160. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  31161. * @returns The render target texture if present otherwise, null
  31162. */
  31163. getShadowMap(): Nullable<RenderTargetTexture>;
  31164. /**
  31165. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  31166. * @returns The render target texture if the shadow map is present otherwise, null
  31167. */
  31168. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  31169. /**
  31170. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  31171. * @param subMesh The submesh we want to render in the shadow map
  31172. * @param useInstances Defines wether will draw in the map using instances
  31173. * @returns true if ready otherwise, false
  31174. */
  31175. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  31176. /**
  31177. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  31178. * @param defines Defines of the material we want to update
  31179. * @param lightIndex Index of the light in the enabled light list of the material
  31180. */
  31181. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  31182. /**
  31183. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  31184. * defined in the generator but impacting the effect).
  31185. * It implies the unifroms available on the materials are the standard BJS ones.
  31186. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  31187. * @param effect The effect we are binfing the information for
  31188. */
  31189. bindShadowLight(lightIndex: string, effect: Effect): void;
  31190. /**
  31191. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  31192. * (eq to shadow prjection matrix * light transform matrix)
  31193. * @returns The transform matrix used to create the shadow map
  31194. */
  31195. getTransformMatrix(): Matrix;
  31196. /**
  31197. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  31198. * Cube and 2D textures for instance.
  31199. */
  31200. recreateShadowMap(): void;
  31201. /**
  31202. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  31203. * @param onCompiled Callback triggered at the and of the effects compilation
  31204. * @param options Sets of optional options forcing the compilation with different modes
  31205. */
  31206. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  31207. useInstances: boolean;
  31208. }>): void;
  31209. /**
  31210. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  31211. * @param options Sets of optional options forcing the compilation with different modes
  31212. * @returns A promise that resolves when the compilation completes
  31213. */
  31214. forceCompilationAsync(options?: Partial<{
  31215. useInstances: boolean;
  31216. }>): Promise<void>;
  31217. /**
  31218. * Serializes the shadow generator setup to a json object.
  31219. * @returns The serialized JSON object
  31220. */
  31221. serialize(): any;
  31222. /**
  31223. * Disposes the Shadow map and related Textures and effects.
  31224. */
  31225. dispose(): void;
  31226. }
  31227. /**
  31228. * Default implementation IShadowGenerator.
  31229. * This is the main object responsible of generating shadows in the framework.
  31230. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  31231. */
  31232. class ShadowGenerator implements IShadowGenerator {
  31233. /**
  31234. * Shadow generator mode None: no filtering applied.
  31235. */
  31236. static readonly FILTER_NONE: number;
  31237. /**
  31238. * Shadow generator mode ESM: Exponential Shadow Mapping.
  31239. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  31240. */
  31241. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  31242. /**
  31243. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  31244. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  31245. */
  31246. static readonly FILTER_POISSONSAMPLING: number;
  31247. /**
  31248. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  31249. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  31250. */
  31251. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  31252. /**
  31253. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  31254. * edge artifacts on steep falloff.
  31255. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  31256. */
  31257. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  31258. /**
  31259. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  31260. * edge artifacts on steep falloff.
  31261. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  31262. */
  31263. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  31264. /**
  31265. * Shadow generator mode PCF: Percentage Closer Filtering
  31266. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  31267. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  31268. */
  31269. static readonly FILTER_PCF: number;
  31270. /**
  31271. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  31272. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  31273. * Contact Hardening
  31274. */
  31275. static readonly FILTER_PCSS: number;
  31276. /**
  31277. * Reserved for PCF and PCSS
  31278. * Highest Quality.
  31279. *
  31280. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  31281. *
  31282. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  31283. */
  31284. static readonly QUALITY_HIGH: number;
  31285. /**
  31286. * Reserved for PCF and PCSS
  31287. * Good tradeoff for quality/perf cross devices
  31288. *
  31289. * Execute PCF on a 3*3 kernel.
  31290. *
  31291. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  31292. */
  31293. static readonly QUALITY_MEDIUM: number;
  31294. /**
  31295. * Reserved for PCF and PCSS
  31296. * The lowest quality but the fastest.
  31297. *
  31298. * Execute PCF on a 1*1 kernel.
  31299. *
  31300. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  31301. */
  31302. static readonly QUALITY_LOW: number;
  31303. private _bias;
  31304. /**
  31305. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  31306. */
  31307. /**
  31308. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  31309. */
  31310. bias: number;
  31311. private _normalBias;
  31312. /**
  31313. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  31314. */
  31315. /**
  31316. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  31317. */
  31318. normalBias: number;
  31319. private _blurBoxOffset;
  31320. /**
  31321. * Gets the blur box offset: offset applied during the blur pass.
  31322. * Only usefull if useKernelBlur = false
  31323. */
  31324. /**
  31325. * Sets the blur box offset: offset applied during the blur pass.
  31326. * Only usefull if useKernelBlur = false
  31327. */
  31328. blurBoxOffset: number;
  31329. private _blurScale;
  31330. /**
  31331. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  31332. * 2 means half of the size.
  31333. */
  31334. /**
  31335. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  31336. * 2 means half of the size.
  31337. */
  31338. blurScale: number;
  31339. private _blurKernel;
  31340. /**
  31341. * Gets the blur kernel: kernel size of the blur pass.
  31342. * Only usefull if useKernelBlur = true
  31343. */
  31344. /**
  31345. * Sets the blur kernel: kernel size of the blur pass.
  31346. * Only usefull if useKernelBlur = true
  31347. */
  31348. blurKernel: number;
  31349. private _useKernelBlur;
  31350. /**
  31351. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  31352. * Only usefull in filtered mode (useBlurExponentialShadowMap...)
  31353. */
  31354. /**
  31355. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  31356. * Only usefull in filtered mode (useBlurExponentialShadowMap...)
  31357. */
  31358. useKernelBlur: boolean;
  31359. private _depthScale;
  31360. /**
  31361. * Gets the depth scale used in ESM mode.
  31362. */
  31363. /**
  31364. * Sets the depth scale used in ESM mode.
  31365. * This can override the scale stored on the light.
  31366. */
  31367. depthScale: number;
  31368. private _filter;
  31369. /**
  31370. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  31371. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  31372. */
  31373. /**
  31374. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  31375. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  31376. */
  31377. filter: number;
  31378. /**
  31379. * Gets if the current filter is set to Poisson Sampling.
  31380. */
  31381. /**
  31382. * Sets the current filter to Poisson Sampling.
  31383. */
  31384. usePoissonSampling: boolean;
  31385. /**
  31386. * Gets if the current filter is set to VSM.
  31387. * DEPRECATED. Should use useExponentialShadowMap instead.
  31388. */
  31389. /**
  31390. * Sets the current filter is to VSM.
  31391. * DEPRECATED. Should use useExponentialShadowMap instead.
  31392. */
  31393. useVarianceShadowMap: boolean;
  31394. /**
  31395. * Gets if the current filter is set to blurred VSM.
  31396. * DEPRECATED. Should use useBlurExponentialShadowMap instead.
  31397. */
  31398. /**
  31399. * Sets the current filter is to blurred VSM.
  31400. * DEPRECATED. Should use useBlurExponentialShadowMap instead.
  31401. */
  31402. useBlurVarianceShadowMap: boolean;
  31403. /**
  31404. * Gets if the current filter is set to ESM.
  31405. */
  31406. /**
  31407. * Sets the current filter is to ESM.
  31408. */
  31409. useExponentialShadowMap: boolean;
  31410. /**
  31411. * Gets if the current filter is set to filtered ESM.
  31412. */
  31413. /**
  31414. * Gets if the current filter is set to filtered ESM.
  31415. */
  31416. useBlurExponentialShadowMap: boolean;
  31417. /**
  31418. * Gets if the current filter is set to "close ESM" (using the inverse of the
  31419. * exponential to prevent steep falloff artifacts).
  31420. */
  31421. /**
  31422. * Sets the current filter to "close ESM" (using the inverse of the
  31423. * exponential to prevent steep falloff artifacts).
  31424. */
  31425. useCloseExponentialShadowMap: boolean;
  31426. /**
  31427. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  31428. * exponential to prevent steep falloff artifacts).
  31429. */
  31430. /**
  31431. * Sets the current filter to filtered "close ESM" (using the inverse of the
  31432. * exponential to prevent steep falloff artifacts).
  31433. */
  31434. useBlurCloseExponentialShadowMap: boolean;
  31435. /**
  31436. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  31437. */
  31438. /**
  31439. * Sets the current filter to "PCF" (percentage closer filtering).
  31440. */
  31441. usePercentageCloserFiltering: boolean;
  31442. private _filteringQuality;
  31443. /**
  31444. * Gets the PCF or PCSS Quality.
  31445. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  31446. */
  31447. /**
  31448. * Sets the PCF or PCSS Quality.
  31449. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  31450. */
  31451. filteringQuality: number;
  31452. /**
  31453. * Gets if the current filter is set to "PCSS" (contact hardening).
  31454. */
  31455. /**
  31456. * Sets the current filter to "PCSS" (contact hardening).
  31457. */
  31458. useContactHardeningShadow: boolean;
  31459. private _contactHardeningLightSizeUVRatio;
  31460. /**
  31461. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  31462. * Using a ratio helps keeping shape stability independently of the map size.
  31463. *
  31464. * It does not account for the light projection as it was having too much
  31465. * instability during the light setup or during light position changes.
  31466. *
  31467. * Only valid if useContactHardeningShadow is true.
  31468. */
  31469. /**
  31470. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  31471. * Using a ratio helps keeping shape stability independently of the map size.
  31472. *
  31473. * It does not account for the light projection as it was having too much
  31474. * instability during the light setup or during light position changes.
  31475. *
  31476. * Only valid if useContactHardeningShadow is true.
  31477. */
  31478. contactHardeningLightSizeUVRatio: number;
  31479. private _darkness;
  31480. /**
  31481. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  31482. * 0 means strongest and 1 would means no shadow.
  31483. * @returns the darkness.
  31484. */
  31485. getDarkness(): number;
  31486. /**
  31487. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  31488. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  31489. * @returns the shadow generator allowing fluent coding.
  31490. */
  31491. setDarkness(darkness: number): ShadowGenerator;
  31492. private _transparencyShadow;
  31493. /**
  31494. * Sets the ability to have transparent shadow (boolean).
  31495. * @param transparent True if transparent else False
  31496. * @returns the shadow generator allowing fluent coding
  31497. */
  31498. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  31499. private _shadowMap;
  31500. private _shadowMap2;
  31501. /**
  31502. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  31503. * @returns The render target texture if present otherwise, null
  31504. */
  31505. getShadowMap(): Nullable<RenderTargetTexture>;
  31506. /**
  31507. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  31508. * @returns The render target texture if the shadow map is present otherwise, null
  31509. */
  31510. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  31511. /**
  31512. * Helper function to add a mesh and its descendants to the list of shadow casters.
  31513. * @param mesh Mesh to add
  31514. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  31515. * @returns the Shadow Generator itself
  31516. */
  31517. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  31518. /**
  31519. * Helper function to remove a mesh and its descendants from the list of shadow casters
  31520. * @param mesh Mesh to remove
  31521. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  31522. * @returns the Shadow Generator itself
  31523. */
  31524. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  31525. /**
  31526. * Controls the extent to which the shadows fade out at the edge of the frustum
  31527. * Used only by directionals and spots
  31528. */
  31529. frustumEdgeFalloff: number;
  31530. private _light;
  31531. /**
  31532. * Returns the associated light object.
  31533. * @returns the light generating the shadow
  31534. */
  31535. getLight(): IShadowLight;
  31536. /**
  31537. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  31538. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  31539. * It might on the other hand introduce peter panning.
  31540. */
  31541. forceBackFacesOnly: boolean;
  31542. private _scene;
  31543. private _lightDirection;
  31544. private _effect;
  31545. private _viewMatrix;
  31546. private _projectionMatrix;
  31547. private _transformMatrix;
  31548. private _cachedPosition;
  31549. private _cachedDirection;
  31550. private _cachedDefines;
  31551. private _currentRenderID;
  31552. private _boxBlurPostprocess;
  31553. private _kernelBlurXPostprocess;
  31554. private _kernelBlurYPostprocess;
  31555. private _blurPostProcesses;
  31556. private _mapSize;
  31557. private _currentFaceIndex;
  31558. private _currentFaceIndexCache;
  31559. private _textureType;
  31560. private _defaultTextureMatrix;
  31561. /**
  31562. * Creates a ShadowGenerator object.
  31563. * A ShadowGenerator is the required tool to use the shadows.
  31564. * Each light casting shadows needs to use its own ShadowGenerator.
  31565. * Documentation : http://doc.babylonjs.com/tutorials/shadows
  31566. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  31567. * @param light The light object generating the shadows.
  31568. * @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.
  31569. */
  31570. constructor(mapSize: number, light: IShadowLight, useFullFloatFirst?: boolean);
  31571. private _initializeGenerator();
  31572. private _initializeShadowMap();
  31573. private _initializeBlurRTTAndPostProcesses();
  31574. private _renderForShadowMap(opaqueSubMeshes, alphaTestSubMeshes, transparentSubMeshes, depthOnlySubMeshes);
  31575. private _renderSubMeshForShadowMap(subMesh);
  31576. private _applyFilterValues();
  31577. /**
  31578. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  31579. * @param onCompiled Callback triggered at the and of the effects compilation
  31580. * @param options Sets of optional options forcing the compilation with different modes
  31581. */
  31582. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  31583. useInstances: boolean;
  31584. }>): void;
  31585. /**
  31586. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  31587. * @param options Sets of optional options forcing the compilation with different modes
  31588. * @returns A promise that resolves when the compilation completes
  31589. */
  31590. forceCompilationAsync(options?: Partial<{
  31591. useInstances: boolean;
  31592. }>): Promise<void>;
  31593. /**
  31594. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  31595. * @param subMesh The submesh we want to render in the shadow map
  31596. * @param useInstances Defines wether will draw in the map using instances
  31597. * @returns true if ready otherwise, false
  31598. */
  31599. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  31600. /**
  31601. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  31602. * @param defines Defines of the material we want to update
  31603. * @param lightIndex Index of the light in the enabled light list of the material
  31604. */
  31605. prepareDefines(defines: any, lightIndex: number): void;
  31606. /**
  31607. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  31608. * defined in the generator but impacting the effect).
  31609. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  31610. * @param effect The effect we are binfing the information for
  31611. */
  31612. bindShadowLight(lightIndex: string, effect: Effect): void;
  31613. /**
  31614. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  31615. * (eq to shadow prjection matrix * light transform matrix)
  31616. * @returns The transform matrix used to create the shadow map
  31617. */
  31618. getTransformMatrix(): Matrix;
  31619. /**
  31620. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  31621. * Cube and 2D textures for instance.
  31622. */
  31623. recreateShadowMap(): void;
  31624. private _disposeBlurPostProcesses();
  31625. private _disposeRTTandPostProcesses();
  31626. /**
  31627. * Disposes the ShadowGenerator.
  31628. * Returns nothing.
  31629. */
  31630. dispose(): void;
  31631. /**
  31632. * Serializes the shadow generator setup to a json object.
  31633. * @returns The serialized JSON object
  31634. */
  31635. serialize(): any;
  31636. /**
  31637. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  31638. * @param parsedShadowGenerator The JSON object to parse
  31639. * @param scene The scene to create the shadow map for
  31640. * @returns The parsed shadow generator
  31641. */
  31642. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  31643. }
  31644. }
  31645. declare module BABYLON {
  31646. }
  31647. declare module BABYLON {
  31648. /**
  31649. * Background material used to create an efficient environement around your scene.
  31650. */
  31651. class BackgroundMaterial extends PushMaterial {
  31652. /**
  31653. * Standard reflectance value at parallel view angle.
  31654. */
  31655. static StandardReflectance0: number;
  31656. /**
  31657. * Standard reflectance value at grazing angle.
  31658. */
  31659. static StandardReflectance90: number;
  31660. protected _primaryColor: Color3;
  31661. /**
  31662. * Key light Color (multiply against the environement texture)
  31663. */
  31664. primaryColor: Color3;
  31665. protected __perceptualColor: Nullable<Color3>;
  31666. /**
  31667. * Experimental Internal Use Only.
  31668. *
  31669. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  31670. * This acts as a helper to set the primary color to a more "human friendly" value.
  31671. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  31672. * output color as close as possible from the chosen value.
  31673. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  31674. * part of lighting setup.)
  31675. */
  31676. _perceptualColor: Nullable<Color3>;
  31677. protected _primaryColorShadowLevel: float;
  31678. /**
  31679. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  31680. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  31681. */
  31682. primaryColorShadowLevel: float;
  31683. protected _primaryColorHighlightLevel: float;
  31684. /**
  31685. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  31686. * The primary color is used at the level chosen to define what the white area would look.
  31687. */
  31688. primaryColorHighlightLevel: float;
  31689. protected _reflectionTexture: Nullable<BaseTexture>;
  31690. /**
  31691. * Reflection Texture used in the material.
  31692. * Should be author in a specific way for the best result (refer to the documentation).
  31693. */
  31694. reflectionTexture: Nullable<BaseTexture>;
  31695. protected _reflectionBlur: float;
  31696. /**
  31697. * Reflection Texture level of blur.
  31698. *
  31699. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  31700. * texture twice.
  31701. */
  31702. reflectionBlur: float;
  31703. protected _diffuseTexture: Nullable<BaseTexture>;
  31704. /**
  31705. * Diffuse Texture used in the material.
  31706. * Should be author in a specific way for the best result (refer to the documentation).
  31707. */
  31708. diffuseTexture: Nullable<BaseTexture>;
  31709. protected _shadowLights: Nullable<IShadowLight[]>;
  31710. /**
  31711. * Specify the list of lights casting shadow on the material.
  31712. * All scene shadow lights will be included if null.
  31713. */
  31714. shadowLights: Nullable<IShadowLight[]>;
  31715. protected _shadowLevel: float;
  31716. /**
  31717. * Helps adjusting the shadow to a softer level if required.
  31718. * 0 means black shadows and 1 means no shadows.
  31719. */
  31720. shadowLevel: float;
  31721. protected _sceneCenter: Vector3;
  31722. /**
  31723. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  31724. * It is usually zero but might be interesting to modify according to your setup.
  31725. */
  31726. sceneCenter: Vector3;
  31727. protected _opacityFresnel: boolean;
  31728. /**
  31729. * This helps specifying that the material is falling off to the sky box at grazing angle.
  31730. * This helps ensuring a nice transition when the camera goes under the ground.
  31731. */
  31732. opacityFresnel: boolean;
  31733. protected _reflectionFresnel: boolean;
  31734. /**
  31735. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  31736. * This helps adding a mirror texture on the ground.
  31737. */
  31738. reflectionFresnel: boolean;
  31739. protected _reflectionFalloffDistance: number;
  31740. /**
  31741. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  31742. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  31743. */
  31744. reflectionFalloffDistance: number;
  31745. protected _reflectionAmount: number;
  31746. /**
  31747. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  31748. */
  31749. reflectionAmount: number;
  31750. protected _reflectionReflectance0: number;
  31751. /**
  31752. * This specifies the weight of the reflection at grazing angle.
  31753. */
  31754. reflectionReflectance0: number;
  31755. protected _reflectionReflectance90: number;
  31756. /**
  31757. * This specifies the weight of the reflection at a perpendicular point of view.
  31758. */
  31759. reflectionReflectance90: number;
  31760. /**
  31761. * Sets the reflection reflectance fresnel values according to the default standard
  31762. * empirically know to work well :-)
  31763. */
  31764. reflectionStandardFresnelWeight: number;
  31765. protected _useRGBColor: boolean;
  31766. /**
  31767. * Helps to directly use the maps channels instead of their level.
  31768. */
  31769. useRGBColor: boolean;
  31770. protected _enableNoise: boolean;
  31771. /**
  31772. * This helps reducing the banding effect that could occur on the background.
  31773. */
  31774. enableNoise: boolean;
  31775. /**
  31776. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  31777. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  31778. * Recommended to be keep at 1.0 except for special cases.
  31779. */
  31780. fovMultiplier: number;
  31781. private _fovMultiplier;
  31782. /**
  31783. * Enable the FOV adjustment feature controlled by fovMultiplier.
  31784. */
  31785. useEquirectangularFOV: boolean;
  31786. private _maxSimultaneousLights;
  31787. /**
  31788. * Number of Simultaneous lights allowed on the material.
  31789. */
  31790. maxSimultaneousLights: int;
  31791. /**
  31792. * Default configuration related to image processing available in the Background Material.
  31793. */
  31794. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  31795. /**
  31796. * Keep track of the image processing observer to allow dispose and replace.
  31797. */
  31798. private _imageProcessingObserver;
  31799. /**
  31800. * Attaches a new image processing configuration to the PBR Material.
  31801. * @param configuration (if null the scene configuration will be use)
  31802. */
  31803. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  31804. /**
  31805. * Gets the image processing configuration used either in this material.
  31806. */
  31807. /**
  31808. * Sets the Default image processing configuration used either in the this material.
  31809. *
  31810. * If sets to null, the scene one is in use.
  31811. */
  31812. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  31813. /**
  31814. * Gets wether the color curves effect is enabled.
  31815. */
  31816. /**
  31817. * Sets wether the color curves effect is enabled.
  31818. */
  31819. cameraColorCurvesEnabled: boolean;
  31820. /**
  31821. * Gets wether the color grading effect is enabled.
  31822. */
  31823. /**
  31824. * Gets wether the color grading effect is enabled.
  31825. */
  31826. cameraColorGradingEnabled: boolean;
  31827. /**
  31828. * Gets wether tonemapping is enabled or not.
  31829. */
  31830. /**
  31831. * Sets wether tonemapping is enabled or not
  31832. */
  31833. cameraToneMappingEnabled: boolean;
  31834. /**
  31835. * The camera exposure used on this material.
  31836. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  31837. * This corresponds to a photographic exposure.
  31838. */
  31839. /**
  31840. * The camera exposure used on this material.
  31841. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  31842. * This corresponds to a photographic exposure.
  31843. */
  31844. cameraExposure: float;
  31845. /**
  31846. * Gets The camera contrast used on this material.
  31847. */
  31848. /**
  31849. * Sets The camera contrast used on this material.
  31850. */
  31851. cameraContrast: float;
  31852. /**
  31853. * Gets the Color Grading 2D Lookup Texture.
  31854. */
  31855. /**
  31856. * Sets the Color Grading 2D Lookup Texture.
  31857. */
  31858. cameraColorGradingTexture: Nullable<BaseTexture>;
  31859. /**
  31860. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  31861. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  31862. * 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;
  31863. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  31864. */
  31865. /**
  31866. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  31867. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  31868. * 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;
  31869. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  31870. */
  31871. cameraColorCurves: Nullable<ColorCurves>;
  31872. /**
  31873. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  31874. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  31875. */
  31876. switchToBGR: boolean;
  31877. private _renderTargets;
  31878. private _reflectionControls;
  31879. private _white;
  31880. private _primaryShadowColor;
  31881. private _primaryHighlightColor;
  31882. /**
  31883. * Instantiates a Background Material in the given scene
  31884. * @param name The friendly name of the material
  31885. * @param scene The scene to add the material to
  31886. */
  31887. constructor(name: string, scene: Scene);
  31888. /**
  31889. * The entire material has been created in order to prevent overdraw.
  31890. * @returns false
  31891. */
  31892. needAlphaTesting(): boolean;
  31893. /**
  31894. * The entire material has been created in order to prevent overdraw.
  31895. * @returns true if blending is enable
  31896. */
  31897. needAlphaBlending(): boolean;
  31898. /**
  31899. * Checks wether the material is ready to be rendered for a given mesh.
  31900. * @param mesh The mesh to render
  31901. * @param subMesh The submesh to check against
  31902. * @param useInstances Specify wether or not the material is used with instances
  31903. * @returns true if all the dependencies are ready (Textures, Effects...)
  31904. */
  31905. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  31906. /**
  31907. * Compute the primary color according to the chosen perceptual color.
  31908. */
  31909. private _computePrimaryColorFromPerceptualColor();
  31910. /**
  31911. * Compute the highlights and shadow colors according to their chosen levels.
  31912. */
  31913. private _computePrimaryColors();
  31914. /**
  31915. * Build the uniform buffer used in the material.
  31916. */
  31917. buildUniformLayout(): void;
  31918. /**
  31919. * Unbind the material.
  31920. */
  31921. unbind(): void;
  31922. /**
  31923. * Bind only the world matrix to the material.
  31924. * @param world The world matrix to bind.
  31925. */
  31926. bindOnlyWorldMatrix(world: Matrix): void;
  31927. /**
  31928. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  31929. * @param world The world matrix to bind.
  31930. * @param subMesh The submesh to bind for.
  31931. */
  31932. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  31933. /**
  31934. * Dispose the material.
  31935. * @param forceDisposeEffect Force disposal of the associated effect.
  31936. * @param forceDisposeTextures Force disposal of the associated textures.
  31937. */
  31938. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  31939. /**
  31940. * Clones the material.
  31941. * @param name The cloned name.
  31942. * @returns The cloned material.
  31943. */
  31944. clone(name: string): BackgroundMaterial;
  31945. /**
  31946. * Serializes the current material to its JSON representation.
  31947. * @returns The JSON representation.
  31948. */
  31949. serialize(): any;
  31950. /**
  31951. * Gets the class name of the material
  31952. * @returns "BackgroundMaterial"
  31953. */
  31954. getClassName(): string;
  31955. /**
  31956. * Parse a JSON input to create back a background material.
  31957. * @param source The JSON data to parse
  31958. * @param scene The scene to create the parsed material in
  31959. * @param rootUrl The root url of the assets the material depends upon
  31960. * @returns the instantiated BackgroundMaterial.
  31961. */
  31962. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  31963. }
  31964. }
  31965. declare module BABYLON {
  31966. /**
  31967. * The Physically based material base class of BJS.
  31968. *
  31969. * This offers the main features of a standard PBR material.
  31970. * For more information, please refer to the documentation :
  31971. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  31972. */
  31973. abstract class PBRBaseMaterial extends PushMaterial {
  31974. /**
  31975. * Intensity of the direct lights e.g. the four lights available in your scene.
  31976. * This impacts both the direct diffuse and specular highlights.
  31977. */
  31978. protected _directIntensity: number;
  31979. /**
  31980. * Intensity of the emissive part of the material.
  31981. * This helps controlling the emissive effect without modifying the emissive color.
  31982. */
  31983. protected _emissiveIntensity: number;
  31984. /**
  31985. * Intensity of the environment e.g. how much the environment will light the object
  31986. * either through harmonics for rough material or through the refelction for shiny ones.
  31987. */
  31988. protected _environmentIntensity: number;
  31989. /**
  31990. * This is a special control allowing the reduction of the specular highlights coming from the
  31991. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  31992. */
  31993. protected _specularIntensity: number;
  31994. /**
  31995. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  31996. */
  31997. private _lightingInfos;
  31998. /**
  31999. * Debug Control allowing disabling the bump map on this material.
  32000. */
  32001. protected _disableBumpMap: boolean;
  32002. /**
  32003. * AKA Diffuse Texture in standard nomenclature.
  32004. */
  32005. protected _albedoTexture: BaseTexture;
  32006. /**
  32007. * AKA Occlusion Texture in other nomenclature.
  32008. */
  32009. protected _ambientTexture: BaseTexture;
  32010. /**
  32011. * AKA Occlusion Texture Intensity in other nomenclature.
  32012. */
  32013. protected _ambientTextureStrength: number;
  32014. /**
  32015. * Stores the alpha values in a texture.
  32016. */
  32017. protected _opacityTexture: BaseTexture;
  32018. /**
  32019. * Stores the reflection values in a texture.
  32020. */
  32021. protected _reflectionTexture: BaseTexture;
  32022. /**
  32023. * Stores the refraction values in a texture.
  32024. */
  32025. protected _refractionTexture: BaseTexture;
  32026. /**
  32027. * Stores the emissive values in a texture.
  32028. */
  32029. protected _emissiveTexture: BaseTexture;
  32030. /**
  32031. * AKA Specular texture in other nomenclature.
  32032. */
  32033. protected _reflectivityTexture: BaseTexture;
  32034. /**
  32035. * Used to switch from specular/glossiness to metallic/roughness workflow.
  32036. */
  32037. protected _metallicTexture: BaseTexture;
  32038. /**
  32039. * Specifies the metallic scalar of the metallic/roughness workflow.
  32040. * Can also be used to scale the metalness values of the metallic texture.
  32041. */
  32042. protected _metallic: number;
  32043. /**
  32044. * Specifies the roughness scalar of the metallic/roughness workflow.
  32045. * Can also be used to scale the roughness values of the metallic texture.
  32046. */
  32047. protected _roughness: number;
  32048. /**
  32049. * Used to enable roughness/glossiness fetch from a separate chanel depending on the current mode.
  32050. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  32051. */
  32052. protected _microSurfaceTexture: BaseTexture;
  32053. /**
  32054. * Stores surface normal data used to displace a mesh in a texture.
  32055. */
  32056. protected _bumpTexture: BaseTexture;
  32057. /**
  32058. * Stores the pre-calculated light information of a mesh in a texture.
  32059. */
  32060. protected _lightmapTexture: BaseTexture;
  32061. /**
  32062. * The color of a material in ambient lighting.
  32063. */
  32064. protected _ambientColor: Color3;
  32065. /**
  32066. * AKA Diffuse Color in other nomenclature.
  32067. */
  32068. protected _albedoColor: Color3;
  32069. /**
  32070. * AKA Specular Color in other nomenclature.
  32071. */
  32072. protected _reflectivityColor: Color3;
  32073. /**
  32074. * The color applied when light is reflected from a material.
  32075. */
  32076. protected _reflectionColor: Color3;
  32077. /**
  32078. * The color applied when light is emitted from a material.
  32079. */
  32080. protected _emissiveColor: Color3;
  32081. /**
  32082. * AKA Glossiness in other nomenclature.
  32083. */
  32084. protected _microSurface: number;
  32085. /**
  32086. * source material index of refraction (IOR)' / 'destination material IOR.
  32087. */
  32088. protected _indexOfRefraction: number;
  32089. /**
  32090. * Controls if refraction needs to be inverted on Y. This could be usefull for procedural texture.
  32091. */
  32092. protected _invertRefractionY: boolean;
  32093. /**
  32094. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  32095. * Materials half opaque for instance using refraction could benefit from this control.
  32096. */
  32097. protected _linkRefractionWithTransparency: boolean;
  32098. /**
  32099. * Specifies that the material will use the light map as a show map.
  32100. */
  32101. protected _useLightmapAsShadowmap: boolean;
  32102. /**
  32103. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  32104. * makes the reflect vector face the model (under horizon).
  32105. */
  32106. protected _useHorizonOcclusion: boolean;
  32107. /**
  32108. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  32109. * too much the area relying on ambient texture to define their ambient occlusion.
  32110. */
  32111. protected _useRadianceOcclusion: boolean;
  32112. /**
  32113. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  32114. */
  32115. protected _useAlphaFromAlbedoTexture: boolean;
  32116. /**
  32117. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  32118. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  32119. */
  32120. protected _useSpecularOverAlpha: boolean;
  32121. /**
  32122. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  32123. */
  32124. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  32125. /**
  32126. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  32127. */
  32128. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  32129. /**
  32130. * Specifies if the metallic texture contains the roughness information in its green channel.
  32131. */
  32132. protected _useRoughnessFromMetallicTextureGreen: boolean;
  32133. /**
  32134. * Specifies if the metallic texture contains the metallness information in its blue channel.
  32135. */
  32136. protected _useMetallnessFromMetallicTextureBlue: boolean;
  32137. /**
  32138. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  32139. */
  32140. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  32141. /**
  32142. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  32143. */
  32144. protected _useAmbientInGrayScale: boolean;
  32145. /**
  32146. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  32147. * The material will try to infer what glossiness each pixel should be.
  32148. */
  32149. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  32150. /**
  32151. * BJS is using an harcoded light falloff based on a manually sets up range.
  32152. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  32153. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  32154. */
  32155. protected _usePhysicalLightFalloff: boolean;
  32156. /**
  32157. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  32158. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  32159. */
  32160. protected _useRadianceOverAlpha: boolean;
  32161. /**
  32162. * Allows using an object space normal map (instead of tangent space).
  32163. */
  32164. protected _useObjectSpaceNormalMap: boolean;
  32165. /**
  32166. * Allows using the bump map in parallax mode.
  32167. */
  32168. protected _useParallax: boolean;
  32169. /**
  32170. * Allows using the bump map in parallax occlusion mode.
  32171. */
  32172. protected _useParallaxOcclusion: boolean;
  32173. /**
  32174. * Controls the scale bias of the parallax mode.
  32175. */
  32176. protected _parallaxScaleBias: number;
  32177. /**
  32178. * If sets to true, disables all the lights affecting the material.
  32179. */
  32180. protected _disableLighting: boolean;
  32181. /**
  32182. * Number of Simultaneous lights allowed on the material.
  32183. */
  32184. protected _maxSimultaneousLights: number;
  32185. /**
  32186. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  32187. */
  32188. protected _invertNormalMapX: boolean;
  32189. /**
  32190. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  32191. */
  32192. protected _invertNormalMapY: boolean;
  32193. /**
  32194. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  32195. */
  32196. protected _twoSidedLighting: boolean;
  32197. /**
  32198. * Defines the alpha limits in alpha test mode.
  32199. */
  32200. protected _alphaCutOff: number;
  32201. /**
  32202. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  32203. */
  32204. protected _forceAlphaTest: boolean;
  32205. /**
  32206. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  32207. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  32208. */
  32209. protected _useAlphaFresnel: boolean;
  32210. /**
  32211. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  32212. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  32213. */
  32214. protected _useLinearAlphaFresnel: boolean;
  32215. /**
  32216. * The transparency mode of the material.
  32217. */
  32218. protected _transparencyMode: Nullable<number>;
  32219. /**
  32220. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  32221. * from cos thetav and roughness:
  32222. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  32223. */
  32224. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  32225. /**
  32226. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  32227. */
  32228. protected _forceIrradianceInFragment: boolean;
  32229. /**
  32230. * Force normal to face away from face.
  32231. */
  32232. protected _forceNormalForward: boolean;
  32233. /**
  32234. * Enables specular anti aliasing in the PBR shader.
  32235. * It will both interacts on the Geometry for analytical and IBL lighting.
  32236. * It also prefilter the roughness map based on the bump values.
  32237. */
  32238. protected _enableSpecularAntiAliasing: boolean;
  32239. /**
  32240. * Default configuration related to image processing available in the PBR Material.
  32241. */
  32242. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  32243. /**
  32244. * Keep track of the image processing observer to allow dispose and replace.
  32245. */
  32246. private _imageProcessingObserver;
  32247. /**
  32248. * Attaches a new image processing configuration to the PBR Material.
  32249. * @param configuration
  32250. */
  32251. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  32252. /**
  32253. * Stores the available render targets.
  32254. */
  32255. private _renderTargets;
  32256. /**
  32257. * Sets the global ambient color for the material used in lighting calculations.
  32258. */
  32259. private _globalAmbientColor;
  32260. /**
  32261. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  32262. */
  32263. private _useLogarithmicDepth;
  32264. /**
  32265. * If set to true, no lighting calculations will be applied.
  32266. */
  32267. private _unlit;
  32268. /**
  32269. * Instantiates a new PBRMaterial instance.
  32270. *
  32271. * @param name The material name
  32272. * @param scene The scene the material will be use in.
  32273. */
  32274. constructor(name: string, scene: Scene);
  32275. /**
  32276. * Gets the name of the material class.
  32277. */
  32278. getClassName(): string;
  32279. /**
  32280. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  32281. */
  32282. /**
  32283. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  32284. */
  32285. useLogarithmicDepth: boolean;
  32286. /**
  32287. * Gets the current transparency mode.
  32288. */
  32289. /**
  32290. * Sets the transparency mode of the material.
  32291. */
  32292. transparencyMode: Nullable<number>;
  32293. /**
  32294. * Returns true if alpha blending should be disabled.
  32295. */
  32296. private readonly _disableAlphaBlending;
  32297. /**
  32298. * Specifies whether or not this material should be rendered in alpha blend mode.
  32299. */
  32300. needAlphaBlending(): boolean;
  32301. /**
  32302. * Specifies if the mesh will require alpha blending.
  32303. * @param mesh - BJS mesh.
  32304. */
  32305. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  32306. /**
  32307. * Specifies whether or not this material should be rendered in alpha test mode.
  32308. */
  32309. needAlphaTesting(): boolean;
  32310. /**
  32311. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  32312. */
  32313. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  32314. /**
  32315. * Gets the texture used for the alpha test.
  32316. */
  32317. getAlphaTestTexture(): BaseTexture;
  32318. /**
  32319. * Stores the reflectivity values based on metallic roughness workflow.
  32320. */
  32321. private static _scaledReflectivity;
  32322. /**
  32323. * Specifies that the submesh is ready to be used.
  32324. * @param mesh - BJS mesh.
  32325. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  32326. * @param useInstances - Specifies that instances should be used.
  32327. * @returns - boolean indicating that the submesh is ready or not.
  32328. */
  32329. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  32330. /**
  32331. * Specifies if the material uses metallic roughness workflow.
  32332. * @returns boolean specifiying if the material uses metallic roughness workflow.
  32333. */
  32334. isMetallicWorkflow(): boolean;
  32335. private _prepareEffect(mesh, defines, onCompiled?, onError?, useInstances?, useClipPlane?);
  32336. private _prepareDefines(mesh, defines, useInstances?, useClipPlane?);
  32337. /**
  32338. * Force shader compilation
  32339. */
  32340. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  32341. clipPlane: boolean;
  32342. }>): void;
  32343. /**
  32344. * Initializes the uniform buffer layout for the shader.
  32345. */
  32346. buildUniformLayout(): void;
  32347. /**
  32348. * Unbinds the textures.
  32349. */
  32350. unbind(): void;
  32351. /**
  32352. * Binds the submesh data.
  32353. * @param world - The world matrix.
  32354. * @param mesh - The BJS mesh.
  32355. * @param subMesh - A submesh of the BJS mesh.
  32356. */
  32357. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  32358. /**
  32359. * Returns the animatable textures.
  32360. * @returns - Array of animatable textures.
  32361. */
  32362. getAnimatables(): IAnimatable[];
  32363. /**
  32364. * Returns the texture used for reflections.
  32365. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  32366. */
  32367. private _getReflectionTexture();
  32368. /**
  32369. * Returns the texture used for refraction or null if none is used.
  32370. * @returns - Refection texture if present. If no refraction texture and refraction
  32371. * is linked with transparency, returns environment texture. Otherwise, returns null.
  32372. */
  32373. private _getRefractionTexture();
  32374. /**
  32375. * Disposes the resources of the material.
  32376. * @param forceDisposeEffect - Forces the disposal of effects.
  32377. * @param forceDisposeTextures - Forces the disposal of all textures.
  32378. */
  32379. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  32380. }
  32381. }
  32382. declare module BABYLON {
  32383. /**
  32384. * The Physically based simple base material of BJS.
  32385. *
  32386. * This enables better naming and convention enforcements on top of the pbrMaterial.
  32387. * It is used as the base class for both the specGloss and metalRough conventions.
  32388. */
  32389. abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  32390. /**
  32391. * Number of Simultaneous lights allowed on the material.
  32392. */
  32393. maxSimultaneousLights: number;
  32394. /**
  32395. * If sets to true, disables all the lights affecting the material.
  32396. */
  32397. disableLighting: boolean;
  32398. /**
  32399. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  32400. */
  32401. environmentTexture: BaseTexture;
  32402. /**
  32403. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  32404. */
  32405. invertNormalMapX: boolean;
  32406. /**
  32407. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  32408. */
  32409. invertNormalMapY: boolean;
  32410. /**
  32411. * Normal map used in the model.
  32412. */
  32413. normalTexture: BaseTexture;
  32414. /**
  32415. * Emissivie color used to self-illuminate the model.
  32416. */
  32417. emissiveColor: Color3;
  32418. /**
  32419. * Emissivie texture used to self-illuminate the model.
  32420. */
  32421. emissiveTexture: BaseTexture;
  32422. /**
  32423. * Occlusion Channel Strenght.
  32424. */
  32425. occlusionStrength: number;
  32426. /**
  32427. * Occlusion Texture of the material (adding extra occlusion effects).
  32428. */
  32429. occlusionTexture: BaseTexture;
  32430. /**
  32431. * Defines the alpha limits in alpha test mode.
  32432. */
  32433. alphaCutOff: number;
  32434. /**
  32435. * Gets the current double sided mode.
  32436. */
  32437. /**
  32438. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  32439. */
  32440. doubleSided: boolean;
  32441. lightmapTexture: BaseTexture;
  32442. useLightmapAsShadowmap: boolean;
  32443. /**
  32444. * Return the active textures of the material.
  32445. */
  32446. getActiveTextures(): BaseTexture[];
  32447. hasTexture(texture: BaseTexture): boolean;
  32448. /**
  32449. * Instantiates a new PBRMaterial instance.
  32450. *
  32451. * @param name The material name
  32452. * @param scene The scene the material will be use in.
  32453. */
  32454. constructor(name: string, scene: Scene);
  32455. getClassName(): string;
  32456. }
  32457. }
  32458. declare module BABYLON {
  32459. /**
  32460. * The Physically based material of BJS.
  32461. *
  32462. * This offers the main features of a standard PBR material.
  32463. * For more information, please refer to the documentation :
  32464. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  32465. */
  32466. class PBRMaterial extends PBRBaseMaterial {
  32467. private static _PBRMATERIAL_OPAQUE;
  32468. /**
  32469. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  32470. */
  32471. static readonly PBRMATERIAL_OPAQUE: number;
  32472. /**
  32473. * Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  32474. */
  32475. private static _PBRMATERIAL_ALPHATEST;
  32476. /**
  32477. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  32478. */
  32479. static readonly PBRMATERIAL_ALPHATEST: number;
  32480. /**
  32481. * Represents the value for Alpha Blend. Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  32482. */
  32483. private static _PBRMATERIAL_ALPHABLEND;
  32484. /**
  32485. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  32486. */
  32487. static readonly PBRMATERIAL_ALPHABLEND: number;
  32488. /**
  32489. * 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.
  32490. * They are also discarded below the alpha cutoff threshold to improve performances.
  32491. */
  32492. private static _PBRMATERIAL_ALPHATESTANDBLEND;
  32493. /**
  32494. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  32495. * They are also discarded below the alpha cutoff threshold to improve performances.
  32496. */
  32497. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  32498. /**
  32499. * Intensity of the direct lights e.g. the four lights available in your scene.
  32500. * This impacts both the direct diffuse and specular highlights.
  32501. */
  32502. directIntensity: number;
  32503. /**
  32504. * Intensity of the emissive part of the material.
  32505. * This helps controlling the emissive effect without modifying the emissive color.
  32506. */
  32507. emissiveIntensity: number;
  32508. /**
  32509. * Intensity of the environment e.g. how much the environment will light the object
  32510. * either through harmonics for rough material or through the refelction for shiny ones.
  32511. */
  32512. environmentIntensity: number;
  32513. /**
  32514. * This is a special control allowing the reduction of the specular highlights coming from the
  32515. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  32516. */
  32517. specularIntensity: number;
  32518. /**
  32519. * Debug Control allowing disabling the bump map on this material.
  32520. */
  32521. disableBumpMap: boolean;
  32522. /**
  32523. * AKA Diffuse Texture in standard nomenclature.
  32524. */
  32525. albedoTexture: BaseTexture;
  32526. /**
  32527. * AKA Occlusion Texture in other nomenclature.
  32528. */
  32529. ambientTexture: BaseTexture;
  32530. /**
  32531. * AKA Occlusion Texture Intensity in other nomenclature.
  32532. */
  32533. ambientTextureStrength: number;
  32534. /**
  32535. * Stores the alpha values in a texture.
  32536. */
  32537. opacityTexture: BaseTexture;
  32538. /**
  32539. * Stores the reflection values in a texture.
  32540. */
  32541. reflectionTexture: Nullable<BaseTexture>;
  32542. /**
  32543. * Stores the emissive values in a texture.
  32544. */
  32545. emissiveTexture: BaseTexture;
  32546. /**
  32547. * AKA Specular texture in other nomenclature.
  32548. */
  32549. reflectivityTexture: BaseTexture;
  32550. /**
  32551. * Used to switch from specular/glossiness to metallic/roughness workflow.
  32552. */
  32553. metallicTexture: BaseTexture;
  32554. /**
  32555. * Specifies the metallic scalar of the metallic/roughness workflow.
  32556. * Can also be used to scale the metalness values of the metallic texture.
  32557. */
  32558. metallic: number;
  32559. /**
  32560. * Specifies the roughness scalar of the metallic/roughness workflow.
  32561. * Can also be used to scale the roughness values of the metallic texture.
  32562. */
  32563. roughness: number;
  32564. /**
  32565. * Used to enable roughness/glossiness fetch from a separate chanel depending on the current mode.
  32566. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  32567. */
  32568. microSurfaceTexture: BaseTexture;
  32569. /**
  32570. * Stores surface normal data used to displace a mesh in a texture.
  32571. */
  32572. bumpTexture: BaseTexture;
  32573. /**
  32574. * Stores the pre-calculated light information of a mesh in a texture.
  32575. */
  32576. lightmapTexture: BaseTexture;
  32577. /**
  32578. * Stores the refracted light information in a texture.
  32579. */
  32580. refractionTexture: BaseTexture;
  32581. /**
  32582. * The color of a material in ambient lighting.
  32583. */
  32584. ambientColor: Color3;
  32585. /**
  32586. * AKA Diffuse Color in other nomenclature.
  32587. */
  32588. albedoColor: Color3;
  32589. /**
  32590. * AKA Specular Color in other nomenclature.
  32591. */
  32592. reflectivityColor: Color3;
  32593. /**
  32594. * The color reflected from the material.
  32595. */
  32596. reflectionColor: Color3;
  32597. /**
  32598. * The color emitted from the material.
  32599. */
  32600. emissiveColor: Color3;
  32601. /**
  32602. * AKA Glossiness in other nomenclature.
  32603. */
  32604. microSurface: number;
  32605. /**
  32606. * source material index of refraction (IOR)' / 'destination material IOR.
  32607. */
  32608. indexOfRefraction: number;
  32609. /**
  32610. * Controls if refraction needs to be inverted on Y. This could be usefull for procedural texture.
  32611. */
  32612. invertRefractionY: boolean;
  32613. /**
  32614. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  32615. * Materials half opaque for instance using refraction could benefit from this control.
  32616. */
  32617. linkRefractionWithTransparency: boolean;
  32618. useLightmapAsShadowmap: boolean;
  32619. /**
  32620. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  32621. */
  32622. useAlphaFromAlbedoTexture: boolean;
  32623. /**
  32624. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  32625. */
  32626. forceAlphaTest: boolean;
  32627. /**
  32628. * Defines the alpha limits in alpha test mode.
  32629. */
  32630. alphaCutOff: number;
  32631. /**
  32632. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  32633. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  32634. */
  32635. useSpecularOverAlpha: boolean;
  32636. /**
  32637. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  32638. */
  32639. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  32640. /**
  32641. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  32642. */
  32643. useRoughnessFromMetallicTextureAlpha: boolean;
  32644. /**
  32645. * Specifies if the metallic texture contains the roughness information in its green channel.
  32646. */
  32647. useRoughnessFromMetallicTextureGreen: boolean;
  32648. /**
  32649. * Specifies if the metallic texture contains the metallness information in its blue channel.
  32650. */
  32651. useMetallnessFromMetallicTextureBlue: boolean;
  32652. /**
  32653. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  32654. */
  32655. useAmbientOcclusionFromMetallicTextureRed: boolean;
  32656. /**
  32657. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  32658. */
  32659. useAmbientInGrayScale: boolean;
  32660. /**
  32661. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  32662. * The material will try to infer what glossiness each pixel should be.
  32663. */
  32664. useAutoMicroSurfaceFromReflectivityMap: boolean;
  32665. /**
  32666. * BJS is using an harcoded light falloff based on a manually sets up range.
  32667. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  32668. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  32669. */
  32670. usePhysicalLightFalloff: boolean;
  32671. /**
  32672. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  32673. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  32674. */
  32675. useRadianceOverAlpha: boolean;
  32676. /**
  32677. * Allows using an object space normal map (instead of tangent space).
  32678. */
  32679. useObjectSpaceNormalMap: boolean;
  32680. /**
  32681. * Allows using the bump map in parallax mode.
  32682. */
  32683. useParallax: boolean;
  32684. /**
  32685. * Allows using the bump map in parallax occlusion mode.
  32686. */
  32687. useParallaxOcclusion: boolean;
  32688. /**
  32689. * Controls the scale bias of the parallax mode.
  32690. */
  32691. parallaxScaleBias: number;
  32692. /**
  32693. * If sets to true, disables all the lights affecting the material.
  32694. */
  32695. disableLighting: boolean;
  32696. /**
  32697. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  32698. */
  32699. forceIrradianceInFragment: boolean;
  32700. /**
  32701. * Number of Simultaneous lights allowed on the material.
  32702. */
  32703. maxSimultaneousLights: number;
  32704. /**
  32705. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  32706. */
  32707. invertNormalMapX: boolean;
  32708. /**
  32709. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  32710. */
  32711. invertNormalMapY: boolean;
  32712. /**
  32713. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  32714. */
  32715. twoSidedLighting: boolean;
  32716. /**
  32717. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  32718. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  32719. */
  32720. useAlphaFresnel: boolean;
  32721. /**
  32722. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  32723. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  32724. */
  32725. useLinearAlphaFresnel: boolean;
  32726. /**
  32727. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  32728. * And/Or occlude the blended part.
  32729. */
  32730. environmentBRDFTexture: Nullable<BaseTexture>;
  32731. /**
  32732. * Force normal to face away from face.
  32733. */
  32734. forceNormalForward: boolean;
  32735. /**
  32736. * Enables specular anti aliasing in the PBR shader.
  32737. * It will both interacts on the Geometry for analytical and IBL lighting.
  32738. * It also prefilter the roughness map based on the bump values.
  32739. */
  32740. enableSpecularAntiAliasing: boolean;
  32741. /**
  32742. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  32743. * makes the reflect vector face the model (under horizon).
  32744. */
  32745. useHorizonOcclusion: boolean;
  32746. /**
  32747. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  32748. * too much the area relying on ambient texture to define their ambient occlusion.
  32749. */
  32750. useRadianceOcclusion: boolean;
  32751. /**
  32752. * If set to true, no lighting calculations will be applied.
  32753. */
  32754. unlit: boolean;
  32755. /**
  32756. * Gets the image processing configuration used either in this material.
  32757. */
  32758. /**
  32759. * Sets the Default image processing configuration used either in the this material.
  32760. *
  32761. * If sets to null, the scene one is in use.
  32762. */
  32763. imageProcessingConfiguration: ImageProcessingConfiguration;
  32764. /**
  32765. * Gets wether the color curves effect is enabled.
  32766. */
  32767. /**
  32768. * Sets wether the color curves effect is enabled.
  32769. */
  32770. cameraColorCurvesEnabled: boolean;
  32771. /**
  32772. * Gets wether the color grading effect is enabled.
  32773. */
  32774. /**
  32775. * Gets wether the color grading effect is enabled.
  32776. */
  32777. cameraColorGradingEnabled: boolean;
  32778. /**
  32779. * Gets wether tonemapping is enabled or not.
  32780. */
  32781. /**
  32782. * Sets wether tonemapping is enabled or not
  32783. */
  32784. cameraToneMappingEnabled: boolean;
  32785. /**
  32786. * The camera exposure used on this material.
  32787. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  32788. * This corresponds to a photographic exposure.
  32789. */
  32790. /**
  32791. * The camera exposure used on this material.
  32792. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  32793. * This corresponds to a photographic exposure.
  32794. */
  32795. cameraExposure: number;
  32796. /**
  32797. * Gets The camera contrast used on this material.
  32798. */
  32799. /**
  32800. * Sets The camera contrast used on this material.
  32801. */
  32802. cameraContrast: number;
  32803. /**
  32804. * Gets the Color Grading 2D Lookup Texture.
  32805. */
  32806. /**
  32807. * Sets the Color Grading 2D Lookup Texture.
  32808. */
  32809. cameraColorGradingTexture: Nullable<BaseTexture>;
  32810. /**
  32811. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  32812. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  32813. * 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;
  32814. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  32815. */
  32816. /**
  32817. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  32818. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  32819. * 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;
  32820. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  32821. */
  32822. cameraColorCurves: Nullable<ColorCurves>;
  32823. /**
  32824. * Instantiates a new PBRMaterial instance.
  32825. *
  32826. * @param name The material name
  32827. * @param scene The scene the material will be use in.
  32828. */
  32829. constructor(name: string, scene: Scene);
  32830. /**
  32831. * Returns the name of this material class.
  32832. */
  32833. getClassName(): string;
  32834. /**
  32835. * Returns an array of the actively used textures.
  32836. * @returns - Array of BaseTextures
  32837. */
  32838. getActiveTextures(): BaseTexture[];
  32839. /**
  32840. * Checks to see if a texture is used in the material.
  32841. * @param texture - Base texture to use.
  32842. * @returns - Boolean specifying if a texture is used in the material.
  32843. */
  32844. hasTexture(texture: BaseTexture): boolean;
  32845. /**
  32846. * Makes a duplicate of the current material.
  32847. * @param name - name to use for the new material.
  32848. */
  32849. clone(name: string): PBRMaterial;
  32850. /**
  32851. * Serializes this PBR Material.
  32852. * @returns - An object with the serialized material.
  32853. */
  32854. serialize(): any;
  32855. /**
  32856. * Parses a PBR Material from a serialized object.
  32857. * @param source - Serialized object.
  32858. * @param scene - BJS scene instance.
  32859. * @param rootUrl - url for the scene object
  32860. * @returns - PBRMaterial
  32861. */
  32862. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  32863. }
  32864. }
  32865. declare module BABYLON {
  32866. /**
  32867. * The PBR material of BJS following the metal roughness convention.
  32868. *
  32869. * This fits to the PBR convention in the GLTF definition:
  32870. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  32871. */
  32872. class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  32873. /**
  32874. * The base color has two different interpretations depending on the value of metalness.
  32875. * When the material is a metal, the base color is the specific measured reflectance value
  32876. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  32877. * of the material.
  32878. */
  32879. baseColor: Color3;
  32880. /**
  32881. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  32882. * well as opacity information in the alpha channel.
  32883. */
  32884. baseTexture: BaseTexture;
  32885. /**
  32886. * Specifies the metallic scalar value of the material.
  32887. * Can also be used to scale the metalness values of the metallic texture.
  32888. */
  32889. metallic: number;
  32890. /**
  32891. * Specifies the roughness scalar value of the material.
  32892. * Can also be used to scale the roughness values of the metallic texture.
  32893. */
  32894. roughness: number;
  32895. /**
  32896. * Texture containing both the metallic value in the B channel and the
  32897. * roughness value in the G channel to keep better precision.
  32898. */
  32899. metallicRoughnessTexture: BaseTexture;
  32900. /**
  32901. * Instantiates a new PBRMetalRoughnessMaterial instance.
  32902. *
  32903. * @param name The material name
  32904. * @param scene The scene the material will be use in.
  32905. */
  32906. constructor(name: string, scene: Scene);
  32907. /**
  32908. * Return the currrent class name of the material.
  32909. */
  32910. getClassName(): string;
  32911. /**
  32912. * Return the active textures of the material.
  32913. */
  32914. getActiveTextures(): BaseTexture[];
  32915. /**
  32916. * Checks to see if a texture is used in the material.
  32917. * @param texture - Base texture to use.
  32918. * @returns - Boolean specifying if a texture is used in the material.
  32919. */
  32920. hasTexture(texture: BaseTexture): boolean;
  32921. /**
  32922. * Makes a duplicate of the current material.
  32923. * @param name - name to use for the new material.
  32924. */
  32925. clone(name: string): PBRMetallicRoughnessMaterial;
  32926. /**
  32927. * Serialize the material to a parsable JSON object.
  32928. */
  32929. serialize(): any;
  32930. /**
  32931. * Parses a JSON object correponding to the serialize function.
  32932. */
  32933. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  32934. }
  32935. }
  32936. declare module BABYLON {
  32937. /**
  32938. * The PBR material of BJS following the specular glossiness convention.
  32939. *
  32940. * This fits to the PBR convention in the GLTF definition:
  32941. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  32942. */
  32943. class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  32944. /**
  32945. * Specifies the diffuse color of the material.
  32946. */
  32947. diffuseColor: Color3;
  32948. /**
  32949. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  32950. * channel.
  32951. */
  32952. diffuseTexture: BaseTexture;
  32953. /**
  32954. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  32955. */
  32956. specularColor: Color3;
  32957. /**
  32958. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  32959. */
  32960. glossiness: number;
  32961. /**
  32962. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  32963. */
  32964. specularGlossinessTexture: BaseTexture;
  32965. /**
  32966. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  32967. *
  32968. * @param name The material name
  32969. * @param scene The scene the material will be use in.
  32970. */
  32971. constructor(name: string, scene: Scene);
  32972. /**
  32973. * Return the currrent class name of the material.
  32974. */
  32975. getClassName(): string;
  32976. /**
  32977. * Return the active textures of the material.
  32978. */
  32979. getActiveTextures(): BaseTexture[];
  32980. /**
  32981. * Checks to see if a texture is used in the material.
  32982. * @param texture - Base texture to use.
  32983. * @returns - Boolean specifying if a texture is used in the material.
  32984. */
  32985. hasTexture(texture: BaseTexture): boolean;
  32986. /**
  32987. * Makes a duplicate of the current material.
  32988. * @param name - name to use for the new material.
  32989. */
  32990. clone(name: string): PBRSpecularGlossinessMaterial;
  32991. /**
  32992. * Serialize the material to a parsable JSON object.
  32993. */
  32994. serialize(): any;
  32995. /**
  32996. * Parses a JSON object correponding to the serialize function.
  32997. */
  32998. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  32999. }
  33000. }
  33001. declare module BABYLON {
  33002. class BaseTexture {
  33003. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  33004. name: string;
  33005. private _hasAlpha;
  33006. hasAlpha: boolean;
  33007. getAlphaFromRGB: boolean;
  33008. level: number;
  33009. coordinatesIndex: number;
  33010. private _coordinatesMode;
  33011. /**
  33012. * How a texture is mapped.
  33013. *
  33014. * | Value | Type | Description |
  33015. * | ----- | ----------------------------------- | ----------- |
  33016. * | 0 | EXPLICIT_MODE | |
  33017. * | 1 | SPHERICAL_MODE | |
  33018. * | 2 | PLANAR_MODE | |
  33019. * | 3 | CUBIC_MODE | |
  33020. * | 4 | PROJECTION_MODE | |
  33021. * | 5 | SKYBOX_MODE | |
  33022. * | 6 | INVCUBIC_MODE | |
  33023. * | 7 | EQUIRECTANGULAR_MODE | |
  33024. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  33025. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  33026. */
  33027. coordinatesMode: number;
  33028. /**
  33029. * | Value | Type | Description |
  33030. * | ----- | ------------------ | ----------- |
  33031. * | 0 | CLAMP_ADDRESSMODE | |
  33032. * | 1 | WRAP_ADDRESSMODE | |
  33033. * | 2 | MIRROR_ADDRESSMODE | |
  33034. */
  33035. wrapU: number;
  33036. /**
  33037. * | Value | Type | Description |
  33038. * | ----- | ------------------ | ----------- |
  33039. * | 0 | CLAMP_ADDRESSMODE | |
  33040. * | 1 | WRAP_ADDRESSMODE | |
  33041. * | 2 | MIRROR_ADDRESSMODE | |
  33042. */
  33043. wrapV: number;
  33044. /**
  33045. * | Value | Type | Description |
  33046. * | ----- | ------------------ | ----------- |
  33047. * | 0 | CLAMP_ADDRESSMODE | |
  33048. * | 1 | WRAP_ADDRESSMODE | |
  33049. * | 2 | MIRROR_ADDRESSMODE | |
  33050. */
  33051. wrapR: number;
  33052. anisotropicFilteringLevel: number;
  33053. isCube: boolean;
  33054. is3D: boolean;
  33055. gammaSpace: boolean;
  33056. invertZ: boolean;
  33057. lodLevelInAlpha: boolean;
  33058. lodGenerationOffset: number;
  33059. lodGenerationScale: number;
  33060. isRenderTarget: boolean;
  33061. readonly uid: string;
  33062. toString(): string;
  33063. getClassName(): string;
  33064. animations: Animation[];
  33065. /**
  33066. * An event triggered when the texture is disposed.
  33067. */
  33068. onDisposeObservable: Observable<BaseTexture>;
  33069. private _onDisposeObserver;
  33070. onDispose: () => void;
  33071. delayLoadState: number;
  33072. private _scene;
  33073. _texture: Nullable<InternalTexture>;
  33074. private _uid;
  33075. readonly isBlocking: boolean;
  33076. constructor(scene: Nullable<Scene>);
  33077. getScene(): Nullable<Scene>;
  33078. getTextureMatrix(): Matrix;
  33079. getReflectionTextureMatrix(): Matrix;
  33080. getInternalTexture(): Nullable<InternalTexture>;
  33081. isReadyOrNotBlocking(): boolean;
  33082. isReady(): boolean;
  33083. getSize(): ISize;
  33084. getBaseSize(): ISize;
  33085. scale(ratio: number): void;
  33086. readonly canRescale: boolean;
  33087. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number): Nullable<InternalTexture>;
  33088. _rebuild(): void;
  33089. delayLoad(): void;
  33090. clone(): Nullable<BaseTexture>;
  33091. readonly textureType: number;
  33092. readonly textureFormat: number;
  33093. readPixels(faceIndex?: number): Nullable<ArrayBufferView>;
  33094. releaseInternalTexture(): void;
  33095. sphericalPolynomial: Nullable<SphericalPolynomial>;
  33096. readonly _lodTextureHigh: Nullable<BaseTexture>;
  33097. readonly _lodTextureMid: Nullable<BaseTexture>;
  33098. readonly _lodTextureLow: Nullable<BaseTexture>;
  33099. dispose(): void;
  33100. serialize(): any;
  33101. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  33102. }
  33103. }
  33104. declare module BABYLON {
  33105. /**
  33106. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  33107. * It can help converting any input color in a desired output one. This can then be used to create effects
  33108. * from sepia, black and white to sixties or futuristic rendering...
  33109. *
  33110. * The only supported format is currently 3dl.
  33111. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table/
  33112. */
  33113. class ColorGradingTexture extends BaseTexture {
  33114. /**
  33115. * The current texture matrix. (will always be identity in color grading texture)
  33116. */
  33117. private _textureMatrix;
  33118. /**
  33119. * The texture URL.
  33120. */
  33121. url: string;
  33122. /**
  33123. * Empty line regex stored for GC.
  33124. */
  33125. private static _noneEmptyLineRegex;
  33126. private _engine;
  33127. /**
  33128. * Instantiates a ColorGradingTexture from the following parameters.
  33129. *
  33130. * @param url The location of the color gradind data (currently only supporting 3dl)
  33131. * @param scene The scene the texture will be used in
  33132. */
  33133. constructor(url: string, scene: Scene);
  33134. /**
  33135. * Returns the texture matrix used in most of the material.
  33136. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  33137. */
  33138. getTextureMatrix(): Matrix;
  33139. /**
  33140. * Occurs when the file being loaded is a .3dl LUT file.
  33141. */
  33142. private load3dlTexture();
  33143. /**
  33144. * Starts the loading process of the texture.
  33145. */
  33146. private loadTexture();
  33147. /**
  33148. * Clones the color gradind texture.
  33149. */
  33150. clone(): ColorGradingTexture;
  33151. /**
  33152. * Called during delayed load for textures.
  33153. */
  33154. delayLoad(): void;
  33155. /**
  33156. * Parses a color grading texture serialized by Babylon.
  33157. * @param parsedTexture The texture information being parsedTexture
  33158. * @param scene The scene to load the texture in
  33159. * @param rootUrl The root url of the data assets to load
  33160. * @return A color gradind texture
  33161. */
  33162. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<ColorGradingTexture>;
  33163. /**
  33164. * Serializes the LUT texture to json format.
  33165. */
  33166. serialize(): any;
  33167. }
  33168. }
  33169. declare module BABYLON {
  33170. class CubeTexture extends BaseTexture {
  33171. url: string;
  33172. coordinatesMode: number;
  33173. /**
  33174. * Gets or sets the center of the bounding box associated with the cube texture
  33175. * It must define where the camera used to render the texture was set
  33176. */
  33177. boundingBoxPosition: Vector3;
  33178. private _boundingBoxSize;
  33179. /**
  33180. * Gets or sets the size of the bounding box associated with the cube texture
  33181. * When defined, the cubemap will switch to local mode
  33182. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  33183. * @example https://www.babylonjs-playground.com/#RNASML
  33184. */
  33185. boundingBoxSize: Vector3;
  33186. protected _rotationY: number;
  33187. /**
  33188. * Gets texture matrix rotation angle around Y axis radians.
  33189. */
  33190. /**
  33191. * Sets texture matrix rotation angle around Y axis in radians.
  33192. */
  33193. rotationY: number;
  33194. private _noMipmap;
  33195. private _files;
  33196. private _extensions;
  33197. private _textureMatrix;
  33198. private _format;
  33199. private _prefiltered;
  33200. private _createPolynomials;
  33201. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  33202. /**
  33203. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  33204. * @param url defines the url of the prefiltered texture
  33205. * @param scene defines the scene the texture is attached to
  33206. * @param forcedExtension defines the extension of the file if different from the url
  33207. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  33208. * @return the prefiltered texture
  33209. */
  33210. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  33211. /**
  33212. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  33213. * as prefiltered data.
  33214. * @param rootUrl defines the url of the texture or the root name of the six images
  33215. * @param scene defines the scene the texture is attached to
  33216. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  33217. * @param noMipmap defines if mipmaps should be created or not
  33218. * @param files defines the six files to load for the different faces
  33219. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  33220. * @param onError defines a callback triggered in case of error during load
  33221. * @param format defines the internal format to use for the texture once loaded
  33222. * @param prefiltered defines whether or not the texture is created from prefiltered data
  33223. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  33224. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  33225. * @return the cube texture
  33226. */
  33227. 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);
  33228. delayLoad(): void;
  33229. getReflectionTextureMatrix(): Matrix;
  33230. setReflectionTextureMatrix(value: Matrix): void;
  33231. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  33232. clone(): CubeTexture;
  33233. }
  33234. }
  33235. declare module BABYLON {
  33236. /**
  33237. * A class extending {BABYLON.Texture} allowing drawing on a texture
  33238. * @see http://doc.babylonjs.com/how_to/dynamictexture
  33239. */
  33240. class DynamicTexture extends Texture {
  33241. private _generateMipMaps;
  33242. private _canvas;
  33243. private _context;
  33244. private _engine;
  33245. /**
  33246. * Creates a {BABYLON.DynamicTexture}
  33247. * @param name defines the name of the texture
  33248. * @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
  33249. * @param scene defines the scene where you want the texture
  33250. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  33251. * @param samplingMode defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  33252. * @param format defines the texture format to use (default is BABYLON.Engine.TEXTUREFORMAT_RGBA)
  33253. */
  33254. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  33255. /**
  33256. * Gets the current state of canRescale
  33257. */
  33258. readonly canRescale: boolean;
  33259. private _recreate(textureSize);
  33260. /**
  33261. * Scales the texture
  33262. * @param ratio the scale factor to apply to both width and height
  33263. */
  33264. scale(ratio: number): void;
  33265. /**
  33266. * Resizes the texture
  33267. * @param width the new width
  33268. * @param height the new height
  33269. */
  33270. scaleTo(width: number, height: number): void;
  33271. /**
  33272. * Gets the context of the canvas used by the texture
  33273. * @returns the canvas context of the dynamic texture
  33274. */
  33275. getContext(): CanvasRenderingContext2D;
  33276. /**
  33277. * Clears the texture
  33278. */
  33279. clear(): void;
  33280. /**
  33281. * Updates the texture
  33282. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  33283. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  33284. */
  33285. update(invertY?: boolean, premulAlpha?: boolean): void;
  33286. /**
  33287. * Draws text onto the texture
  33288. * @param text defines the text to be drawn
  33289. * @param x defines the placement of the text from the left
  33290. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  33291. * @param font defines the font to be used with font-style, font-size, font-name
  33292. * @param color defines the color used for the text
  33293. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  33294. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  33295. * @param update defines whether texture is immediately update (default is true)
  33296. */
  33297. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  33298. /**
  33299. * Clones the texture
  33300. * @returns the clone of the texture.
  33301. */
  33302. clone(): DynamicTexture;
  33303. /** @hidden */
  33304. _rebuild(): void;
  33305. }
  33306. }
  33307. declare module BABYLON {
  33308. /**
  33309. * This represents a texture coming from an HDR input.
  33310. *
  33311. * The only supported format is currently panorama picture stored in RGBE format.
  33312. * Example of such files can be found on HDRLib: http://hdrlib.com/
  33313. */
  33314. class HDRCubeTexture extends BaseTexture {
  33315. private static _facesMapping;
  33316. private _generateHarmonics;
  33317. private _noMipmap;
  33318. private _textureMatrix;
  33319. private _size;
  33320. private _onLoad;
  33321. private _onError;
  33322. /**
  33323. * The texture URL.
  33324. */
  33325. url: string;
  33326. /**
  33327. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  33328. */
  33329. coordinatesMode: number;
  33330. protected _isBlocking: boolean;
  33331. /**
  33332. * Gets wether or not the texture is blocking during loading.
  33333. */
  33334. /**
  33335. * Sets wether or not the texture is blocking during loading.
  33336. */
  33337. isBlocking: boolean;
  33338. protected _rotationY: number;
  33339. /**
  33340. * Gets texture matrix rotation angle around Y axis radians.
  33341. */
  33342. /**
  33343. * Sets texture matrix rotation angle around Y axis in radians.
  33344. */
  33345. rotationY: number;
  33346. /**
  33347. * Gets or sets the center of the bounding box associated with the cube texture
  33348. * It must define where the camera used to render the texture was set
  33349. */
  33350. boundingBoxPosition: Vector3;
  33351. private _boundingBoxSize;
  33352. /**
  33353. * Gets or sets the size of the bounding box associated with the cube texture
  33354. * When defined, the cubemap will switch to local mode
  33355. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  33356. * @example https://www.babylonjs-playground.com/#RNASML
  33357. */
  33358. boundingBoxSize: Vector3;
  33359. /**
  33360. * Instantiates an HDRTexture from the following parameters.
  33361. *
  33362. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  33363. * @param scene The scene the texture will be used in
  33364. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  33365. * @param noMipmap Forces to not generate the mipmap if true
  33366. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  33367. * @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)
  33368. * @param reserved Reserved flag for internal use.
  33369. */
  33370. 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>);
  33371. /**
  33372. * Occurs when the file is raw .hdr file.
  33373. */
  33374. private loadTexture();
  33375. clone(): HDRCubeTexture;
  33376. delayLoad(): void;
  33377. getReflectionTextureMatrix(): Matrix;
  33378. setReflectionTextureMatrix(value: Matrix): void;
  33379. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  33380. serialize(): any;
  33381. }
  33382. }
  33383. declare module BABYLON {
  33384. /**
  33385. * Class used to store data associated with WebGL texture data for the engine
  33386. * This class should not be used directly
  33387. */
  33388. class InternalTexture implements IInternalTextureTracker {
  33389. /**
  33390. * The source of the texture data is unknown
  33391. */
  33392. static DATASOURCE_UNKNOWN: number;
  33393. /**
  33394. * Texture data comes from an URL
  33395. */
  33396. static DATASOURCE_URL: number;
  33397. /**
  33398. * Texture data is only used for temporary storage
  33399. */
  33400. static DATASOURCE_TEMP: number;
  33401. /**
  33402. * Texture data comes from raw data (ArrayBuffer)
  33403. */
  33404. static DATASOURCE_RAW: number;
  33405. /**
  33406. * Texture content is dynamic (video or dynamic texture)
  33407. */
  33408. static DATASOURCE_DYNAMIC: number;
  33409. /**
  33410. * Texture content is generated by rendering to it
  33411. */
  33412. static DATASOURCE_RENDERTARGET: number;
  33413. /**
  33414. * Texture content is part of a multi render target process
  33415. */
  33416. static DATASOURCE_MULTIRENDERTARGET: number;
  33417. /**
  33418. * Texture data comes from a cube data file
  33419. */
  33420. static DATASOURCE_CUBE: number;
  33421. /**
  33422. * Texture data comes from a raw cube data
  33423. */
  33424. static DATASOURCE_CUBERAW: number;
  33425. /**
  33426. * Texture data come from a prefiltered cube data file
  33427. */
  33428. static DATASOURCE_CUBEPREFILTERED: number;
  33429. /**
  33430. * Texture content is raw 3D data
  33431. */
  33432. static DATASOURCE_RAW3D: number;
  33433. /**
  33434. * Texture content is a depth texture
  33435. */
  33436. static DATASOURCE_DEPTHTEXTURE: number;
  33437. /**
  33438. * Defines if the texture is ready
  33439. */
  33440. isReady: boolean;
  33441. /**
  33442. * Defines if the texture is a cube texture
  33443. */
  33444. isCube: boolean;
  33445. /**
  33446. * Defines if the texture contains 3D data
  33447. */
  33448. is3D: boolean;
  33449. /**
  33450. * Gets the URL used to load this texture
  33451. */
  33452. url: string;
  33453. /**
  33454. * Gets the sampling mode of the texture
  33455. */
  33456. samplingMode: number;
  33457. /**
  33458. * Gets a boolean indicating if the texture needs mipmaps generation
  33459. */
  33460. generateMipMaps: boolean;
  33461. /**
  33462. * Gets the number of samples used by the texture (WebGL2+ only)
  33463. */
  33464. samples: number;
  33465. /**
  33466. * Gets the type of the texture
  33467. */
  33468. type: number;
  33469. /**
  33470. * Gets the format of the texture
  33471. */
  33472. format: number;
  33473. /**
  33474. * Observable called when the texture is loaded
  33475. */
  33476. onLoadedObservable: Observable<InternalTexture>;
  33477. /**
  33478. * Gets the width of the texture
  33479. */
  33480. width: number;
  33481. /**
  33482. * Gets the height of the texture
  33483. */
  33484. height: number;
  33485. /**
  33486. * Gets the depth of the texture
  33487. */
  33488. depth: number;
  33489. /**
  33490. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  33491. */
  33492. baseWidth: number;
  33493. /**
  33494. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  33495. */
  33496. baseHeight: number;
  33497. /**
  33498. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  33499. */
  33500. baseDepth: number;
  33501. /**
  33502. * Gets a boolean indicating if the texture is inverted on Y axis
  33503. */
  33504. invertY: boolean;
  33505. /**
  33506. * Gets or set the previous tracker in the list
  33507. */
  33508. previous: Nullable<IInternalTextureTracker>;
  33509. /**
  33510. * Gets or set the next tracker in the list
  33511. */
  33512. next: Nullable<IInternalTextureTracker>;
  33513. /** @hidden */
  33514. _initialSlot: number;
  33515. /** @hidden */
  33516. _designatedSlot: number;
  33517. /** @hidden */
  33518. _dataSource: number;
  33519. /** @hidden */
  33520. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  33521. /** @hidden */
  33522. _bufferView: Nullable<ArrayBufferView>;
  33523. /** @hidden */
  33524. _bufferViewArray: Nullable<ArrayBufferView[]>;
  33525. /** @hidden */
  33526. _size: number;
  33527. /** @hidden */
  33528. _extension: string;
  33529. /** @hidden */
  33530. _files: Nullable<string[]>;
  33531. /** @hidden */
  33532. _workingCanvas: HTMLCanvasElement;
  33533. /** @hidden */
  33534. _workingContext: CanvasRenderingContext2D;
  33535. /** @hidden */
  33536. _framebuffer: Nullable<WebGLFramebuffer>;
  33537. /** @hidden */
  33538. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  33539. /** @hidden */
  33540. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  33541. /** @hidden */
  33542. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  33543. /** @hidden */
  33544. _attachments: Nullable<number[]>;
  33545. /** @hidden */
  33546. _cachedCoordinatesMode: Nullable<number>;
  33547. /** @hidden */
  33548. _cachedWrapU: Nullable<number>;
  33549. /** @hidden */
  33550. _cachedWrapV: Nullable<number>;
  33551. /** @hidden */
  33552. _cachedWrapR: Nullable<number>;
  33553. /** @hidden */
  33554. _cachedAnisotropicFilteringLevel: Nullable<number>;
  33555. /** @hidden */
  33556. _isDisabled: boolean;
  33557. /** @hidden */
  33558. _compression: Nullable<string>;
  33559. /** @hidden */
  33560. _generateStencilBuffer: boolean;
  33561. /** @hidden */
  33562. _generateDepthBuffer: boolean;
  33563. /** @hidden */
  33564. _comparisonFunction: number;
  33565. /** @hidden */
  33566. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  33567. /** @hidden */
  33568. _lodGenerationScale: number;
  33569. /** @hidden */
  33570. _lodGenerationOffset: number;
  33571. /** @hidden */
  33572. _lodTextureHigh: BaseTexture;
  33573. /** @hidden */
  33574. _lodTextureMid: BaseTexture;
  33575. /** @hidden */
  33576. _lodTextureLow: BaseTexture;
  33577. /** @hidden */
  33578. _webGLTexture: Nullable<WebGLTexture>;
  33579. /** @hidden */
  33580. _references: number;
  33581. private _engine;
  33582. /**
  33583. * Gets the data source type of the texture (can be one of the BABYLON.InternalTexture.DATASOURCE_XXXX)
  33584. */
  33585. readonly dataSource: number;
  33586. /**
  33587. * Creates a new InternalTexture
  33588. * @param engine defines the engine to use
  33589. * @param dataSource defines the type of data that will be used
  33590. */
  33591. constructor(engine: Engine, dataSource: number);
  33592. /**
  33593. * Increments the number of references (ie. the number of {BABYLON.Texture} that point to it)
  33594. */
  33595. incrementReferences(): void;
  33596. /**
  33597. * Change the size of the texture (not the size of the content)
  33598. * @param width defines the new width
  33599. * @param height defines the new height
  33600. * @param depth defines the new depth (1 by default)
  33601. */
  33602. updateSize(width: int, height: int, depth?: int): void;
  33603. /** @hidden */
  33604. _rebuild(): void;
  33605. private _swapAndDie(target);
  33606. /**
  33607. * Dispose the current allocated resources
  33608. */
  33609. dispose(): void;
  33610. }
  33611. }
  33612. declare module BABYLON {
  33613. /**
  33614. * Internal interface used to track {BABYLON.InternalTexture} already bound to the GL context
  33615. */
  33616. interface IInternalTextureTracker {
  33617. /**
  33618. * Gets or set the previous tracker in the list
  33619. */
  33620. previous: Nullable<IInternalTextureTracker>;
  33621. /**
  33622. * Gets or set the next tracker in the list
  33623. */
  33624. next: Nullable<IInternalTextureTracker>;
  33625. }
  33626. /**
  33627. * Internal class used by the engine to get list of {BABYLON.InternalTexture} already bound to the GL context
  33628. */
  33629. class DummyInternalTextureTracker {
  33630. /**
  33631. * Gets or set the previous tracker in the list
  33632. */
  33633. previous: Nullable<IInternalTextureTracker>;
  33634. /**
  33635. * Gets or set the next tracker in the list
  33636. */
  33637. next: Nullable<IInternalTextureTracker>;
  33638. }
  33639. }
  33640. declare module BABYLON {
  33641. class MirrorTexture extends RenderTargetTexture {
  33642. private scene;
  33643. mirrorPlane: Plane;
  33644. private _transformMatrix;
  33645. private _mirrorMatrix;
  33646. private _savedViewMatrix;
  33647. private _blurX;
  33648. private _blurY;
  33649. private _adaptiveBlurKernel;
  33650. private _blurKernelX;
  33651. private _blurKernelY;
  33652. private _blurRatio;
  33653. blurRatio: number;
  33654. adaptiveBlurKernel: number;
  33655. blurKernel: number;
  33656. blurKernelX: number;
  33657. blurKernelY: number;
  33658. private _autoComputeBlurKernel();
  33659. protected _onRatioRescale(): void;
  33660. private _updateGammaSpace();
  33661. private _imageProcessingConfigChangeObserver;
  33662. constructor(name: string, size: number | {
  33663. width: number;
  33664. height: number;
  33665. } | {
  33666. ratio: number;
  33667. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  33668. private _preparePostProcesses();
  33669. clone(): MirrorTexture;
  33670. serialize(): any;
  33671. dispose(): void;
  33672. }
  33673. }
  33674. declare module BABYLON {
  33675. interface IMultiRenderTargetOptions {
  33676. generateMipMaps?: boolean;
  33677. types?: number[];
  33678. samplingModes?: number[];
  33679. generateDepthBuffer?: boolean;
  33680. generateStencilBuffer?: boolean;
  33681. generateDepthTexture?: boolean;
  33682. textureCount?: number;
  33683. doNotChangeAspectRatio?: boolean;
  33684. defaultType?: number;
  33685. }
  33686. class MultiRenderTarget extends RenderTargetTexture {
  33687. private _internalTextures;
  33688. private _textures;
  33689. readonly isSupported: boolean;
  33690. private _multiRenderTargetOptions;
  33691. readonly textures: Texture[];
  33692. readonly depthTexture: Texture;
  33693. wrapU: number;
  33694. wrapV: number;
  33695. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  33696. _rebuild(): void;
  33697. private _createInternalTextures();
  33698. private _createTextures();
  33699. samples: number;
  33700. resize(size: any): void;
  33701. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  33702. dispose(): void;
  33703. releaseInternalTextures(): void;
  33704. }
  33705. }
  33706. declare module BABYLON {
  33707. class RawTexture extends Texture {
  33708. format: number;
  33709. private _engine;
  33710. constructor(data: ArrayBufferView, width: number, height: number, format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  33711. update(data: ArrayBufferView): void;
  33712. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  33713. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  33714. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  33715. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  33716. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  33717. }
  33718. }
  33719. declare module BABYLON {
  33720. /**
  33721. * Class used to store 3D textures containing user data
  33722. */
  33723. class RawTexture3D extends Texture {
  33724. /** Gets or sets the texture format to use*/
  33725. format: number;
  33726. private _engine;
  33727. /**
  33728. * Create a new RawTexture3D
  33729. * @param data defines the data of the texture
  33730. * @param width defines the width of the texture
  33731. * @param height defines the height of the texture
  33732. * @param depth defines the depth of the texture
  33733. * @param format defines the texture format to use
  33734. * @param scene defines the hosting scene
  33735. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  33736. * @param invertY defines if texture must be stored with Y axis inverted
  33737. * @param samplingMode defines the sampling mode to use (BABYLON.Texture.TRILINEAR_SAMPLINGMODE by default)
  33738. */
  33739. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  33740. /** Gets or sets the texture format to use*/
  33741. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number);
  33742. /**
  33743. * Update the texture with new data
  33744. * @param data defines the data to store in the texture
  33745. */
  33746. update(data: ArrayBufferView): void;
  33747. }
  33748. }
  33749. declare module BABYLON {
  33750. /**
  33751. * Creates a refraction texture used by refraction channel of the standard material.
  33752. * @param name the texture name
  33753. * @param size size of the underlying texture
  33754. * @param scene root scene
  33755. */
  33756. class RefractionTexture extends RenderTargetTexture {
  33757. refractionPlane: Plane;
  33758. depth: number;
  33759. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  33760. clone(): RefractionTexture;
  33761. serialize(): any;
  33762. }
  33763. }
  33764. declare module BABYLON {
  33765. class RenderTargetTexture extends Texture {
  33766. isCube: boolean;
  33767. static _REFRESHRATE_RENDER_ONCE: number;
  33768. static _REFRESHRATE_RENDER_ONEVERYFRAME: number;
  33769. static _REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  33770. static readonly REFRESHRATE_RENDER_ONCE: number;
  33771. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  33772. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  33773. /**
  33774. * Use this predicate to dynamically define the list of mesh you want to render.
  33775. * If set, the renderList property will be overwritten.
  33776. */
  33777. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  33778. /**
  33779. * Use this list to define the list of mesh you want to render.
  33780. */
  33781. renderList: Nullable<Array<AbstractMesh>>;
  33782. renderParticles: boolean;
  33783. renderSprites: boolean;
  33784. coordinatesMode: number;
  33785. activeCamera: Nullable<Camera>;
  33786. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  33787. useCameraPostProcesses: boolean;
  33788. ignoreCameraViewport: boolean;
  33789. private _postProcessManager;
  33790. private _postProcesses;
  33791. private _resizeObserver;
  33792. /**
  33793. * An event triggered when the texture is unbind.
  33794. */
  33795. onBeforeBindObservable: Observable<RenderTargetTexture>;
  33796. /**
  33797. * An event triggered when the texture is unbind.
  33798. */
  33799. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  33800. private _onAfterUnbindObserver;
  33801. onAfterUnbind: () => void;
  33802. /**
  33803. * An event triggered before rendering the texture
  33804. */
  33805. onBeforeRenderObservable: Observable<number>;
  33806. private _onBeforeRenderObserver;
  33807. onBeforeRender: (faceIndex: number) => void;
  33808. /**
  33809. * An event triggered after rendering the texture
  33810. */
  33811. onAfterRenderObservable: Observable<number>;
  33812. private _onAfterRenderObserver;
  33813. onAfterRender: (faceIndex: number) => void;
  33814. /**
  33815. * An event triggered after the texture clear
  33816. */
  33817. onClearObservable: Observable<Engine>;
  33818. private _onClearObserver;
  33819. onClear: (Engine: Engine) => void;
  33820. clearColor: Color4;
  33821. protected _size: number | {
  33822. width: number;
  33823. height: number;
  33824. };
  33825. protected _initialSizeParameter: number | {
  33826. width: number;
  33827. height: number;
  33828. } | {
  33829. ratio: number;
  33830. };
  33831. protected _sizeRatio: Nullable<number>;
  33832. _generateMipMaps: boolean;
  33833. protected _renderingManager: RenderingManager;
  33834. _waitingRenderList: string[];
  33835. protected _doNotChangeAspectRatio: boolean;
  33836. protected _currentRefreshId: number;
  33837. protected _refreshRate: number;
  33838. protected _textureMatrix: Matrix;
  33839. protected _samples: number;
  33840. protected _renderTargetOptions: RenderTargetCreationOptions;
  33841. readonly renderTargetOptions: RenderTargetCreationOptions;
  33842. protected _engine: Engine;
  33843. protected _onRatioRescale(): void;
  33844. /**
  33845. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  33846. * It must define where the camera used to render the texture is set
  33847. */
  33848. boundingBoxPosition: Vector3;
  33849. private _boundingBoxSize;
  33850. /**
  33851. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  33852. * When defined, the cubemap will switch to local mode
  33853. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  33854. * @example https://www.babylonjs-playground.com/#RNASML
  33855. */
  33856. boundingBoxSize: Vector3;
  33857. /**
  33858. * In case the RTT has been created with a depth texture, get the associated
  33859. * depth texture.
  33860. * Otherwise, return null.
  33861. */
  33862. depthStencilTexture: Nullable<InternalTexture>;
  33863. /**
  33864. * Instantiate a render target texture. This is mainly to render of screen the scene to for instance apply post processse
  33865. * or used a shadow, depth texture...
  33866. * @param name The friendly name of the texture
  33867. * @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)
  33868. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  33869. * @param generateMipMaps True if mip maps need to be generated after render.
  33870. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  33871. * @param type The type of the buffer in the RTT (int, half float, float...)
  33872. * @param isCube True if a cube texture needs to be created
  33873. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  33874. * @param generateDepthBuffer True to generate a depth buffer
  33875. * @param generateStencilBuffer True to generate a stencil buffer
  33876. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  33877. */
  33878. constructor(name: string, size: number | {
  33879. width: number;
  33880. height: number;
  33881. } | {
  33882. ratio: number;
  33883. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean);
  33884. /**
  33885. * Creates a depth stencil texture.
  33886. * This is only available in WebGL 2 or with the depth texture extension available.
  33887. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  33888. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  33889. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  33890. */
  33891. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  33892. private _processSizeParameter(size);
  33893. samples: number;
  33894. resetRefreshCounter(): void;
  33895. refreshRate: number;
  33896. addPostProcess(postProcess: PostProcess): void;
  33897. clearPostProcesses(dispose?: boolean): void;
  33898. removePostProcess(postProcess: PostProcess): void;
  33899. _shouldRender(): boolean;
  33900. getRenderSize(): number;
  33901. getRenderWidth(): number;
  33902. getRenderHeight(): number;
  33903. readonly canRescale: boolean;
  33904. scale(ratio: number): void;
  33905. getReflectionTextureMatrix(): Matrix;
  33906. resize(size: number | {
  33907. width: number;
  33908. height: number;
  33909. } | {
  33910. ratio: number;
  33911. }): void;
  33912. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  33913. private _bestReflectionRenderTargetDimension(renderDimension, scale);
  33914. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  33915. private renderToTarget(faceIndex, currentRenderList, currentRenderListLength, useCameraPostProcess, dumpForDebug);
  33916. /**
  33917. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  33918. * This allowed control for front to back rendering or reversly depending of the special needs.
  33919. *
  33920. * @param renderingGroupId The rendering group id corresponding to its index
  33921. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  33922. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  33923. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  33924. */
  33925. 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;
  33926. /**
  33927. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  33928. *
  33929. * @param renderingGroupId The rendering group id corresponding to its index
  33930. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  33931. */
  33932. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  33933. clone(): RenderTargetTexture;
  33934. serialize(): any;
  33935. disposeFramebufferObjects(): void;
  33936. dispose(): void;
  33937. _rebuild(): void;
  33938. /**
  33939. * Clear the info related to rendering groups preventing retention point in material dispose.
  33940. */
  33941. freeRenderingGroups(): void;
  33942. }
  33943. }
  33944. declare module BABYLON {
  33945. class Texture extends BaseTexture {
  33946. static NEAREST_SAMPLINGMODE: number;
  33947. static NEAREST_NEAREST_MIPLINEAR: number;
  33948. static BILINEAR_SAMPLINGMODE: number;
  33949. static LINEAR_LINEAR_MIPNEAREST: number;
  33950. static TRILINEAR_SAMPLINGMODE: number;
  33951. static LINEAR_LINEAR_MIPLINEAR: number;
  33952. static NEAREST_NEAREST_MIPNEAREST: number;
  33953. static NEAREST_LINEAR_MIPNEAREST: number;
  33954. static NEAREST_LINEAR_MIPLINEAR: number;
  33955. static NEAREST_LINEAR: number;
  33956. static NEAREST_NEAREST: number;
  33957. static LINEAR_NEAREST_MIPNEAREST: number;
  33958. static LINEAR_NEAREST_MIPLINEAR: number;
  33959. static LINEAR_LINEAR: number;
  33960. static LINEAR_NEAREST: number;
  33961. static EXPLICIT_MODE: number;
  33962. static SPHERICAL_MODE: number;
  33963. static PLANAR_MODE: number;
  33964. static CUBIC_MODE: number;
  33965. static PROJECTION_MODE: number;
  33966. static SKYBOX_MODE: number;
  33967. static INVCUBIC_MODE: number;
  33968. static EQUIRECTANGULAR_MODE: number;
  33969. static FIXED_EQUIRECTANGULAR_MODE: number;
  33970. static FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  33971. static CLAMP_ADDRESSMODE: number;
  33972. static WRAP_ADDRESSMODE: number;
  33973. static MIRROR_ADDRESSMODE: number;
  33974. /**
  33975. * 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
  33976. */
  33977. static UseSerializedUrlIfAny: boolean;
  33978. url: Nullable<string>;
  33979. uOffset: number;
  33980. vOffset: number;
  33981. uScale: number;
  33982. vScale: number;
  33983. uAng: number;
  33984. vAng: number;
  33985. wAng: number;
  33986. /**
  33987. * Defines the center of rotation (U)
  33988. */
  33989. uRotationCenter: number;
  33990. /**
  33991. * Defines the center of rotation (V)
  33992. */
  33993. vRotationCenter: number;
  33994. /**
  33995. * Defines the center of rotation (W)
  33996. */
  33997. wRotationCenter: number;
  33998. readonly noMipmap: boolean;
  33999. private _noMipmap;
  34000. _invertY: boolean;
  34001. private _rowGenerationMatrix;
  34002. private _cachedTextureMatrix;
  34003. private _projectionModeMatrix;
  34004. private _t0;
  34005. private _t1;
  34006. private _t2;
  34007. private _cachedUOffset;
  34008. private _cachedVOffset;
  34009. private _cachedUScale;
  34010. private _cachedVScale;
  34011. private _cachedUAng;
  34012. private _cachedVAng;
  34013. private _cachedWAng;
  34014. private _cachedProjectionMatrixId;
  34015. private _cachedCoordinatesMode;
  34016. _samplingMode: number;
  34017. /** @hidden */
  34018. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  34019. private _deleteBuffer;
  34020. protected _format: Nullable<number>;
  34021. private _delayedOnLoad;
  34022. private _delayedOnError;
  34023. protected _onLoadObservable: Nullable<Observable<Texture>>;
  34024. protected _isBlocking: boolean;
  34025. isBlocking: boolean;
  34026. readonly samplingMode: number;
  34027. 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);
  34028. /**
  34029. * Update the url (and optional buffer) of this texture if url was null during construction.
  34030. * @param url the url of the texture
  34031. * @param buffer the buffer of the texture (defaults to null)
  34032. */
  34033. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>): void;
  34034. delayLoad(): void;
  34035. updateSamplingMode(samplingMode: number): void;
  34036. private _prepareRowForTextureGeneration(x, y, z, t);
  34037. getTextureMatrix(): Matrix;
  34038. getReflectionTextureMatrix(): Matrix;
  34039. clone(): Texture;
  34040. readonly onLoadObservable: Observable<Texture>;
  34041. serialize(): any;
  34042. getClassName(): string;
  34043. dispose(): void;
  34044. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  34045. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  34046. 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;
  34047. }
  34048. }
  34049. declare module BABYLON {
  34050. /**
  34051. * Settings for finer control over video usage
  34052. */
  34053. interface VideoTextureSettings {
  34054. /**
  34055. * Applies `autoplay` to video, if specified
  34056. */
  34057. autoPlay?: boolean;
  34058. /**
  34059. * Applies `loop` to video, if specified
  34060. */
  34061. loop?: boolean;
  34062. /**
  34063. * Automatically updates internal texture from video at every frame in the render loop
  34064. */
  34065. autoUpdateTexture: boolean;
  34066. }
  34067. class VideoTexture extends Texture {
  34068. /**
  34069. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  34070. */
  34071. readonly autoUpdateTexture: boolean;
  34072. /**
  34073. * The video instance used by the texture internally
  34074. */
  34075. readonly video: HTMLVideoElement;
  34076. private _generateMipMaps;
  34077. private _engine;
  34078. private _stillImageCaptured;
  34079. /**
  34080. * Creates a video texture.
  34081. * Sample : https://doc.babylonjs.com/how_to/video_texture
  34082. * @param {string | null} name optional name, will detect from video source, if not defined
  34083. * @param {(string | string[] | HTMLVideoElement)} src can be used to provide an url, array of urls or an already setup HTML video element.
  34084. * @param {BABYLON.Scene} scene is obviously the current scene.
  34085. * @param {boolean} generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  34086. * @param {boolean} invertY is false by default but can be used to invert video on Y axis
  34087. * @param {number} samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  34088. * @param {VideoTextureSettings} [settings] allows finer control over video usage
  34089. */
  34090. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  34091. private _getName(src);
  34092. private _getVideo(src);
  34093. private _createInternalTexture;
  34094. private reset;
  34095. /**
  34096. * Internal method to initiate `update`.
  34097. */
  34098. _rebuild(): void;
  34099. /**
  34100. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  34101. */
  34102. update(): void;
  34103. /**
  34104. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  34105. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  34106. */
  34107. updateTexture(isVisible: boolean): void;
  34108. protected _updateInternalTexture: (e?: Event | undefined) => void;
  34109. /**
  34110. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  34111. * @param url New url.
  34112. */
  34113. updateURL(url: string): void;
  34114. dispose(): void;
  34115. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  34116. minWidth: number;
  34117. maxWidth: number;
  34118. minHeight: number;
  34119. maxHeight: number;
  34120. deviceId: string;
  34121. }): void;
  34122. }
  34123. }
  34124. declare var DracoDecoderModule: any;
  34125. declare var WebAssembly: any;
  34126. declare module BABYLON {
  34127. /**
  34128. * Configuration for Draco compression
  34129. */
  34130. interface IDracoCompressionConfiguration {
  34131. /**
  34132. * Configuration for the decoder.
  34133. */
  34134. decoder?: {
  34135. /**
  34136. * The url to the WebAssembly module.
  34137. */
  34138. wasmUrl?: string;
  34139. /**
  34140. * The url to the WebAssembly binary.
  34141. */
  34142. wasmBinaryUrl?: string;
  34143. /**
  34144. * The url to the fallback JavaScript module.
  34145. */
  34146. fallbackUrl?: string;
  34147. };
  34148. }
  34149. /**
  34150. * Draco compression (https://google.github.io/draco/)
  34151. *
  34152. * This class wraps the Draco module.
  34153. *
  34154. * **Encoder**
  34155. *
  34156. * The encoder is not currently implemented.
  34157. *
  34158. * **Decoder**
  34159. *
  34160. * By default, the configuration points to a copy of the Draco decoder files for glTF from https://preview.babylonjs.com.
  34161. *
  34162. * To update the configuration, use the following code:
  34163. * ```javascript
  34164. * BABYLON.DracoCompression.Configuration = {
  34165. * decoder: {
  34166. * wasmUrl: "<url to the WebAssembly library>",
  34167. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  34168. * fallbackUrl: "<url to the fallback JavaScript library>",
  34169. * }
  34170. * };
  34171. * ```
  34172. *
  34173. * 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.
  34174. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  34175. * Use `BABYLON.DracoCompression.DecoderAvailable` to determine if the decoder is available for the current session.
  34176. *
  34177. * To decode Draco compressed data, create a DracoCompression object and call decodeMeshAsync:
  34178. * ```javascript
  34179. * var dracoCompression = new BABYLON.DracoCompression();
  34180. * var vertexData = await dracoCompression.decodeMeshAsync(data, {
  34181. * [BABYLON.VertexBuffer.PositionKind]: 0
  34182. * });
  34183. * ```
  34184. *
  34185. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  34186. */
  34187. class DracoCompression implements IDisposable {
  34188. private static _DecoderModulePromise;
  34189. /**
  34190. * The configuration. Defaults to the following urls:
  34191. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  34192. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  34193. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  34194. */
  34195. static Configuration: IDracoCompressionConfiguration;
  34196. /**
  34197. * Returns true if the decoder is available.
  34198. */
  34199. static readonly DecoderAvailable: boolean;
  34200. /**
  34201. * Constructor
  34202. */
  34203. constructor();
  34204. /**
  34205. * Stop all async operations and release resources.
  34206. */
  34207. dispose(): void;
  34208. /**
  34209. * Decode Draco compressed mesh data to vertex data.
  34210. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  34211. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  34212. * @returns A promise that resolves with the decoded vertex data
  34213. */
  34214. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes: {
  34215. [kind: string]: number;
  34216. }): Promise<VertexData>;
  34217. private static _GetDecoderModule();
  34218. private static _LoadScriptAsync(url);
  34219. private static _LoadFileAsync(url);
  34220. }
  34221. }
  34222. declare module BABYLON {
  34223. /**
  34224. * Particle emitter emitting particles from the inside of a box.
  34225. * It emits the particles randomly between 2 given directions.
  34226. */
  34227. class BoxParticleEmitter implements IParticleEmitterType {
  34228. /**
  34229. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  34230. */
  34231. direction1: Vector3;
  34232. /**
  34233. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  34234. */
  34235. direction2: Vector3;
  34236. /**
  34237. * 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.
  34238. */
  34239. minEmitBox: Vector3;
  34240. /**
  34241. * 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.
  34242. */
  34243. maxEmitBox: Vector3;
  34244. /**
  34245. * Creates a new instance BoxParticleEmitter
  34246. */
  34247. constructor();
  34248. /**
  34249. * Called by the particle System when the direction is computed for the created particle.
  34250. * @param emitPower is the power of the particle (speed)
  34251. * @param worldMatrix is the world matrix of the particle system
  34252. * @param directionToUpdate is the direction vector to update with the result
  34253. * @param particle is the particle we are computed the direction for
  34254. */
  34255. startDirectionFunction(emitPower: number, worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  34256. /**
  34257. * Called by the particle System when the position is computed for the created particle.
  34258. * @param worldMatrix is the world matrix of the particle system
  34259. * @param positionToUpdate is the position vector to update with the result
  34260. * @param particle is the particle we are computed the position for
  34261. */
  34262. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  34263. /**
  34264. * Clones the current emitter and returns a copy of it
  34265. * @returns the new emitter
  34266. */
  34267. clone(): BoxParticleEmitter;
  34268. /**
  34269. * Called by the {BABYLON.GPUParticleSystem} to setup the update shader
  34270. * @param effect defines the update shader
  34271. */
  34272. applyToShader(effect: Effect): void;
  34273. /**
  34274. * Returns a string to use to update the GPU particles update shader
  34275. * @returns a string containng the defines string
  34276. */
  34277. getEffectDefines(): string;
  34278. /**
  34279. * Returns the string "BoxEmitter"
  34280. * @returns a string containing the class name
  34281. */
  34282. getClassName(): string;
  34283. /**
  34284. * Serializes the particle system to a JSON object.
  34285. * @returns the JSON object
  34286. */
  34287. serialize(): any;
  34288. /**
  34289. * Parse properties from a JSON object
  34290. * @param serializationObject defines the JSON object
  34291. */
  34292. parse(serializationObject: any): void;
  34293. }
  34294. }
  34295. declare module BABYLON {
  34296. /**
  34297. * Particle emitter emitting particles from the inside of a cone.
  34298. * It emits the particles alongside the cone volume from the base to the particle.
  34299. * The emission direction might be randomized.
  34300. */
  34301. class ConeParticleEmitter implements IParticleEmitterType {
  34302. /**
  34303. * The radius of the emission cone.
  34304. */
  34305. angle: number;
  34306. /**
  34307. * The cone base angle.
  34308. */
  34309. directionRandomizer: number;
  34310. private _radius;
  34311. private _height;
  34312. /**
  34313. * Gets the radius of the emission cone.
  34314. */
  34315. /**
  34316. * Sets the radius of the emission cone.
  34317. */
  34318. radius: number;
  34319. /**
  34320. * Creates a new instance ConeParticleEmitter
  34321. * @param radius the radius of the emission cone (1 by default)
  34322. * @param angles the cone base angle (PI by default)
  34323. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  34324. */
  34325. constructor(radius?: number,
  34326. /**
  34327. * The radius of the emission cone.
  34328. */
  34329. angle?: number,
  34330. /**
  34331. * The cone base angle.
  34332. */
  34333. directionRandomizer?: number);
  34334. /**
  34335. * Called by the particle System when the direction is computed for the created particle.
  34336. * @param emitPower is the power of the particle (speed)
  34337. * @param worldMatrix is the world matrix of the particle system
  34338. * @param directionToUpdate is the direction vector to update with the result
  34339. * @param particle is the particle we are computed the direction for
  34340. */
  34341. startDirectionFunction(emitPower: number, worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  34342. /**
  34343. * Called by the particle System when the position is computed for the created particle.
  34344. * @param worldMatrix is the world matrix of the particle system
  34345. * @param positionToUpdate is the position vector to update with the result
  34346. * @param particle is the particle we are computed the position for
  34347. */
  34348. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  34349. /**
  34350. * Clones the current emitter and returns a copy of it
  34351. * @returns the new emitter
  34352. */
  34353. clone(): ConeParticleEmitter;
  34354. /**
  34355. * Called by the {BABYLON.GPUParticleSystem} to setup the update shader
  34356. * @param effect defines the update shader
  34357. */
  34358. applyToShader(effect: Effect): void;
  34359. /**
  34360. * Returns a string to use to update the GPU particles update shader
  34361. * @returns a string containng the defines string
  34362. */
  34363. getEffectDefines(): string;
  34364. /**
  34365. * Returns the string "BoxEmitter"
  34366. * @returns a string containing the class name
  34367. */
  34368. getClassName(): string;
  34369. /**
  34370. * Serializes the particle system to a JSON object.
  34371. * @returns the JSON object
  34372. */
  34373. serialize(): any;
  34374. /**
  34375. * Parse properties from a JSON object
  34376. * @param serializationObject defines the JSON object
  34377. */
  34378. parse(serializationObject: any): void;
  34379. }
  34380. }
  34381. declare module BABYLON {
  34382. /**
  34383. * Particle emitter represents a volume emitting particles.
  34384. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  34385. */
  34386. interface IParticleEmitterType {
  34387. /**
  34388. * Called by the particle System when the direction is computed for the created particle.
  34389. * @param emitPower is the power of the particle (speed)
  34390. * @param worldMatrix is the world matrix of the particle system
  34391. * @param directionToUpdate is the direction vector to update with the result
  34392. * @param particle is the particle we are computed the direction for
  34393. */
  34394. startDirectionFunction(emitPower: number, worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  34395. /**
  34396. * Called by the particle System when the position is computed for the created particle.
  34397. * @param worldMatrix is the world matrix of the particle system
  34398. * @param positionToUpdate is the position vector to update with the result
  34399. * @param particle is the particle we are computed the position for
  34400. */
  34401. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  34402. /**
  34403. * Clones the current emitter and returns a copy of it
  34404. * @returns the new emitter
  34405. */
  34406. clone(): IParticleEmitterType;
  34407. /**
  34408. * Called by the {BABYLON.GPUParticleSystem} to setup the update shader
  34409. * @param effect defines the update shader
  34410. */
  34411. applyToShader(effect: Effect): void;
  34412. /**
  34413. * Returns a string to use to update the GPU particles update shader
  34414. * @returns the effect defines string
  34415. */
  34416. getEffectDefines(): string;
  34417. /**
  34418. * Returns a string representing the class name
  34419. * @returns a string containing the class name
  34420. */
  34421. getClassName(): string;
  34422. /**
  34423. * Serializes the particle system to a JSON object.
  34424. * @returns the JSON object
  34425. */
  34426. serialize(): any;
  34427. /**
  34428. * Parse properties from a JSON object
  34429. * @param serializationObject defines the JSON object
  34430. */
  34431. parse(serializationObject: any): void;
  34432. }
  34433. }
  34434. declare module BABYLON {
  34435. /**
  34436. * Particle emitter emitting particles from the inside of a sphere.
  34437. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  34438. */
  34439. class SphereParticleEmitter implements IParticleEmitterType {
  34440. /**
  34441. * The radius of the emission sphere.
  34442. */
  34443. radius: number;
  34444. /**
  34445. * How much to randomize the particle direction [0-1].
  34446. */
  34447. directionRandomizer: number;
  34448. /**
  34449. * Creates a new instance SphereParticleEmitter
  34450. * @param radius the radius of the emission sphere (1 by default)
  34451. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  34452. */
  34453. constructor(
  34454. /**
  34455. * The radius of the emission sphere.
  34456. */
  34457. radius?: number,
  34458. /**
  34459. * How much to randomize the particle direction [0-1].
  34460. */
  34461. directionRandomizer?: number);
  34462. /**
  34463. * Called by the particle System when the direction is computed for the created particle.
  34464. * @param emitPower is the power of the particle (speed)
  34465. * @param worldMatrix is the world matrix of the particle system
  34466. * @param directionToUpdate is the direction vector to update with the result
  34467. * @param particle is the particle we are computed the direction for
  34468. */
  34469. startDirectionFunction(emitPower: number, worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  34470. /**
  34471. * Called by the particle System when the position is computed for the created particle.
  34472. * @param worldMatrix is the world matrix of the particle system
  34473. * @param positionToUpdate is the position vector to update with the result
  34474. * @param particle is the particle we are computed the position for
  34475. */
  34476. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  34477. /**
  34478. * Clones the current emitter and returns a copy of it
  34479. * @returns the new emitter
  34480. */
  34481. clone(): SphereParticleEmitter;
  34482. /**
  34483. * Called by the {BABYLON.GPUParticleSystem} to setup the update shader
  34484. * @param effect defines the update shader
  34485. */
  34486. applyToShader(effect: Effect): void;
  34487. /**
  34488. * Returns a string to use to update the GPU particles update shader
  34489. * @returns a string containng the defines string
  34490. */
  34491. getEffectDefines(): string;
  34492. /**
  34493. * Returns the string "SphereParticleEmitter"
  34494. * @returns a string containing the class name
  34495. */
  34496. getClassName(): string;
  34497. /**
  34498. * Serializes the particle system to a JSON object.
  34499. * @returns the JSON object
  34500. */
  34501. serialize(): any;
  34502. /**
  34503. * Parse properties from a JSON object
  34504. * @param serializationObject defines the JSON object
  34505. */
  34506. parse(serializationObject: any): void;
  34507. }
  34508. /**
  34509. * Particle emitter emitting particles from the inside of a sphere.
  34510. * It emits the particles randomly between two vectors.
  34511. */
  34512. class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  34513. /**
  34514. * The min limit of the emission direction.
  34515. */
  34516. direction1: Vector3;
  34517. /**
  34518. * The max limit of the emission direction.
  34519. */
  34520. direction2: Vector3;
  34521. /**
  34522. * Creates a new instance SphereDirectedParticleEmitter
  34523. * @param radius the radius of the emission sphere (1 by default)
  34524. * @param direction1 the min limit of the emission direction (up vector by default)
  34525. * @param direction2 the max limit of the emission direction (up vector by default)
  34526. */
  34527. constructor(radius?: number,
  34528. /**
  34529. * The min limit of the emission direction.
  34530. */
  34531. direction1?: Vector3,
  34532. /**
  34533. * The max limit of the emission direction.
  34534. */
  34535. direction2?: Vector3);
  34536. /**
  34537. * Called by the particle System when the direction is computed for the created particle.
  34538. * @param emitPower is the power of the particle (speed)
  34539. * @param worldMatrix is the world matrix of the particle system
  34540. * @param directionToUpdate is the direction vector to update with the result
  34541. * @param particle is the particle we are computed the direction for
  34542. */
  34543. startDirectionFunction(emitPower: number, worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  34544. /**
  34545. * Clones the current emitter and returns a copy of it
  34546. * @returns the new emitter
  34547. */
  34548. clone(): SphereDirectedParticleEmitter;
  34549. /**
  34550. * Called by the {BABYLON.GPUParticleSystem} to setup the update shader
  34551. * @param effect defines the update shader
  34552. */
  34553. applyToShader(effect: Effect): void;
  34554. /**
  34555. * Returns a string to use to update the GPU particles update shader
  34556. * @returns a string containng the defines string
  34557. */
  34558. getEffectDefines(): string;
  34559. /**
  34560. * Returns the string "SphereDirectedParticleEmitter"
  34561. * @returns a string containing the class name
  34562. */
  34563. getClassName(): string;
  34564. /**
  34565. * Serializes the particle system to a JSON object.
  34566. * @returns the JSON object
  34567. */
  34568. serialize(): any;
  34569. /**
  34570. * Parse properties from a JSON object
  34571. * @param serializationObject defines the JSON object
  34572. */
  34573. parse(serializationObject: any): void;
  34574. }
  34575. }
  34576. declare module BABYLON {
  34577. class CannonJSPlugin implements IPhysicsEnginePlugin {
  34578. private _useDeltaForWorldStep;
  34579. world: any;
  34580. name: string;
  34581. private _physicsMaterials;
  34582. private _fixedTimeStep;
  34583. BJSCANNON: any;
  34584. constructor(_useDeltaForWorldStep?: boolean, iterations?: number);
  34585. setGravity(gravity: Vector3): void;
  34586. setTimeStep(timeStep: number): void;
  34587. getTimeStep(): number;
  34588. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  34589. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  34590. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  34591. generatePhysicsBody(impostor: PhysicsImpostor): void;
  34592. private _processChildMeshes(mainImpostor);
  34593. removePhysicsBody(impostor: PhysicsImpostor): void;
  34594. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  34595. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  34596. private _addMaterial(name, friction, restitution);
  34597. private _checkWithEpsilon(value);
  34598. private _createShape(impostor);
  34599. private _createHeightmap(object, pointDepth?);
  34600. private _minus90X;
  34601. private _plus90X;
  34602. private _tmpPosition;
  34603. private _tmpDeltaPosition;
  34604. private _tmpUnityRotation;
  34605. private _updatePhysicsBodyTransformation(impostor);
  34606. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  34607. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  34608. isSupported(): boolean;
  34609. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  34610. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  34611. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  34612. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  34613. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  34614. getBodyMass(impostor: PhysicsImpostor): number;
  34615. getBodyFriction(impostor: PhysicsImpostor): number;
  34616. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  34617. getBodyRestitution(impostor: PhysicsImpostor): number;
  34618. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  34619. sleepBody(impostor: PhysicsImpostor): void;
  34620. wakeUpBody(impostor: PhysicsImpostor): void;
  34621. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  34622. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  34623. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  34624. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  34625. getRadius(impostor: PhysicsImpostor): number;
  34626. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  34627. dispose(): void;
  34628. private _extendNamespace();
  34629. }
  34630. }
  34631. declare module BABYLON {
  34632. class OimoJSPlugin implements IPhysicsEnginePlugin {
  34633. world: any;
  34634. name: string;
  34635. BJSOIMO: any;
  34636. constructor(iterations?: number);
  34637. setGravity(gravity: Vector3): void;
  34638. setTimeStep(timeStep: number): void;
  34639. getTimeStep(): number;
  34640. private _tmpImpostorsArray;
  34641. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  34642. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  34643. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  34644. generatePhysicsBody(impostor: PhysicsImpostor): void;
  34645. private _tmpPositionVector;
  34646. removePhysicsBody(impostor: PhysicsImpostor): void;
  34647. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  34648. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  34649. isSupported(): boolean;
  34650. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  34651. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  34652. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  34653. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  34654. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  34655. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  34656. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  34657. getBodyMass(impostor: PhysicsImpostor): number;
  34658. getBodyFriction(impostor: PhysicsImpostor): number;
  34659. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  34660. getBodyRestitution(impostor: PhysicsImpostor): number;
  34661. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  34662. sleepBody(impostor: PhysicsImpostor): void;
  34663. wakeUpBody(impostor: PhysicsImpostor): void;
  34664. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  34665. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  34666. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  34667. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  34668. getRadius(impostor: PhysicsImpostor): number;
  34669. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  34670. dispose(): void;
  34671. }
  34672. }
  34673. declare module BABYLON {
  34674. /**
  34675. * This represents a set of one or more post processes in Babylon.
  34676. * A post process can be used to apply a shader to a texture after it is rendered.
  34677. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  34678. */
  34679. class PostProcessRenderEffect {
  34680. private _postProcesses;
  34681. private _getPostProcesses;
  34682. private _singleInstance;
  34683. private _cameras;
  34684. private _indicesForCamera;
  34685. /**
  34686. * Name of the effect
  34687. */
  34688. _name: string;
  34689. /**
  34690. * Instantiates a post process render effect.
  34691. * A post process can be used to apply a shader to a texture after it is rendered.
  34692. * @param engine The engine the effect is tied to
  34693. * @param name The name of the effect
  34694. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  34695. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  34696. */
  34697. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  34698. /**
  34699. * Checks if all the post processes in the effect are supported.
  34700. */
  34701. readonly isSupported: boolean;
  34702. /**
  34703. * Updates the current state of the effect
  34704. */
  34705. _update(): void;
  34706. /**
  34707. * Attaches the effect on cameras
  34708. * @param cameras The camera to attach to.
  34709. */
  34710. _attachCameras(cameras: Camera): void;
  34711. /**
  34712. * Attaches the effect on cameras
  34713. * @param cameras The camera to attach to.
  34714. */
  34715. _attachCameras(cameras: Camera[]): void;
  34716. /**
  34717. * Detatches the effect on cameras
  34718. * @param cameras The camera to detatch from.
  34719. */
  34720. _detachCameras(cameras: Camera): void;
  34721. /**
  34722. * Detatches the effect on cameras
  34723. * @param cameras The camera to detatch from.
  34724. */
  34725. _detachCameras(cameras: Camera[]): void;
  34726. /**
  34727. * Enables the effect on given cameras
  34728. * @param cameras The camera to enable.
  34729. */
  34730. _enable(cameras: Camera): void;
  34731. /**
  34732. * Enables the effect on given cameras
  34733. * @param cameras The camera to enable.
  34734. */
  34735. _enable(cameras: Nullable<Camera[]>): void;
  34736. /**
  34737. * Disables the effect on the given cameras
  34738. * @param cameras The camera to disable.
  34739. */
  34740. _disable(cameras: Camera): void;
  34741. /**
  34742. * Disables the effect on the given cameras
  34743. * @param cameras The camera to disable.
  34744. */
  34745. _disable(cameras: Nullable<Camera[]>): void;
  34746. /**
  34747. * Gets a list of the post processes contained in the effect.
  34748. * @param camera The camera to get the post processes on.
  34749. * @returns The list of the post processes in the effect.
  34750. */
  34751. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  34752. }
  34753. }
  34754. declare module BABYLON {
  34755. class PostProcessRenderPipeline {
  34756. private engine;
  34757. private _renderEffects;
  34758. private _renderEffectsForIsolatedPass;
  34759. protected _cameras: Camera[];
  34760. _name: string;
  34761. constructor(engine: Engine, name: string);
  34762. getClassName(): string;
  34763. readonly isSupported: boolean;
  34764. addEffect(renderEffect: PostProcessRenderEffect): void;
  34765. _rebuild(): void;
  34766. _enableEffect(renderEffectName: string, cameras: Camera): void;
  34767. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  34768. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  34769. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  34770. _attachCameras(cameras: Camera, unique: boolean): void;
  34771. _attachCameras(cameras: Camera[], unique: boolean): void;
  34772. _detachCameras(cameras: Camera): void;
  34773. _detachCameras(cameras: Nullable<Camera[]>): void;
  34774. _update(): void;
  34775. _reset(): void;
  34776. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  34777. dispose(): void;
  34778. }
  34779. }
  34780. declare module BABYLON {
  34781. class PostProcessRenderPipelineManager {
  34782. private _renderPipelines;
  34783. constructor();
  34784. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  34785. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: Camera, unique?: boolean): void;
  34786. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: Camera[], unique?: boolean): void;
  34787. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: Camera): void;
  34788. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: Camera[]): void;
  34789. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: Camera): void;
  34790. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: Camera[]): void;
  34791. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: Camera): void;
  34792. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: Camera[]): void;
  34793. update(): void;
  34794. _rebuild(): void;
  34795. dispose(): void;
  34796. }
  34797. }
  34798. declare module BABYLON {
  34799. /**
  34800. * Helper class dealing with the extraction of spherical polynomial dataArray
  34801. * from a cube map.
  34802. */
  34803. class CubeMapToSphericalPolynomialTools {
  34804. private static FileFaces;
  34805. /**
  34806. * Converts a texture to the according Spherical Polynomial data.
  34807. * This extracts the first 3 orders only as they are the only one used in the lighting.
  34808. *
  34809. * @param texture The texture to extract the information from.
  34810. * @return The Spherical Polynomial data.
  34811. */
  34812. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  34813. /**
  34814. * Converts a cubemap to the according Spherical Polynomial data.
  34815. * This extracts the first 3 orders only as they are the only one used in the lighting.
  34816. *
  34817. * @param cubeInfo The Cube map to extract the information from.
  34818. * @return The Spherical Polynomial data.
  34819. */
  34820. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  34821. }
  34822. }
  34823. declare module BABYLON {
  34824. /**
  34825. * Header information of HDR texture files.
  34826. */
  34827. interface HDRInfo {
  34828. /**
  34829. * The height of the texture in pixels.
  34830. */
  34831. height: number;
  34832. /**
  34833. * The width of the texture in pixels.
  34834. */
  34835. width: number;
  34836. /**
  34837. * The index of the beginning of the data in the binary file.
  34838. */
  34839. dataPosition: number;
  34840. }
  34841. /**
  34842. * This groups tools to convert HDR texture to native colors array.
  34843. */
  34844. class HDRTools {
  34845. private static Ldexp(mantissa, exponent);
  34846. private static Rgbe2float(float32array, red, green, blue, exponent, index);
  34847. private static readStringLine(uint8array, startIndex);
  34848. /**
  34849. * Reads header information from an RGBE texture stored in a native array.
  34850. * More information on this format are available here:
  34851. * https://en.wikipedia.org/wiki/RGBE_image_format
  34852. *
  34853. * @param uint8array The binary file stored in native array.
  34854. * @return The header information.
  34855. */
  34856. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  34857. /**
  34858. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  34859. * This RGBE texture needs to store the information as a panorama.
  34860. *
  34861. * More information on this format are available here:
  34862. * https://en.wikipedia.org/wiki/RGBE_image_format
  34863. *
  34864. * @param buffer The binary file stored in an array buffer.
  34865. * @param size The expected size of the extracted cubemap.
  34866. * @return The Cube Map information.
  34867. */
  34868. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  34869. /**
  34870. * Returns the pixels data extracted from an RGBE texture.
  34871. * This pixels will be stored left to right up to down in the R G B order in one array.
  34872. *
  34873. * More information on this format are available here:
  34874. * https://en.wikipedia.org/wiki/RGBE_image_format
  34875. *
  34876. * @param uint8array The binary file stored in an array buffer.
  34877. * @param hdrInfo The header information of the file.
  34878. * @return The pixels data in RGB right to left up to down order.
  34879. */
  34880. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  34881. private static RGBE_ReadPixels_RLE(uint8array, hdrInfo);
  34882. }
  34883. }
  34884. declare module BABYLON {
  34885. /**
  34886. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  34887. */
  34888. interface CubeMapInfo {
  34889. /**
  34890. * The pixel array for the front face.
  34891. * This is stored in format, left to right, up to down format.
  34892. */
  34893. front: Nullable<ArrayBufferView>;
  34894. /**
  34895. * The pixel array for the back face.
  34896. * This is stored in format, left to right, up to down format.
  34897. */
  34898. back: Nullable<ArrayBufferView>;
  34899. /**
  34900. * The pixel array for the left face.
  34901. * This is stored in format, left to right, up to down format.
  34902. */
  34903. left: Nullable<ArrayBufferView>;
  34904. /**
  34905. * The pixel array for the right face.
  34906. * This is stored in format, left to right, up to down format.
  34907. */
  34908. right: Nullable<ArrayBufferView>;
  34909. /**
  34910. * The pixel array for the up face.
  34911. * This is stored in format, left to right, up to down format.
  34912. */
  34913. up: Nullable<ArrayBufferView>;
  34914. /**
  34915. * The pixel array for the down face.
  34916. * This is stored in format, left to right, up to down format.
  34917. */
  34918. down: Nullable<ArrayBufferView>;
  34919. /**
  34920. * The size of the cubemap stored.
  34921. *
  34922. * Each faces will be size * size pixels.
  34923. */
  34924. size: number;
  34925. /**
  34926. * The format of the texture.
  34927. *
  34928. * RGBA, RGB.
  34929. */
  34930. format: number;
  34931. /**
  34932. * The type of the texture data.
  34933. *
  34934. * UNSIGNED_INT, FLOAT.
  34935. */
  34936. type: number;
  34937. /**
  34938. * Specifies whether the texture is in gamma space.
  34939. */
  34940. gammaSpace: boolean;
  34941. }
  34942. /**
  34943. * Helper class usefull to convert panorama picture to their cubemap representation in 6 faces.
  34944. */
  34945. class PanoramaToCubeMapTools {
  34946. private static FACE_FRONT;
  34947. private static FACE_BACK;
  34948. private static FACE_RIGHT;
  34949. private static FACE_LEFT;
  34950. private static FACE_DOWN;
  34951. private static FACE_UP;
  34952. /**
  34953. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  34954. *
  34955. * @param float32Array The source data.
  34956. * @param inputWidth The width of the input panorama.
  34957. * @param inputhHeight The height of the input panorama.
  34958. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  34959. * @return The cubemap data
  34960. */
  34961. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  34962. private static CreateCubemapTexture(texSize, faceData, float32Array, inputWidth, inputHeight);
  34963. private static CalcProjectionSpherical(vDir, float32Array, inputWidth, inputHeight);
  34964. }
  34965. }
  34966. declare module BABYLON {
  34967. class CustomProceduralTexture extends ProceduralTexture {
  34968. private _animate;
  34969. private _time;
  34970. private _config;
  34971. private _texturePath;
  34972. constructor(name: string, texturePath: any, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  34973. private loadJson(jsonUrl);
  34974. isReady(): boolean;
  34975. render(useCameraPostProcess?: boolean): void;
  34976. updateTextures(): void;
  34977. updateShaderUniforms(): void;
  34978. animate: boolean;
  34979. }
  34980. }
  34981. declare module BABYLON {
  34982. class ProceduralTexture extends Texture {
  34983. isCube: boolean;
  34984. private _size;
  34985. _generateMipMaps: boolean;
  34986. isEnabled: boolean;
  34987. private _currentRefreshId;
  34988. private _refreshRate;
  34989. onGenerated: () => void;
  34990. private _vertexBuffers;
  34991. private _indexBuffer;
  34992. private _effect;
  34993. private _uniforms;
  34994. private _samplers;
  34995. private _fragment;
  34996. _textures: {
  34997. [key: string]: Texture;
  34998. };
  34999. private _floats;
  35000. private _floatsArrays;
  35001. private _colors3;
  35002. private _colors4;
  35003. private _vectors2;
  35004. private _vectors3;
  35005. private _matrices;
  35006. private _fallbackTexture;
  35007. private _fallbackTextureUsed;
  35008. private _engine;
  35009. constructor(name: string, size: any, fragment: any, scene: Scene, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  35010. private _createIndexBuffer();
  35011. _rebuild(): void;
  35012. reset(): void;
  35013. isReady(): boolean;
  35014. resetRefreshCounter(): void;
  35015. setFragment(fragment: any): void;
  35016. refreshRate: number;
  35017. _shouldRender(): boolean;
  35018. getRenderSize(): number;
  35019. resize(size: number, generateMipMaps: boolean): void;
  35020. private _checkUniform(uniformName);
  35021. setTexture(name: string, texture: Texture): ProceduralTexture;
  35022. setFloat(name: string, value: number): ProceduralTexture;
  35023. setFloats(name: string, value: number[]): ProceduralTexture;
  35024. setColor3(name: string, value: Color3): ProceduralTexture;
  35025. setColor4(name: string, value: Color4): ProceduralTexture;
  35026. setVector2(name: string, value: Vector2): ProceduralTexture;
  35027. setVector3(name: string, value: Vector3): ProceduralTexture;
  35028. setMatrix(name: string, value: Matrix): ProceduralTexture;
  35029. render(useCameraPostProcess?: boolean): void;
  35030. clone(): ProceduralTexture;
  35031. dispose(): void;
  35032. }
  35033. }
  35034. declare module BABYLON {
  35035. /**
  35036. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  35037. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  35038. */
  35039. class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  35040. private _scene;
  35041. private _originalCameras;
  35042. /**
  35043. * ID of the sharpen post process,
  35044. */
  35045. private readonly SharpenPostProcessId;
  35046. /**
  35047. * ID of the image processing post process;
  35048. */
  35049. readonly ImageProcessingPostProcessId: string;
  35050. /**
  35051. * ID of the Fast Approximate Anti-Aliasing post process;
  35052. */
  35053. readonly FxaaPostProcessId: string;
  35054. /**
  35055. * ID of the chromatic aberration post process,
  35056. */
  35057. private readonly ChromaticAberrationPostProcessId;
  35058. /**
  35059. * ID of the grain post process
  35060. */
  35061. private readonly GrainPostProcessId;
  35062. /**
  35063. * Sharpen post process which will apply a sharpen convolution to enhance edges
  35064. */
  35065. sharpen: SharpenPostProcess;
  35066. private _sharpenEffect;
  35067. private bloom;
  35068. /**
  35069. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  35070. */
  35071. depthOfField: DepthOfFieldEffect;
  35072. /**
  35073. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  35074. */
  35075. fxaa: FxaaPostProcess;
  35076. /**
  35077. * Image post processing pass used to perform operations such as tone mapping or color grading.
  35078. */
  35079. imageProcessing: ImageProcessingPostProcess;
  35080. /**
  35081. * Chromatic aberration post process which will shift rgb colors in the image
  35082. */
  35083. chromaticAberration: ChromaticAberrationPostProcess;
  35084. private _chromaticAberrationEffect;
  35085. /**
  35086. * Grain post process which add noise to the image
  35087. */
  35088. grain: GrainPostProcess;
  35089. private _grainEffect;
  35090. /**
  35091. * Glow post process which adds a glow to emmisive areas of the image
  35092. */
  35093. private _glowLayer;
  35094. /**
  35095. * Animations which can be used to tweak settings over a period of time
  35096. */
  35097. animations: Animation[];
  35098. private _imageProcessingConfigurationObserver;
  35099. private _sharpenEnabled;
  35100. private _bloomEnabled;
  35101. private _depthOfFieldEnabled;
  35102. private _depthOfFieldBlurLevel;
  35103. private _fxaaEnabled;
  35104. private _imageProcessingEnabled;
  35105. private _defaultPipelineTextureType;
  35106. private _bloomScale;
  35107. private _chromaticAberrationEnabled;
  35108. private _grainEnabled;
  35109. private _buildAllowed;
  35110. /**
  35111. * Enable or disable the sharpen process from the pipeline
  35112. */
  35113. sharpenEnabled: boolean;
  35114. private _resizeObserver;
  35115. private _hardwareScaleLevel;
  35116. private _bloomKernel;
  35117. /**
  35118. * Specifies the size of the bloom blur kernel, relative to the final output size
  35119. */
  35120. bloomKernel: number;
  35121. /**
  35122. * Specifies the weight of the bloom in the final rendering
  35123. */
  35124. private _bloomWeight;
  35125. /**
  35126. * Specifies the luma threshold for the area that will be blurred by the bloom
  35127. */
  35128. private _bloomThreshold;
  35129. private _hdr;
  35130. /**
  35131. * The strength of the bloom.
  35132. */
  35133. bloomWeight: number;
  35134. /**
  35135. * The strength of the bloom.
  35136. */
  35137. bloomThreshold: number;
  35138. /**
  35139. * The scale of the bloom, lower value will provide better performance.
  35140. */
  35141. bloomScale: number;
  35142. /**
  35143. * Enable or disable the bloom from the pipeline
  35144. */
  35145. bloomEnabled: boolean;
  35146. private _rebuildBloom();
  35147. /**
  35148. * If the depth of field is enabled.
  35149. */
  35150. depthOfFieldEnabled: boolean;
  35151. /**
  35152. * Blur level of the depth of field effect. (Higher blur will effect performance)
  35153. */
  35154. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  35155. /**
  35156. * If the anti aliasing is enabled.
  35157. */
  35158. fxaaEnabled: boolean;
  35159. private _samples;
  35160. /**
  35161. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  35162. */
  35163. samples: number;
  35164. /**
  35165. * If image processing is enabled.
  35166. */
  35167. imageProcessingEnabled: boolean;
  35168. /**
  35169. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  35170. */
  35171. glowLayerEnabled: boolean;
  35172. /**
  35173. * Enable or disable the chromaticAberration process from the pipeline
  35174. */
  35175. chromaticAberrationEnabled: boolean;
  35176. /**
  35177. * Enable or disable the grain process from the pipeline
  35178. */
  35179. grainEnabled: boolean;
  35180. /**
  35181. * @constructor
  35182. * @param {string} name - The rendering pipeline name (default: "")
  35183. * @param {boolean} hdr - If high dynamic range textures should be used (default: true)
  35184. * @param {BABYLON.Scene} scene - The scene linked to this pipeline (default: the last created scene)
  35185. * @param {BABYLON.Camera[]} cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  35186. * @param {boolean} automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  35187. */
  35188. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  35189. /**
  35190. * Force the compilation of the entire pipeline.
  35191. */
  35192. prepare(): void;
  35193. private _hasCleared;
  35194. private _prevPostProcess;
  35195. private _prevPrevPostProcess;
  35196. private _setAutoClearAndTextureSharing(postProcess, skipTextureSharing?);
  35197. private _buildPipeline();
  35198. private _disposePostProcesses(disposeNonRecreated?);
  35199. /**
  35200. * Dispose of the pipeline and stop all post processes
  35201. */
  35202. dispose(): void;
  35203. /**
  35204. * Serialize the rendering pipeline (Used when exporting)
  35205. * @returns the serialized object
  35206. */
  35207. serialize(): any;
  35208. /**
  35209. * Parse the serialized pipeline
  35210. * @param source Source pipeline.
  35211. * @param scene The scene to load the pipeline to.
  35212. * @param rootUrl The URL of the serialized pipeline.
  35213. * @returns An instantiated pipeline from the serialized object.
  35214. */
  35215. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  35216. }
  35217. }
  35218. declare module BABYLON {
  35219. class LensRenderingPipeline extends PostProcessRenderPipeline {
  35220. /**
  35221. * The chromatic aberration PostProcess id in the pipeline
  35222. */
  35223. LensChromaticAberrationEffect: string;
  35224. /**
  35225. * The highlights enhancing PostProcess id in the pipeline
  35226. */
  35227. HighlightsEnhancingEffect: string;
  35228. /**
  35229. * The depth-of-field PostProcess id in the pipeline
  35230. */
  35231. LensDepthOfFieldEffect: string;
  35232. private _scene;
  35233. private _depthTexture;
  35234. private _grainTexture;
  35235. private _chromaticAberrationPostProcess;
  35236. private _highlightsPostProcess;
  35237. private _depthOfFieldPostProcess;
  35238. private _edgeBlur;
  35239. private _grainAmount;
  35240. private _chromaticAberration;
  35241. private _distortion;
  35242. private _highlightsGain;
  35243. private _highlightsThreshold;
  35244. private _dofDistance;
  35245. private _dofAperture;
  35246. private _dofDarken;
  35247. private _dofPentagon;
  35248. private _blurNoise;
  35249. /**
  35250. * @constructor
  35251. *
  35252. * Effect parameters are as follow:
  35253. * {
  35254. * chromatic_aberration: number; // from 0 to x (1 for realism)
  35255. * edge_blur: number; // from 0 to x (1 for realism)
  35256. * distortion: number; // from 0 to x (1 for realism)
  35257. * grain_amount: number; // from 0 to 1
  35258. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  35259. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  35260. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  35261. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  35262. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  35263. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  35264. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  35265. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  35266. * }
  35267. * Note: if an effect parameter is unset, effect is disabled
  35268. *
  35269. * @param {string} name - The rendering pipeline name
  35270. * @param {object} parameters - An object containing all parameters (see above)
  35271. * @param {BABYLON.Scene} scene - The scene linked to this pipeline
  35272. * @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)
  35273. * @param {BABYLON.Camera[]} cameras - The array of cameras that the rendering pipeline will be attached to
  35274. */
  35275. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  35276. setEdgeBlur(amount: number): void;
  35277. disableEdgeBlur(): void;
  35278. setGrainAmount(amount: number): void;
  35279. disableGrain(): void;
  35280. setChromaticAberration(amount: number): void;
  35281. disableChromaticAberration(): void;
  35282. setEdgeDistortion(amount: number): void;
  35283. disableEdgeDistortion(): void;
  35284. setFocusDistance(amount: number): void;
  35285. disableDepthOfField(): void;
  35286. setAperture(amount: number): void;
  35287. setDarkenOutOfFocus(amount: number): void;
  35288. enablePentagonBokeh(): void;
  35289. disablePentagonBokeh(): void;
  35290. enableNoiseBlur(): void;
  35291. disableNoiseBlur(): void;
  35292. setHighlightsGain(amount: number): void;
  35293. setHighlightsThreshold(amount: number): void;
  35294. disableHighlights(): void;
  35295. /**
  35296. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  35297. */
  35298. dispose(disableDepthRender?: boolean): void;
  35299. private _createChromaticAberrationPostProcess(ratio);
  35300. private _createHighlightsPostProcess(ratio);
  35301. private _createDepthOfFieldPostProcess(ratio);
  35302. private _createGrainTexture();
  35303. }
  35304. }
  35305. declare module BABYLON {
  35306. class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  35307. /**
  35308. * The PassPostProcess id in the pipeline that contains the original scene color
  35309. */
  35310. SSAOOriginalSceneColorEffect: string;
  35311. /**
  35312. * The SSAO PostProcess id in the pipeline
  35313. */
  35314. SSAORenderEffect: string;
  35315. /**
  35316. * The horizontal blur PostProcess id in the pipeline
  35317. */
  35318. SSAOBlurHRenderEffect: string;
  35319. /**
  35320. * The vertical blur PostProcess id in the pipeline
  35321. */
  35322. SSAOBlurVRenderEffect: string;
  35323. /**
  35324. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  35325. */
  35326. SSAOCombineRenderEffect: string;
  35327. /**
  35328. * The output strength of the SSAO post-process. Default value is 1.0.
  35329. */
  35330. totalStrength: number;
  35331. /**
  35332. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  35333. */
  35334. maxZ: number;
  35335. /**
  35336. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  35337. */
  35338. minZAspect: number;
  35339. /**
  35340. * Number of samples used for the SSAO calculations. Default value is 8
  35341. */
  35342. private _samples;
  35343. /**
  35344. * Ratio object used for SSAO ratio and blur ratio
  35345. */
  35346. private _ratio;
  35347. /**
  35348. * Dynamically generated sphere sampler.
  35349. */
  35350. private _sampleSphere;
  35351. /**
  35352. * Blur filter offsets
  35353. */
  35354. private _samplerOffsets;
  35355. samples: number;
  35356. /**
  35357. * Are we using bilateral blur ?
  35358. */
  35359. private _expensiveBlur;
  35360. expensiveBlur: boolean;
  35361. /**
  35362. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  35363. */
  35364. radius: number;
  35365. /**
  35366. * The base color of the SSAO post-process
  35367. * The final result is "base + ssao" between [0, 1]
  35368. */
  35369. base: number;
  35370. /**
  35371. * Support test.
  35372. */
  35373. static readonly IsSupported: boolean;
  35374. private _scene;
  35375. private _depthTexture;
  35376. private _normalTexture;
  35377. private _randomTexture;
  35378. private _originalColorPostProcess;
  35379. private _ssaoPostProcess;
  35380. private _blurHPostProcess;
  35381. private _blurVPostProcess;
  35382. private _ssaoCombinePostProcess;
  35383. private _firstUpdate;
  35384. /**
  35385. * @constructor
  35386. * @param {string} name - The rendering pipeline name
  35387. * @param {BABYLON.Scene} scene - The scene linked to this pipeline
  35388. * @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 }
  35389. * @param {BABYLON.Camera[]} cameras - The array of cameras that the rendering pipeline will be attached to
  35390. */
  35391. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  35392. /**
  35393. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  35394. */
  35395. dispose(disableGeometryBufferRenderer?: boolean): void;
  35396. private _createBlurPostProcess(ssaoRatio, blurRatio);
  35397. _rebuild(): void;
  35398. private _generateHemisphere();
  35399. private _createSSAOPostProcess(ratio);
  35400. private _createSSAOCombinePostProcess(ratio);
  35401. private _createRandomTexture();
  35402. /**
  35403. * Serialize the rendering pipeline (Used when exporting)
  35404. * @returns the serialized object
  35405. */
  35406. serialize(): any;
  35407. /**
  35408. * Parse the serialized pipeline
  35409. * @param source Source pipeline.
  35410. * @param scene The scene to load the pipeline to.
  35411. * @param rootUrl The URL of the serialized pipeline.
  35412. * @returns An instantiated pipeline from the serialized object.
  35413. */
  35414. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  35415. }
  35416. }
  35417. declare module BABYLON {
  35418. class SSAORenderingPipeline extends PostProcessRenderPipeline {
  35419. /**
  35420. * The PassPostProcess id in the pipeline that contains the original scene color
  35421. */
  35422. SSAOOriginalSceneColorEffect: string;
  35423. /**
  35424. * The SSAO PostProcess id in the pipeline
  35425. */
  35426. SSAORenderEffect: string;
  35427. /**
  35428. * The horizontal blur PostProcess id in the pipeline
  35429. */
  35430. SSAOBlurHRenderEffect: string;
  35431. /**
  35432. * The vertical blur PostProcess id in the pipeline
  35433. */
  35434. SSAOBlurVRenderEffect: string;
  35435. /**
  35436. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  35437. */
  35438. SSAOCombineRenderEffect: string;
  35439. /**
  35440. * The output strength of the SSAO post-process. Default value is 1.0.
  35441. */
  35442. totalStrength: number;
  35443. /**
  35444. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  35445. */
  35446. radius: number;
  35447. /**
  35448. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  35449. * Must not be equal to fallOff and superior to fallOff.
  35450. * Default value is 0.975
  35451. */
  35452. area: number;
  35453. /**
  35454. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  35455. * Must not be equal to area and inferior to area.
  35456. * Default value is 0.0
  35457. */
  35458. fallOff: number;
  35459. /**
  35460. * The base color of the SSAO post-process
  35461. * The final result is "base + ssao" between [0, 1]
  35462. */
  35463. base: number;
  35464. private _scene;
  35465. private _depthTexture;
  35466. private _randomTexture;
  35467. private _originalColorPostProcess;
  35468. private _ssaoPostProcess;
  35469. private _blurHPostProcess;
  35470. private _blurVPostProcess;
  35471. private _ssaoCombinePostProcess;
  35472. private _firstUpdate;
  35473. /**
  35474. * @constructor
  35475. * @param {string} name - The rendering pipeline name
  35476. * @param {BABYLON.Scene} scene - The scene linked to this pipeline
  35477. * @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 }
  35478. * @param {BABYLON.Camera[]} cameras - The array of cameras that the rendering pipeline will be attached to
  35479. */
  35480. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  35481. /**
  35482. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  35483. */
  35484. dispose(disableDepthRender?: boolean): void;
  35485. private _createBlurPostProcess(ratio);
  35486. _rebuild(): void;
  35487. private _createSSAOPostProcess(ratio);
  35488. private _createSSAOCombinePostProcess(ratio);
  35489. private _createRandomTexture();
  35490. }
  35491. }
  35492. declare module BABYLON {
  35493. class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  35494. /**
  35495. * Public members
  35496. */
  35497. originalPostProcess: Nullable<PostProcess>;
  35498. downSampleX4PostProcess: Nullable<PostProcess>;
  35499. brightPassPostProcess: Nullable<PostProcess>;
  35500. blurHPostProcesses: PostProcess[];
  35501. blurVPostProcesses: PostProcess[];
  35502. textureAdderPostProcess: Nullable<PostProcess>;
  35503. volumetricLightPostProcess: Nullable<PostProcess>;
  35504. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  35505. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  35506. volumetricLightMergePostProces: Nullable<PostProcess>;
  35507. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  35508. luminancePostProcess: Nullable<PostProcess>;
  35509. luminanceDownSamplePostProcesses: PostProcess[];
  35510. hdrPostProcess: Nullable<PostProcess>;
  35511. textureAdderFinalPostProcess: Nullable<PostProcess>;
  35512. lensFlareFinalPostProcess: Nullable<PostProcess>;
  35513. hdrFinalPostProcess: Nullable<PostProcess>;
  35514. lensFlarePostProcess: Nullable<PostProcess>;
  35515. lensFlareComposePostProcess: Nullable<PostProcess>;
  35516. motionBlurPostProcess: Nullable<PostProcess>;
  35517. depthOfFieldPostProcess: Nullable<PostProcess>;
  35518. brightThreshold: number;
  35519. blurWidth: number;
  35520. horizontalBlur: boolean;
  35521. exposure: number;
  35522. lensTexture: Nullable<Texture>;
  35523. volumetricLightCoefficient: number;
  35524. volumetricLightPower: number;
  35525. volumetricLightBlurScale: number;
  35526. sourceLight: Nullable<SpotLight | DirectionalLight>;
  35527. hdrMinimumLuminance: number;
  35528. hdrDecreaseRate: number;
  35529. hdrIncreaseRate: number;
  35530. lensColorTexture: Nullable<Texture>;
  35531. lensFlareStrength: number;
  35532. lensFlareGhostDispersal: number;
  35533. lensFlareHaloWidth: number;
  35534. lensFlareDistortionStrength: number;
  35535. lensStarTexture: Nullable<Texture>;
  35536. lensFlareDirtTexture: Nullable<Texture>;
  35537. depthOfFieldDistance: number;
  35538. depthOfFieldBlurWidth: number;
  35539. motionStrength: number;
  35540. animations: Animation[];
  35541. /**
  35542. * Private members
  35543. */
  35544. private _scene;
  35545. private _currentDepthOfFieldSource;
  35546. private _basePostProcess;
  35547. private _hdrCurrentLuminance;
  35548. private _floatTextureType;
  35549. private _ratio;
  35550. private _bloomEnabled;
  35551. private _depthOfFieldEnabled;
  35552. private _vlsEnabled;
  35553. private _lensFlareEnabled;
  35554. private _hdrEnabled;
  35555. private _motionBlurEnabled;
  35556. private _motionBlurSamples;
  35557. private _volumetricLightStepsCount;
  35558. BloomEnabled: boolean;
  35559. DepthOfFieldEnabled: boolean;
  35560. LensFlareEnabled: boolean;
  35561. HDREnabled: boolean;
  35562. VLSEnabled: boolean;
  35563. MotionBlurEnabled: boolean;
  35564. volumetricLightStepsCount: number;
  35565. motionBlurSamples: number;
  35566. /**
  35567. * @constructor
  35568. * @param {string} name - The rendering pipeline name
  35569. * @param {BABYLON.Scene} scene - The scene linked to this pipeline
  35570. * @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)
  35571. * @param {BABYLON.PostProcess} originalPostProcess - the custom original color post-process. Must be "reusable". Can be null.
  35572. * @param {BABYLON.Camera[]} cameras - The array of cameras that the rendering pipeline will be attached to
  35573. */
  35574. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  35575. private _buildPipeline();
  35576. private _createDownSampleX4PostProcess(scene, ratio);
  35577. private _createBrightPassPostProcess(scene, ratio);
  35578. private _createBlurPostProcesses(scene, ratio, indice, blurWidthKey?);
  35579. private _createTextureAdderPostProcess(scene, ratio);
  35580. private _createVolumetricLightPostProcess(scene, ratio);
  35581. private _createLuminancePostProcesses(scene, textureType);
  35582. private _createHdrPostProcess(scene, ratio);
  35583. private _createLensFlarePostProcess(scene, ratio);
  35584. private _createDepthOfFieldPostProcess(scene, ratio);
  35585. private _createMotionBlurPostProcess(scene, ratio);
  35586. private _getDepthTexture();
  35587. private _disposePostProcesses();
  35588. /**
  35589. * Dispose of the pipeline and stop all post processes
  35590. */
  35591. dispose(): void;
  35592. /**
  35593. * Serialize the rendering pipeline (Used when exporting)
  35594. * @returns the serialized object
  35595. */
  35596. serialize(): any;
  35597. /**
  35598. * Parse the serialized pipeline
  35599. * @param source Source pipeline.
  35600. * @param scene The scene to load the pipeline to.
  35601. * @param rootUrl The URL of the serialized pipeline.
  35602. * @returns An instantiated pipeline from the serialized object.
  35603. */
  35604. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  35605. static LuminanceSteps: number;
  35606. }
  35607. }