babylon.d.ts 1.2 MB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292222932229422295222962229722298222992230022301223022230322304223052230622307223082230922310223112231222313223142231522316223172231822319223202232122322223232232422325223262232722328223292233022331223322233322334223352233622337223382233922340223412234222343223442234522346223472234822349223502235122352223532235422355223562235722358223592236022361223622236322364223652236622367223682236922370223712237222373223742237522376223772237822379223802238122382223832238422385223862238722388223892239022391223922239322394223952239622397223982239922400224012240222403224042240522406224072240822409224102241122412224132241422415224162241722418224192242022421224222242322424224252242622427224282242922430224312243222433224342243522436224372243822439224402244122442224432244422445224462244722448224492245022451224522245322454224552245622457224582245922460224612246222463224642246522466224672246822469224702247122472224732247422475224762247722478224792248022481224822248322484224852248622487224882248922490224912249222493224942249522496224972249822499225002250122502225032250422505225062250722508225092251022511225122251322514225152251622517225182251922520225212252222523225242252522526225272252822529225302253122532225332253422535225362253722538225392254022541225422254322544225452254622547225482254922550225512255222553225542255522556225572255822559225602256122562225632256422565225662256722568225692257022571225722257322574225752257622577225782257922580225812258222583225842258522586225872258822589225902259122592225932259422595225962259722598225992260022601226022260322604226052260622607226082260922610226112261222613226142261522616226172261822619226202262122622226232262422625226262262722628226292263022631226322263322634226352263622637226382263922640226412264222643226442264522646226472264822649226502265122652226532265422655226562265722658226592266022661226622266322664226652266622667226682266922670226712267222673226742267522676226772267822679226802268122682226832268422685226862268722688226892269022691226922269322694226952269622697226982269922700227012270222703227042270522706227072270822709227102271122712227132271422715227162271722718227192272022721227222272322724227252272622727227282272922730227312273222733227342273522736227372273822739227402274122742227432274422745227462274722748227492275022751227522275322754227552275622757227582275922760227612276222763227642276522766227672276822769227702277122772227732277422775227762277722778227792278022781227822278322784227852278622787227882278922790227912279222793227942279522796227972279822799228002280122802228032280422805228062280722808228092281022811228122281322814228152281622817228182281922820228212282222823228242282522826228272282822829228302283122832228332283422835228362283722838228392284022841228422284322844228452284622847228482284922850228512285222853228542285522856228572285822859228602286122862228632286422865228662286722868228692287022871228722287322874228752287622877228782287922880228812288222883228842288522886228872288822889228902289122892228932289422895228962289722898228992290022901229022290322904229052290622907229082290922910229112291222913229142291522916229172291822919229202292122922229232292422925229262292722928229292293022931229322293322934229352293622937229382293922940229412294222943229442294522946229472294822949229502295122952229532295422955229562295722958229592296022961229622296322964229652296622967229682296922970229712297222973229742297522976229772297822979229802298122982229832298422985229862298722988229892299022991229922299322994229952299622997229982299923000230012300223003230042300523006230072300823009230102301123012230132301423015230162301723018230192302023021230222302323024230252302623027230282302923030230312303223033230342303523036230372303823039230402304123042230432304423045230462304723048230492305023051230522305323054230552305623057230582305923060230612306223063230642306523066230672306823069230702307123072230732307423075230762307723078230792308023081230822308323084230852308623087230882308923090230912309223093230942309523096230972309823099231002310123102231032310423105231062310723108231092311023111231122311323114231152311623117231182311923120231212312223123231242312523126231272312823129231302313123132231332313423135231362313723138231392314023141231422314323144231452314623147231482314923150231512315223153231542315523156231572315823159231602316123162231632316423165231662316723168231692317023171231722317323174231752317623177231782317923180231812318223183231842318523186231872318823189231902319123192231932319423195231962319723198231992320023201232022320323204232052320623207232082320923210232112321223213232142321523216232172321823219232202322123222232232322423225232262322723228232292323023231232322323323234232352323623237232382323923240232412324223243232442324523246232472324823249232502325123252232532325423255232562325723258232592326023261232622326323264232652326623267232682326923270232712327223273232742327523276232772327823279232802328123282232832328423285232862328723288232892329023291232922329323294232952329623297232982329923300233012330223303233042330523306233072330823309233102331123312233132331423315233162331723318233192332023321233222332323324233252332623327233282332923330233312333223333233342333523336233372333823339233402334123342233432334423345233462334723348233492335023351233522335323354233552335623357233582335923360233612336223363233642336523366233672336823369233702337123372233732337423375233762337723378233792338023381233822338323384233852338623387233882338923390233912339223393233942339523396233972339823399234002340123402234032340423405234062340723408234092341023411234122341323414234152341623417234182341923420234212342223423234242342523426234272342823429234302343123432234332343423435234362343723438234392344023441234422344323444234452344623447234482344923450234512345223453234542345523456234572345823459234602346123462234632346423465234662346723468234692347023471234722347323474234752347623477234782347923480234812348223483234842348523486234872348823489234902349123492234932349423495234962349723498234992350023501235022350323504235052350623507235082350923510235112351223513235142351523516235172351823519235202352123522235232352423525235262352723528235292353023531235322353323534235352353623537235382353923540235412354223543235442354523546235472354823549235502355123552235532355423555235562355723558235592356023561235622356323564235652356623567235682356923570235712357223573235742357523576235772357823579235802358123582235832358423585235862358723588235892359023591235922359323594235952359623597235982359923600236012360223603236042360523606236072360823609236102361123612236132361423615236162361723618236192362023621236222362323624236252362623627236282362923630236312363223633236342363523636236372363823639236402364123642236432364423645236462364723648236492365023651236522365323654236552365623657236582365923660236612366223663236642366523666236672366823669236702367123672236732367423675236762367723678236792368023681236822368323684236852368623687236882368923690236912369223693236942369523696236972369823699237002370123702237032370423705237062370723708237092371023711237122371323714237152371623717237182371923720237212372223723237242372523726237272372823729237302373123732237332373423735237362373723738237392374023741237422374323744237452374623747237482374923750237512375223753237542375523756237572375823759237602376123762237632376423765237662376723768237692377023771237722377323774237752377623777237782377923780237812378223783237842378523786237872378823789237902379123792237932379423795237962379723798237992380023801238022380323804238052380623807238082380923810238112381223813238142381523816238172381823819238202382123822238232382423825238262382723828238292383023831238322383323834238352383623837238382383923840238412384223843238442384523846238472384823849238502385123852238532385423855238562385723858238592386023861238622386323864238652386623867238682386923870238712387223873238742387523876238772387823879238802388123882238832388423885238862388723888238892389023891238922389323894238952389623897238982389923900239012390223903239042390523906239072390823909239102391123912239132391423915239162391723918239192392023921239222392323924239252392623927239282392923930239312393223933239342393523936239372393823939239402394123942239432394423945239462394723948239492395023951239522395323954239552395623957239582395923960239612396223963239642396523966239672396823969239702397123972239732397423975239762397723978239792398023981239822398323984239852398623987239882398923990239912399223993239942399523996239972399823999240002400124002240032400424005240062400724008240092401024011240122401324014240152401624017240182401924020240212402224023240242402524026240272402824029240302403124032240332403424035240362403724038240392404024041240422404324044240452404624047240482404924050240512405224053240542405524056240572405824059240602406124062240632406424065240662406724068240692407024071240722407324074240752407624077240782407924080240812408224083240842408524086240872408824089240902409124092240932409424095240962409724098240992410024101241022410324104241052410624107241082410924110241112411224113241142411524116241172411824119241202412124122241232412424125241262412724128241292413024131241322413324134241352413624137241382413924140241412414224143241442414524146241472414824149241502415124152241532415424155241562415724158241592416024161241622416324164241652416624167241682416924170241712417224173241742417524176241772417824179241802418124182241832418424185241862418724188241892419024191241922419324194241952419624197241982419924200242012420224203242042420524206242072420824209242102421124212242132421424215242162421724218242192422024221242222422324224242252422624227242282422924230242312423224233242342423524236242372423824239242402424124242242432424424245242462424724248242492425024251242522425324254242552425624257242582425924260242612426224263242642426524266242672426824269242702427124272242732427424275242762427724278242792428024281242822428324284242852428624287242882428924290242912429224293242942429524296242972429824299243002430124302243032430424305243062430724308243092431024311243122431324314243152431624317243182431924320243212432224323243242432524326243272432824329243302433124332243332433424335243362433724338243392434024341243422434324344243452434624347243482434924350243512435224353243542435524356243572435824359243602436124362243632436424365243662436724368243692437024371243722437324374243752437624377243782437924380243812438224383243842438524386243872438824389243902439124392243932439424395243962439724398243992440024401244022440324404244052440624407244082440924410244112441224413244142441524416244172441824419244202442124422244232442424425244262442724428244292443024431244322443324434244352443624437244382443924440244412444224443244442444524446244472444824449244502445124452244532445424455244562445724458244592446024461244622446324464244652446624467244682446924470244712447224473244742447524476244772447824479244802448124482244832448424485244862448724488244892449024491244922449324494244952449624497244982449924500245012450224503245042450524506245072450824509245102451124512245132451424515245162451724518245192452024521245222452324524245252452624527245282452924530245312453224533245342453524536245372453824539245402454124542245432454424545245462454724548245492455024551245522455324554245552455624557245582455924560245612456224563245642456524566245672456824569245702457124572245732457424575245762457724578245792458024581245822458324584245852458624587245882458924590245912459224593245942459524596245972459824599246002460124602246032460424605246062460724608246092461024611246122461324614246152461624617246182461924620246212462224623246242462524626246272462824629246302463124632246332463424635246362463724638246392464024641246422464324644246452464624647246482464924650246512465224653246542465524656246572465824659246602466124662246632466424665246662466724668246692467024671246722467324674246752467624677246782467924680246812468224683246842468524686246872468824689246902469124692246932469424695246962469724698246992470024701247022470324704247052470624707247082470924710247112471224713247142471524716247172471824719247202472124722247232472424725247262472724728247292473024731247322473324734247352473624737247382473924740247412474224743247442474524746247472474824749247502475124752247532475424755247562475724758247592476024761247622476324764247652476624767247682476924770247712477224773247742477524776247772477824779247802478124782247832478424785247862478724788247892479024791247922479324794247952479624797247982479924800248012480224803248042480524806248072480824809248102481124812248132481424815248162481724818248192482024821248222482324824248252482624827248282482924830248312483224833248342483524836248372483824839248402484124842248432484424845248462484724848248492485024851248522485324854248552485624857248582485924860248612486224863248642486524866248672486824869248702487124872248732487424875248762487724878248792488024881248822488324884248852488624887248882488924890248912489224893248942489524896248972489824899249002490124902249032490424905249062490724908249092491024911249122491324914249152491624917249182491924920249212492224923249242492524926249272492824929249302493124932249332493424935249362493724938249392494024941249422494324944249452494624947249482494924950249512495224953249542495524956249572495824959249602496124962249632496424965249662496724968249692497024971249722497324974249752497624977249782497924980249812498224983249842498524986249872498824989249902499124992249932499424995249962499724998249992500025001250022500325004250052500625007250082500925010250112501225013250142501525016250172501825019250202502125022250232502425025250262502725028250292503025031250322503325034250352503625037250382503925040250412504225043250442504525046250472504825049250502505125052250532505425055250562505725058250592506025061250622506325064250652506625067250682506925070250712507225073250742507525076250772507825079250802508125082250832508425085250862508725088250892509025091250922509325094250952509625097250982509925100251012510225103251042510525106251072510825109251102511125112251132511425115251162511725118251192512025121251222512325124251252512625127251282512925130251312513225133251342513525136251372513825139251402514125142251432514425145251462514725148251492515025151251522515325154251552515625157251582515925160251612516225163251642516525166251672516825169251702517125172251732517425175251762517725178251792518025181251822518325184251852518625187251882518925190251912519225193251942519525196251972519825199252002520125202252032520425205252062520725208252092521025211252122521325214252152521625217252182521925220252212522225223252242522525226252272522825229252302523125232252332523425235252362523725238252392524025241252422524325244252452524625247252482524925250252512525225253252542525525256252572525825259252602526125262252632526425265252662526725268252692527025271252722527325274252752527625277252782527925280252812528225283252842528525286252872528825289252902529125292252932529425295252962529725298252992530025301253022530325304253052530625307253082530925310253112531225313253142531525316253172531825319253202532125322253232532425325253262532725328253292533025331253322533325334253352533625337253382533925340253412534225343253442534525346253472534825349253502535125352253532535425355253562535725358253592536025361253622536325364253652536625367253682536925370253712537225373253742537525376253772537825379253802538125382253832538425385253862538725388253892539025391253922539325394253952539625397253982539925400254012540225403254042540525406254072540825409254102541125412254132541425415254162541725418254192542025421254222542325424254252542625427254282542925430254312543225433254342543525436254372543825439254402544125442254432544425445254462544725448254492545025451254522545325454254552545625457254582545925460254612546225463254642546525466254672546825469254702547125472254732547425475254762547725478254792548025481254822548325484254852548625487254882548925490254912549225493254942549525496254972549825499255002550125502255032550425505255062550725508255092551025511255122551325514255152551625517255182551925520255212552225523255242552525526255272552825529255302553125532255332553425535255362553725538255392554025541255422554325544255452554625547255482554925550255512555225553255542555525556255572555825559255602556125562255632556425565255662556725568255692557025571255722557325574255752557625577255782557925580255812558225583255842558525586255872558825589255902559125592255932559425595255962559725598255992560025601256022560325604256052560625607256082560925610256112561225613256142561525616256172561825619256202562125622256232562425625256262562725628256292563025631256322563325634256352563625637256382563925640256412564225643256442564525646256472564825649256502565125652256532565425655256562565725658256592566025661256622566325664256652566625667256682566925670256712567225673256742567525676256772567825679256802568125682256832568425685256862568725688256892569025691256922569325694256952569625697256982569925700257012570225703257042570525706257072570825709257102571125712257132571425715257162571725718257192572025721257222572325724257252572625727257282572925730257312573225733257342573525736257372573825739257402574125742257432574425745257462574725748257492575025751257522575325754257552575625757257582575925760257612576225763257642576525766257672576825769257702577125772257732577425775257762577725778257792578025781257822578325784257852578625787257882578925790257912579225793257942579525796257972579825799258002580125802258032580425805258062580725808258092581025811258122581325814258152581625817258182581925820258212582225823258242582525826258272582825829258302583125832258332583425835258362583725838258392584025841258422584325844258452584625847258482584925850258512585225853258542585525856258572585825859258602586125862258632586425865258662586725868258692587025871258722587325874258752587625877258782587925880258812588225883258842588525886258872588825889258902589125892258932589425895258962589725898258992590025901259022590325904259052590625907259082590925910259112591225913259142591525916259172591825919259202592125922259232592425925259262592725928259292593025931259322593325934259352593625937259382593925940259412594225943259442594525946259472594825949259502595125952259532595425955259562595725958259592596025961259622596325964259652596625967259682596925970259712597225973259742597525976259772597825979259802598125982259832598425985259862598725988259892599025991259922599325994259952599625997259982599926000260012600226003260042600526006260072600826009260102601126012260132601426015260162601726018260192602026021260222602326024260252602626027260282602926030260312603226033260342603526036260372603826039260402604126042260432604426045260462604726048260492605026051260522605326054260552605626057260582605926060260612606226063260642606526066260672606826069260702607126072260732607426075260762607726078260792608026081260822608326084260852608626087260882608926090260912609226093260942609526096260972609826099261002610126102261032610426105261062610726108261092611026111261122611326114261152611626117261182611926120261212612226123261242612526126261272612826129261302613126132261332613426135261362613726138261392614026141261422614326144261452614626147261482614926150261512615226153261542615526156261572615826159261602616126162261632616426165261662616726168261692617026171261722617326174261752617626177261782617926180261812618226183261842618526186261872618826189261902619126192261932619426195261962619726198261992620026201262022620326204262052620626207262082620926210262112621226213262142621526216262172621826219262202622126222262232622426225262262622726228262292623026231262322623326234262352623626237262382623926240262412624226243262442624526246262472624826249262502625126252262532625426255262562625726258262592626026261262622626326264262652626626267262682626926270262712627226273262742627526276262772627826279262802628126282262832628426285262862628726288262892629026291262922629326294262952629626297262982629926300263012630226303263042630526306263072630826309263102631126312263132631426315263162631726318263192632026321263222632326324263252632626327263282632926330263312633226333263342633526336263372633826339263402634126342263432634426345263462634726348263492635026351263522635326354263552635626357263582635926360263612636226363263642636526366263672636826369263702637126372263732637426375263762637726378263792638026381263822638326384263852638626387263882638926390263912639226393263942639526396263972639826399264002640126402264032640426405264062640726408264092641026411264122641326414264152641626417264182641926420264212642226423264242642526426264272642826429264302643126432264332643426435264362643726438264392644026441264422644326444264452644626447264482644926450264512645226453264542645526456264572645826459264602646126462264632646426465264662646726468264692647026471264722647326474264752647626477264782647926480264812648226483264842648526486264872648826489264902649126492264932649426495264962649726498264992650026501265022650326504265052650626507265082650926510265112651226513265142651526516265172651826519265202652126522265232652426525265262652726528265292653026531265322653326534265352653626537265382653926540265412654226543265442654526546265472654826549265502655126552265532655426555265562655726558265592656026561265622656326564265652656626567265682656926570265712657226573265742657526576265772657826579265802658126582265832658426585265862658726588265892659026591265922659326594265952659626597265982659926600266012660226603266042660526606266072660826609266102661126612266132661426615266162661726618266192662026621266222662326624266252662626627266282662926630266312663226633266342663526636266372663826639266402664126642266432664426645266462664726648266492665026651266522665326654266552665626657266582665926660266612666226663266642666526666266672666826669266702667126672266732667426675266762667726678266792668026681266822668326684266852668626687266882668926690266912669226693266942669526696266972669826699267002670126702267032670426705267062670726708267092671026711267122671326714267152671626717267182671926720267212672226723267242672526726267272672826729267302673126732267332673426735267362673726738267392674026741267422674326744267452674626747267482674926750267512675226753267542675526756267572675826759267602676126762267632676426765267662676726768267692677026771267722677326774267752677626777267782677926780267812678226783267842678526786267872678826789267902679126792267932679426795267962679726798267992680026801268022680326804268052680626807268082680926810268112681226813268142681526816268172681826819268202682126822268232682426825268262682726828268292683026831268322683326834268352683626837268382683926840268412684226843268442684526846268472684826849268502685126852268532685426855268562685726858268592686026861268622686326864268652686626867268682686926870268712687226873268742687526876268772687826879268802688126882268832688426885268862688726888268892689026891268922689326894268952689626897268982689926900269012690226903269042690526906269072690826909269102691126912269132691426915269162691726918269192692026921269222692326924269252692626927269282692926930269312693226933269342693526936269372693826939269402694126942269432694426945269462694726948269492695026951269522695326954269552695626957269582695926960269612696226963269642696526966269672696826969269702697126972269732697426975269762697726978269792698026981269822698326984269852698626987269882698926990269912699226993269942699526996269972699826999270002700127002270032700427005270062700727008270092701027011270122701327014270152701627017270182701927020270212702227023270242702527026270272702827029270302703127032270332703427035270362703727038270392704027041270422704327044270452704627047270482704927050270512705227053270542705527056270572705827059270602706127062270632706427065270662706727068270692707027071270722707327074270752707627077270782707927080270812708227083270842708527086270872708827089270902709127092270932709427095270962709727098270992710027101271022710327104271052710627107271082710927110271112711227113271142711527116271172711827119271202712127122271232712427125271262712727128271292713027131271322713327134271352713627137271382713927140271412714227143271442714527146271472714827149271502715127152271532715427155271562715727158271592716027161271622716327164271652716627167271682716927170271712717227173271742717527176271772717827179271802718127182271832718427185271862718727188271892719027191271922719327194271952719627197271982719927200272012720227203272042720527206272072720827209272102721127212272132721427215272162721727218272192722027221272222722327224272252722627227272282722927230272312723227233272342723527236272372723827239272402724127242272432724427245272462724727248272492725027251272522725327254272552725627257272582725927260272612726227263272642726527266272672726827269272702727127272272732727427275272762727727278272792728027281272822728327284272852728627287272882728927290272912729227293272942729527296272972729827299273002730127302273032730427305273062730727308273092731027311273122731327314273152731627317273182731927320273212732227323273242732527326273272732827329273302733127332273332733427335273362733727338273392734027341273422734327344273452734627347273482734927350273512735227353273542735527356273572735827359273602736127362273632736427365273662736727368273692737027371273722737327374273752737627377273782737927380273812738227383273842738527386273872738827389273902739127392273932739427395273962739727398273992740027401274022740327404274052740627407274082740927410274112741227413274142741527416274172741827419274202742127422274232742427425274262742727428274292743027431274322743327434274352743627437274382743927440274412744227443274442744527446274472744827449274502745127452274532745427455274562745727458274592746027461274622746327464274652746627467274682746927470274712747227473274742747527476274772747827479274802748127482274832748427485274862748727488274892749027491274922749327494274952749627497274982749927500275012750227503275042750527506275072750827509275102751127512275132751427515275162751727518275192752027521275222752327524275252752627527275282752927530275312753227533275342753527536275372753827539275402754127542275432754427545275462754727548275492755027551275522755327554275552755627557275582755927560275612756227563275642756527566275672756827569275702757127572275732757427575275762757727578275792758027581275822758327584275852758627587275882758927590275912759227593275942759527596275972759827599276002760127602276032760427605276062760727608276092761027611276122761327614276152761627617276182761927620276212762227623276242762527626276272762827629276302763127632276332763427635276362763727638276392764027641276422764327644276452764627647276482764927650276512765227653276542765527656276572765827659276602766127662276632766427665276662766727668276692767027671276722767327674276752767627677276782767927680276812768227683276842768527686276872768827689276902769127692276932769427695276962769727698276992770027701277022770327704277052770627707277082770927710277112771227713277142771527716277172771827719277202772127722277232772427725277262772727728277292773027731277322773327734277352773627737277382773927740277412774227743277442774527746277472774827749277502775127752277532775427755277562775727758277592776027761277622776327764277652776627767277682776927770277712777227773277742777527776277772777827779277802778127782277832778427785277862778727788277892779027791277922779327794277952779627797277982779927800278012780227803278042780527806278072780827809278102781127812278132781427815278162781727818278192782027821278222782327824278252782627827278282782927830278312783227833278342783527836278372783827839278402784127842278432784427845278462784727848278492785027851278522785327854278552785627857278582785927860278612786227863278642786527866278672786827869278702787127872278732787427875278762787727878278792788027881278822788327884278852788627887278882788927890278912789227893278942789527896278972789827899279002790127902279032790427905279062790727908279092791027911279122791327914279152791627917279182791927920279212792227923279242792527926279272792827929279302793127932279332793427935279362793727938279392794027941279422794327944279452794627947279482794927950279512795227953279542795527956279572795827959279602796127962279632796427965279662796727968279692797027971279722797327974279752797627977279782797927980279812798227983279842798527986279872798827989279902799127992279932799427995279962799727998279992800028001280022800328004280052800628007280082800928010280112801228013280142801528016280172801828019280202802128022280232802428025280262802728028280292803028031280322803328034280352803628037280382803928040280412804228043280442804528046280472804828049280502805128052280532805428055280562805728058280592806028061280622806328064280652806628067280682806928070280712807228073280742807528076280772807828079280802808128082280832808428085280862808728088280892809028091280922809328094280952809628097280982809928100281012810228103281042810528106281072810828109281102811128112281132811428115281162811728118281192812028121281222812328124281252812628127281282812928130281312813228133281342813528136281372813828139281402814128142281432814428145281462814728148281492815028151281522815328154281552815628157281582815928160281612816228163281642816528166281672816828169281702817128172281732817428175281762817728178281792818028181281822818328184281852818628187281882818928190281912819228193281942819528196281972819828199282002820128202282032820428205282062820728208282092821028211282122821328214282152821628217282182821928220282212822228223282242822528226282272822828229282302823128232282332823428235282362823728238282392824028241282422824328244282452824628247282482824928250282512825228253282542825528256282572825828259282602826128262282632826428265282662826728268282692827028271282722827328274282752827628277282782827928280282812828228283282842828528286282872828828289282902829128292282932829428295282962829728298282992830028301283022830328304283052830628307283082830928310283112831228313283142831528316283172831828319283202832128322283232832428325283262832728328283292833028331283322833328334283352833628337283382833928340283412834228343283442834528346283472834828349283502835128352283532835428355283562835728358283592836028361283622836328364283652836628367283682836928370283712837228373283742837528376283772837828379283802838128382283832838428385283862838728388283892839028391283922839328394283952839628397283982839928400284012840228403284042840528406284072840828409284102841128412284132841428415284162841728418284192842028421284222842328424284252842628427284282842928430284312843228433284342843528436284372843828439284402844128442284432844428445284462844728448284492845028451284522845328454284552845628457284582845928460284612846228463284642846528466284672846828469284702847128472284732847428475284762847728478284792848028481284822848328484284852848628487284882848928490284912849228493284942849528496284972849828499285002850128502285032850428505285062850728508285092851028511285122851328514285152851628517285182851928520285212852228523285242852528526285272852828529285302853128532285332853428535285362853728538285392854028541285422854328544285452854628547285482854928550285512855228553285542855528556285572855828559285602856128562285632856428565285662856728568285692857028571285722857328574285752857628577285782857928580285812858228583285842858528586285872858828589285902859128592285932859428595285962859728598285992860028601286022860328604286052860628607286082860928610286112861228613286142861528616286172861828619286202862128622286232862428625286262862728628286292863028631286322863328634286352863628637286382863928640286412864228643286442864528646286472864828649286502865128652286532865428655286562865728658286592866028661286622866328664286652866628667286682866928670286712867228673286742867528676286772867828679286802868128682286832868428685286862868728688286892869028691286922869328694286952869628697286982869928700287012870228703287042870528706287072870828709287102871128712287132871428715287162871728718287192872028721287222872328724287252872628727287282872928730287312873228733287342873528736287372873828739287402874128742287432874428745287462874728748287492875028751
  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: ParticleSystem[];
  29. /**
  30. * Animations to keep.
  31. */
  32. animations: Animation[];
  33. /**
  34. * MultiMaterials to keep.
  35. */
  36. multiMaterials: MultiMaterial[];
  37. /**
  38. * Materials to keep.
  39. */
  40. materials: Material[];
  41. /**
  42. * MorphTargetManagers to keep.
  43. */
  44. morphTargetManagers: MorphTargetManager[];
  45. /**
  46. * Geometries to keep.
  47. */
  48. geometries: Geometry[];
  49. /**
  50. * TransformNodes to keep.
  51. */
  52. transformNodes: TransformNode[];
  53. /**
  54. * LensFlareSystems to keep.
  55. */
  56. lensFlareSystems: LensFlareSystem[];
  57. /**
  58. * ShadowGenerators to keep.
  59. */
  60. shadowGenerators: ShadowGenerator[];
  61. /**
  62. * ActionManagers to keep.
  63. */
  64. actionManagers: ActionManager[];
  65. /**
  66. * Sounds to keep.
  67. */
  68. sounds: Sound[];
  69. }
  70. /**
  71. * Container with a set of assets that can be added or removed from a scene.
  72. */
  73. class AssetContainer {
  74. /**
  75. * The scene the AssetContainer belongs to.
  76. */
  77. scene: Scene;
  78. /**
  79. * Cameras populated in the container.
  80. */
  81. cameras: Camera[];
  82. /**
  83. * Lights populated in the container.
  84. */
  85. lights: Light[];
  86. /**
  87. * Meshes populated in the container.
  88. */
  89. meshes: AbstractMesh[];
  90. /**
  91. * Skeletons populated in the container.
  92. */
  93. skeletons: Skeleton[];
  94. /**
  95. * ParticleSystems populated in the container.
  96. */
  97. particleSystems: IParticleSystem[];
  98. /**
  99. * Animations populated in the container.
  100. */
  101. animations: Animation[];
  102. /**
  103. * MultiMaterials populated in the container.
  104. */
  105. multiMaterials: MultiMaterial[];
  106. /**
  107. * Materials populated in the container.
  108. */
  109. materials: Material[];
  110. /**
  111. * MorphTargetManagers populated in the container.
  112. */
  113. morphTargetManagers: MorphTargetManager[];
  114. /**
  115. * Geometries populated in the container.
  116. */
  117. geometries: Geometry[];
  118. /**
  119. * TransformNodes populated in the container.
  120. */
  121. transformNodes: TransformNode[];
  122. /**
  123. * LensFlareSystems populated in the container.
  124. */
  125. lensFlareSystems: LensFlareSystem[];
  126. /**
  127. * ShadowGenerators populated in the container.
  128. */
  129. shadowGenerators: ShadowGenerator[];
  130. /**
  131. * ActionManagers populated in the container.
  132. */
  133. actionManagers: ActionManager[];
  134. /**
  135. * Sounds populated in the container.
  136. */
  137. sounds: Sound[];
  138. /**
  139. * Instantiates an AssetContainer.
  140. * @param scene The scene the AssetContainer belongs to.
  141. */
  142. constructor(scene: Scene);
  143. /**
  144. * Adds all the assets from the container to the scene.
  145. */
  146. addAllToScene(): void;
  147. /**
  148. * Removes all the assets in the container from the scene
  149. */
  150. removeAllFromScene(): void;
  151. private _moveAssets<T>(sourceAssets, targetAssets, keepAssets);
  152. /**
  153. * Removes all the assets contained in the scene and adds them to the container.
  154. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  155. */
  156. moveAllFromScene(keepAssets?: KeepAssets): void;
  157. }
  158. }
  159. interface Window {
  160. mozIndexedDB: IDBFactory;
  161. webkitIndexedDB: IDBFactory;
  162. msIndexedDB: IDBFactory;
  163. webkitURL: typeof URL;
  164. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  165. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  166. WebGLRenderingContext: WebGLRenderingContext;
  167. MSGesture: MSGesture;
  168. CANNON: any;
  169. AudioContext: AudioContext;
  170. webkitAudioContext: AudioContext;
  171. PointerEvent: any;
  172. Math: Math;
  173. Uint8Array: Uint8ArrayConstructor;
  174. Float32Array: Float32ArrayConstructor;
  175. mozURL: typeof URL;
  176. msURL: typeof URL;
  177. VRFrameData: any;
  178. DracoDecoderModule: any;
  179. }
  180. interface WebGLRenderingContext {
  181. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  182. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  183. vertexAttribDivisor(index: number, divisor: number): void;
  184. createVertexArray(): any;
  185. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  186. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  187. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  188. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  189. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  190. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  191. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  192. createQuery(): WebGLQuery;
  193. deleteQuery(query: WebGLQuery): void;
  194. beginQuery(target: number, query: WebGLQuery): void;
  195. endQuery(target: number): void;
  196. getQueryParameter(query: WebGLQuery, pname: number): any;
  197. getQuery(target: number, pname: number): any;
  198. MAX_SAMPLES: number;
  199. RGBA8: number;
  200. READ_FRAMEBUFFER: number;
  201. DRAW_FRAMEBUFFER: number;
  202. UNIFORM_BUFFER: number;
  203. HALF_FLOAT_OES: number;
  204. RGBA16F: number;
  205. RGBA32F: number;
  206. R32F: number;
  207. RG32F: number;
  208. RGB32F: number;
  209. RED: number;
  210. RG: number;
  211. UNSIGNED_INT_24_8: number;
  212. DEPTH24_STENCIL8: number;
  213. drawBuffers(buffers: number[]): void;
  214. readBuffer(src: number): void;
  215. readonly COLOR_ATTACHMENT0: number;
  216. readonly COLOR_ATTACHMENT1: number;
  217. readonly COLOR_ATTACHMENT2: number;
  218. readonly COLOR_ATTACHMENT3: number;
  219. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  220. ANY_SAMPLES_PASSED: number;
  221. QUERY_RESULT_AVAILABLE: number;
  222. QUERY_RESULT: number;
  223. }
  224. interface Document {
  225. mozCancelFullScreen(): void;
  226. msCancelFullScreen(): void;
  227. mozFullScreen: boolean;
  228. msIsFullScreen: boolean;
  229. fullscreen: boolean;
  230. mozPointerLockElement: HTMLElement;
  231. msPointerLockElement: HTMLElement;
  232. webkitPointerLockElement: HTMLElement;
  233. }
  234. interface HTMLCanvasElement {
  235. msRequestPointerLock?(): void;
  236. mozRequestPointerLock?(): void;
  237. webkitRequestPointerLock?(): void;
  238. }
  239. interface CanvasRenderingContext2D {
  240. msImageSmoothingEnabled: boolean;
  241. }
  242. interface WebGLBuffer {
  243. references: number;
  244. capacity: number;
  245. is32Bits: boolean;
  246. }
  247. interface WebGLProgram {
  248. transformFeedback?: WebGLTransformFeedback | null;
  249. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  250. }
  251. interface MouseEvent {
  252. mozMovementX: number;
  253. mozMovementY: number;
  254. webkitMovementX: number;
  255. webkitMovementY: number;
  256. msMovementX: number;
  257. msMovementY: number;
  258. }
  259. interface Navigator {
  260. getVRDisplays: () => any;
  261. mozGetVRDevices: (any: any) => any;
  262. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  263. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  264. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  265. webkitGetGamepads(): Gamepad[];
  266. msGetGamepads(): Gamepad[];
  267. webkitGamepads(): Gamepad[];
  268. }
  269. interface HTMLVideoElement {
  270. mozSrcObject: any;
  271. }
  272. interface Screen {
  273. orientation: string;
  274. mozOrientation: string;
  275. }
  276. interface Math {
  277. fround(x: number): number;
  278. imul(a: number, b: number): number;
  279. }
  280. interface GamepadPose {
  281. hasOrientation: boolean;
  282. hasPosition: boolean;
  283. position?: Float32Array;
  284. linearVelocity?: Float32Array;
  285. linearAcceleration?: Float32Array;
  286. orientation?: Float32Array;
  287. angularVelocity?: Float32Array;
  288. angularAcceleration?: Float32Array;
  289. }
  290. interface EXT_disjoint_timer_query {
  291. QUERY_COUNTER_BITS_EXT: number;
  292. TIME_ELAPSED_EXT: number;
  293. TIMESTAMP_EXT: number;
  294. GPU_DISJOINT_EXT: number;
  295. QUERY_RESULT_EXT: number;
  296. QUERY_RESULT_AVAILABLE_EXT: number;
  297. queryCounterEXT(query: WebGLQuery, target: number): void;
  298. createQueryEXT(): WebGLQuery;
  299. beginQueryEXT(target: number, query: WebGLQuery): void;
  300. endQueryEXT(target: number): void;
  301. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  302. deleteQueryEXT(query: WebGLQuery): void;
  303. }
  304. interface WebGLUniformLocation {
  305. _currentState: any;
  306. }
  307. declare module BABYLON {
  308. /**
  309. * Node is the basic class for all scene objects (Mesh, Light Camera).
  310. */
  311. class Node {
  312. /**
  313. * Gets or sets the name of the node
  314. */
  315. name: string;
  316. /**
  317. * Gets or sets the id of the node
  318. */
  319. id: string;
  320. /**
  321. * Gets or sets the unique id of the node
  322. */
  323. uniqueId: number;
  324. /**
  325. * Gets or sets a string used to store user defined state for the node
  326. */
  327. state: string;
  328. /**
  329. * Gets or sets an object used to store user defined information for the node
  330. */
  331. metadata: any;
  332. /**
  333. * Gets or sets a boolean used to define if the node must be serialized
  334. */
  335. doNotSerialize: boolean;
  336. /** @ignore */
  337. _isDisposed: boolean;
  338. /**
  339. * Gets a list of {BABYLON.Animation} associated with the node
  340. */
  341. animations: Animation[];
  342. private _ranges;
  343. /**
  344. * Callback raised when the node is ready to be used
  345. */
  346. onReady: (node: Node) => void;
  347. private _isEnabled;
  348. private _isReady;
  349. /** @ignore */
  350. _currentRenderId: number;
  351. private _parentRenderId;
  352. /** @ignore */
  353. _waitingParentId: Nullable<string>;
  354. private _scene;
  355. /** @ignore */
  356. _cache: any;
  357. private _parentNode;
  358. private _children;
  359. /**
  360. * Gets a boolean indicating if the node has been disposed
  361. * @returns true if the node was disposed
  362. */
  363. isDisposed(): boolean;
  364. /**
  365. * Gets or sets the parent of the node
  366. */
  367. parent: Nullable<Node>;
  368. /**
  369. * Gets a string idenfifying the name of the class
  370. * @returns "Node" string
  371. */
  372. getClassName(): string;
  373. /**
  374. * An event triggered when the mesh is disposed
  375. * @type {BABYLON.Observable}
  376. */
  377. onDisposeObservable: Observable<Node>;
  378. private _onDisposeObserver;
  379. /**
  380. * Sets a callback that will be raised when the node will be disposed
  381. */
  382. onDispose: () => void;
  383. /**
  384. * Creates a new Node
  385. * @param {string} name - the name and id to be given to this node
  386. * @param {BABYLON.Scene} the scene this node will be added to
  387. */
  388. constructor(name: string, scene?: Nullable<Scene>);
  389. /**
  390. * Gets the scene of the node
  391. * @returns a {BABYLON.Scene}
  392. */
  393. getScene(): Scene;
  394. /**
  395. * Gets the engine of the node
  396. * @returns a {BABYLON.Engine}
  397. */
  398. getEngine(): Engine;
  399. private _behaviors;
  400. /**
  401. * Attach a behavior to the node
  402. * @see http://doc.babylonjs.com/features/behaviour
  403. * @param behavior defines the behavior to attach
  404. * @returns the current Node
  405. */
  406. addBehavior(behavior: Behavior<Node>): Node;
  407. /**
  408. * Remove an attached behavior
  409. * @see http://doc.babylonjs.com/features/behaviour
  410. * @param behavior defines the behavior to attach
  411. * @returns the current Node
  412. */
  413. removeBehavior(behavior: Behavior<Node>): Node;
  414. /**
  415. * Gets the list of attached behaviors
  416. * @see http://doc.babylonjs.com/features/behaviour
  417. */
  418. readonly behaviors: Behavior<Node>[];
  419. /**
  420. * Gets an attached behavior by name
  421. * @param name defines the name of the behavior to look for
  422. * @see http://doc.babylonjs.com/features/behaviour
  423. * @returns null if behavior was not found else the requested behavior
  424. */
  425. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  426. /**
  427. * Returns the world matrix of the node
  428. * @returns a matrix containing the node's world matrix
  429. */
  430. getWorldMatrix(): Matrix;
  431. /** @ignore */
  432. _initCache(): void;
  433. /** @ignore */
  434. updateCache(force?: boolean): void;
  435. /** @ignore */
  436. _updateCache(ignoreParentClass?: boolean): void;
  437. /** @ignore */
  438. _isSynchronized(): boolean;
  439. /** @ignore */
  440. _markSyncedWithParent(): void;
  441. /** @ignore */
  442. isSynchronizedWithParent(): boolean;
  443. /** @ignore */
  444. isSynchronized(updateCache?: boolean): boolean;
  445. /** @ignore */
  446. hasNewParent(update?: boolean): boolean;
  447. /**
  448. * Is this node ready to be used/rendered
  449. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  450. * @return true if the node is ready
  451. */
  452. isReady(completeCheck?: boolean): boolean;
  453. /**
  454. * Is this node enabled?
  455. * 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
  456. * @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
  457. * @return whether this node (and its parent) is enabled
  458. * @see setEnabled
  459. */
  460. isEnabled(checkAncestors?: boolean): boolean;
  461. /**
  462. * Set the enabled state of this node
  463. * @param value defines the new enabled state
  464. * @see isEnabled
  465. */
  466. setEnabled(value: boolean): void;
  467. /**
  468. * Is this node a descendant of the given node?
  469. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  470. * @param ancestor defines the parent node to inspect
  471. * @see parent
  472. * @returns a boolean indicating if this node is a descendant of the given node
  473. */
  474. isDescendantOf(ancestor: Node): boolean;
  475. /** @ignore */
  476. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  477. /**
  478. * Will return all nodes that have this node as ascendant
  479. * @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
  480. * @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
  481. * @return all children nodes of all types
  482. */
  483. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  484. /**
  485. * Get all child-meshes of this node
  486. * @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
  487. * @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
  488. * @returns an array of {BABYLON.AbstractMesh}
  489. */
  490. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  491. /**
  492. * Get all child-transformNodes of this node
  493. * @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
  494. * @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
  495. * @returns an array of {BABYLON.TransformNode}
  496. */
  497. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  498. /**
  499. * Get all direct children of this node
  500. * @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
  501. * @returns an array of {BABYLON.Node}
  502. */
  503. getChildren(predicate?: (node: Node) => boolean): Node[];
  504. /** @ignore */
  505. _setReady(state: boolean): void;
  506. /**
  507. * Get an animation by name
  508. * @param name defines the name of the animation to look for
  509. * @returns null if not found else the requested animation
  510. */
  511. getAnimationByName(name: string): Nullable<Animation>;
  512. /**
  513. * Creates an animation range for this node
  514. * @param name defines the name of the range
  515. * @param from defines the starting key
  516. * @param to defines the end key
  517. */
  518. createAnimationRange(name: string, from: number, to: number): void;
  519. /**
  520. * Delete a specific animation range
  521. * @param name defines the name of the range to delete
  522. * @param deleteFrames defines if animation frames from the range must be deleted as well
  523. */
  524. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  525. /**
  526. * Get an animation range by name
  527. * @param name defines the name of the animation range to look for
  528. * @returns null if not found else the requested animation range
  529. */
  530. getAnimationRange(name: string): Nullable<AnimationRange>;
  531. /**
  532. * Will start the animation sequence
  533. * @param name defines the range frames for animation sequence
  534. * @param loop defines if the animation should loop (false by default)
  535. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  536. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  537. * @returns the object created for this animation. If range does not exist, it will return null
  538. */
  539. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  540. /**
  541. * Serialize animation ranges into a JSON compatible object
  542. * @returns serialization object
  543. */
  544. serializeAnimationRanges(): any;
  545. /**
  546. * Computes the world matrix of the node
  547. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  548. * @returns the world matrix
  549. */
  550. computeWorldMatrix(force?: boolean): Matrix;
  551. /**
  552. * Releases all associated resources
  553. */
  554. dispose(): void;
  555. /**
  556. * Parse animation range data from a serialization object and store them into a given node
  557. * @param node defines where to store the animation ranges
  558. * @param parsedNode defines the serialization object to read data from
  559. * @param scene defines the hosting scene
  560. */
  561. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  562. }
  563. }
  564. declare module BABYLON {
  565. interface IDisposable {
  566. dispose(): void;
  567. }
  568. interface IActiveMeshCandidateProvider {
  569. getMeshes(scene: Scene): AbstractMesh[];
  570. readonly checksIsEnabled: boolean;
  571. }
  572. /**
  573. * This class is used by the onRenderingGroupObservable
  574. */
  575. class RenderingGroupInfo {
  576. /**
  577. * The Scene that being rendered
  578. */
  579. scene: Scene;
  580. /**
  581. * The camera currently used for the rendering pass
  582. */
  583. camera: Nullable<Camera>;
  584. /**
  585. * The ID of the renderingGroup being processed
  586. */
  587. renderingGroupId: number;
  588. /**
  589. * The rendering stage, can be either STAGE_PRECLEAR, STAGE_PREOPAQUE, STAGE_PRETRANSPARENT, STAGE_POSTTRANSPARENT
  590. */
  591. renderStage: number;
  592. /**
  593. * Stage corresponding to the very first hook in the renderingGroup phase: before the render buffer may be cleared
  594. * This stage will be fired no matter what
  595. */
  596. static STAGE_PRECLEAR: number;
  597. /**
  598. * Called before opaque object are rendered.
  599. * This stage will be fired only if there's 3D Opaque content to render
  600. */
  601. static STAGE_PREOPAQUE: number;
  602. /**
  603. * Called after the opaque objects are rendered and before the transparent ones
  604. * This stage will be fired only if there's 3D transparent content to render
  605. */
  606. static STAGE_PRETRANSPARENT: number;
  607. /**
  608. * Called after the transparent object are rendered, last hook of the renderingGroup phase
  609. * This stage will be fired no matter what
  610. */
  611. static STAGE_POSTTRANSPARENT: number;
  612. }
  613. /**
  614. * Represents a scene to be rendered by the engine.
  615. * @see http://doc.babylonjs.com/page.php?p=21911
  616. */
  617. class Scene implements IAnimatable {
  618. private static _FOGMODE_NONE;
  619. private static _FOGMODE_EXP;
  620. private static _FOGMODE_EXP2;
  621. private static _FOGMODE_LINEAR;
  622. private static _uniqueIdCounter;
  623. static MinDeltaTime: number;
  624. static MaxDeltaTime: number;
  625. /** The fog is deactivated */
  626. static readonly FOGMODE_NONE: number;
  627. /** The fog density is following an exponential function */
  628. static readonly FOGMODE_EXP: number;
  629. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  630. static readonly FOGMODE_EXP2: number;
  631. /** The fog density is following a linear function. */
  632. static readonly FOGMODE_LINEAR: number;
  633. autoClear: boolean;
  634. autoClearDepthAndStencil: boolean;
  635. clearColor: Color4;
  636. ambientColor: Color3;
  637. _environmentBRDFTexture: BaseTexture;
  638. protected _environmentTexture: BaseTexture;
  639. /**
  640. * Texture used in all pbr material as the reflection texture.
  641. * As in the majority of the scene they are the same (exception for multi room and so on),
  642. * this is easier to reference from here than from all the materials.
  643. */
  644. /**
  645. * Texture used in all pbr material as the reflection texture.
  646. * As in the majority of the scene they are the same (exception for multi room and so on),
  647. * this is easier to set here than in all the materials.
  648. */
  649. environmentTexture: BaseTexture;
  650. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  651. /**
  652. * Default image processing configuration used either in the rendering
  653. * Forward main pass or through the imageProcessingPostProcess if present.
  654. * As in the majority of the scene they are the same (exception for multi camera),
  655. * this is easier to reference from here than from all the materials and post process.
  656. *
  657. * No setter as we it is a shared configuration, you can set the values instead.
  658. */
  659. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  660. forceWireframe: boolean;
  661. private _forcePointsCloud;
  662. forcePointsCloud: boolean;
  663. forceShowBoundingBoxes: boolean;
  664. clipPlane: Nullable<Plane>;
  665. animationsEnabled: boolean;
  666. useConstantAnimationDeltaTime: boolean;
  667. constantlyUpdateMeshUnderPointer: boolean;
  668. hoverCursor: string;
  669. defaultCursor: string;
  670. /**
  671. * This is used to call preventDefault() on pointer down
  672. * in order to block unwanted artifacts like system double clicks
  673. */
  674. preventDefaultOnPointerDown: boolean;
  675. metadata: any;
  676. loadingPluginName: string;
  677. private _spritePredicate;
  678. /**
  679. * An event triggered when the scene is disposed.
  680. * @type {BABYLON.Observable}
  681. */
  682. onDisposeObservable: Observable<Scene>;
  683. private _onDisposeObserver;
  684. /** A function to be executed when this scene is disposed. */
  685. onDispose: () => void;
  686. /**
  687. * An event triggered before rendering the scene (right after animations and physics)
  688. * @type {BABYLON.Observable}
  689. */
  690. onBeforeRenderObservable: Observable<Scene>;
  691. private _onBeforeRenderObserver;
  692. /** A function to be executed before rendering this scene */
  693. beforeRender: Nullable<() => void>;
  694. /**
  695. * An event triggered after rendering the scene
  696. * @type {BABYLON.Observable}
  697. */
  698. onAfterRenderObservable: Observable<Scene>;
  699. private _onAfterRenderObserver;
  700. /** A function to be executed after rendering this scene */
  701. afterRender: Nullable<() => void>;
  702. /**
  703. * An event triggered before animating the scene
  704. * @type {BABYLON.Observable}
  705. */
  706. onBeforeAnimationsObservable: Observable<Scene>;
  707. /**
  708. * An event triggered after animations processing
  709. * @type {BABYLON.Observable}
  710. */
  711. onAfterAnimationsObservable: Observable<Scene>;
  712. /**
  713. * An event triggered before draw calls are ready to be sent
  714. * @type {BABYLON.Observable}
  715. */
  716. onBeforeDrawPhaseObservable: Observable<Scene>;
  717. /**
  718. * An event triggered after draw calls have been sent
  719. * @type {BABYLON.Observable}
  720. */
  721. onAfterDrawPhaseObservable: Observable<Scene>;
  722. /**
  723. * An event triggered when physic simulation is about to be run
  724. * @type {BABYLON.Observable}
  725. */
  726. onBeforePhysicsObservable: Observable<Scene>;
  727. /**
  728. * An event triggered when physic simulation has been done
  729. * @type {BABYLON.Observable}
  730. */
  731. onAfterPhysicsObservable: Observable<Scene>;
  732. /**
  733. * An event triggered when the scene is ready
  734. * @type {BABYLON.Observable}
  735. */
  736. onReadyObservable: Observable<Scene>;
  737. /**
  738. * An event triggered before rendering a camera
  739. * @type {BABYLON.Observable}
  740. */
  741. onBeforeCameraRenderObservable: Observable<Camera>;
  742. private _onBeforeCameraRenderObserver;
  743. beforeCameraRender: () => void;
  744. /**
  745. * An event triggered after rendering a camera
  746. * @type {BABYLON.Observable}
  747. */
  748. onAfterCameraRenderObservable: Observable<Camera>;
  749. private _onAfterCameraRenderObserver;
  750. afterCameraRender: () => void;
  751. /**
  752. * An event triggered when active meshes evaluation is about to start
  753. * @type {BABYLON.Observable}
  754. */
  755. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  756. /**
  757. * An event triggered when active meshes evaluation is done
  758. * @type {BABYLON.Observable}
  759. */
  760. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  761. /**
  762. * An event triggered when particles rendering is about to start
  763. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  764. * @type {BABYLON.Observable}
  765. */
  766. onBeforeParticlesRenderingObservable: Observable<Scene>;
  767. /**
  768. * An event triggered when particles rendering is done
  769. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  770. * @type {BABYLON.Observable}
  771. */
  772. onAfterParticlesRenderingObservable: Observable<Scene>;
  773. /**
  774. * An event triggered when sprites rendering is about to start
  775. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  776. * @type {BABYLON.Observable}
  777. */
  778. onBeforeSpritesRenderingObservable: Observable<Scene>;
  779. /**
  780. * An event triggered when sprites rendering is done
  781. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  782. * @type {BABYLON.Observable}
  783. */
  784. onAfterSpritesRenderingObservable: Observable<Scene>;
  785. /**
  786. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  787. * @type {BABYLON.Observable}
  788. */
  789. onDataLoadedObservable: Observable<Scene>;
  790. /**
  791. * An event triggered when a camera is created
  792. * @type {BABYLON.Observable}
  793. */
  794. onNewCameraAddedObservable: Observable<Camera>;
  795. /**
  796. * An event triggered when a camera is removed
  797. * @type {BABYLON.Observable}
  798. */
  799. onCameraRemovedObservable: Observable<Camera>;
  800. /**
  801. * An event triggered when a light is created
  802. * @type {BABYLON.Observable}
  803. */
  804. onNewLightAddedObservable: Observable<Light>;
  805. /**
  806. * An event triggered when a light is removed
  807. * @type {BABYLON.Observable}
  808. */
  809. onLightRemovedObservable: Observable<Light>;
  810. /**
  811. * An event triggered when a geometry is created
  812. * @type {BABYLON.Observable}
  813. */
  814. onNewGeometryAddedObservable: Observable<Geometry>;
  815. /**
  816. * An event triggered when a geometry is removed
  817. * @type {BABYLON.Observable}
  818. */
  819. onGeometryRemovedObservable: Observable<Geometry>;
  820. /**
  821. * An event triggered when a transform node is created
  822. * @type {BABYLON.Observable}
  823. */
  824. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  825. /**
  826. * An event triggered when a transform node is removed
  827. * @type {BABYLON.Observable}
  828. */
  829. onTransformNodeRemovedObservable: Observable<TransformNode>;
  830. /**
  831. * An event triggered when a mesh is created
  832. * @type {BABYLON.Observable}
  833. */
  834. onNewMeshAddedObservable: Observable<AbstractMesh>;
  835. /**
  836. * An event triggered when a mesh is removed
  837. * @type {BABYLON.Observable}
  838. */
  839. onMeshRemovedObservable: Observable<AbstractMesh>;
  840. /**
  841. * An event triggered when render targets are about to be rendered
  842. * Can happen multiple times per frame.
  843. * @type {BABYLON.Observable}
  844. */
  845. OnBeforeRenderTargetsRenderObservable: Observable<Scene>;
  846. /**
  847. * An event triggered when render targets were rendered.
  848. * Can happen multiple times per frame.
  849. * @type {BABYLON.Observable}
  850. */
  851. OnAfterRenderTargetsRenderObservable: Observable<Scene>;
  852. /**
  853. * An event triggered before calculating deterministic simulation step
  854. * @type {BABYLON.Observable}
  855. */
  856. onBeforeStepObservable: Observable<Scene>;
  857. /**
  858. * An event triggered after calculating deterministic simulation step
  859. * @type {BABYLON.Observable}
  860. */
  861. onAfterStepObservable: Observable<Scene>;
  862. /**
  863. * This Observable will be triggered for each stage of each renderingGroup of each rendered camera.
  864. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  865. * 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)
  866. */
  867. onRenderingGroupObservable: Observable<RenderingGroupInfo>;
  868. animations: Animation[];
  869. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  870. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  871. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  872. private _onPointerMove;
  873. private _onPointerDown;
  874. private _onPointerUp;
  875. /** Deprecated. Use onPointerObservable instead */
  876. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  877. /** Deprecated. Use onPointerObservable instead */
  878. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  879. /** Deprecated. Use onPointerObservable instead */
  880. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>) => void;
  881. /** Deprecated. Use onPointerObservable instead */
  882. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  883. private _gamepadManager;
  884. readonly gamepadManager: GamepadManager;
  885. /**
  886. * 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).
  887. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  888. */
  889. onPrePointerObservable: Observable<PointerInfoPre>;
  890. /**
  891. * Observable event triggered each time an input event is received from the rendering canvas
  892. */
  893. onPointerObservable: Observable<PointerInfo>;
  894. readonly unTranslatedPointer: Vector2;
  895. /** The distance in pixel that you have to move to prevent some events */
  896. static DragMovementThreshold: number;
  897. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  898. static LongPressDelay: number;
  899. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  900. static DoubleClickDelay: number;
  901. /** If you need to check double click without raising a single click at first click, enable this flag */
  902. static ExclusiveDoubleClickMode: boolean;
  903. private _initClickEvent;
  904. private _initActionManager;
  905. private _delayedSimpleClick;
  906. private _delayedSimpleClickTimeout;
  907. private _previousDelayedSimpleClickTimeout;
  908. private _meshPickProceed;
  909. private _previousButtonPressed;
  910. private _currentPickResult;
  911. private _previousPickResult;
  912. private _totalPointersPressed;
  913. private _doubleClickOccured;
  914. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  915. cameraToUseForPointers: Nullable<Camera>;
  916. private _pointerX;
  917. private _pointerY;
  918. private _unTranslatedPointerX;
  919. private _unTranslatedPointerY;
  920. private _startingPointerPosition;
  921. private _previousStartingPointerPosition;
  922. private _startingPointerTime;
  923. private _previousStartingPointerTime;
  924. private _timeAccumulator;
  925. private _currentStepId;
  926. private _currentInternalStep;
  927. _mirroredCameraPosition: Nullable<Vector3>;
  928. /**
  929. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  930. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  931. */
  932. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  933. /**
  934. * Observable event triggered each time an keyboard event is received from the hosting window
  935. */
  936. onKeyboardObservable: Observable<KeyboardInfo>;
  937. private _onKeyDown;
  938. private _onKeyUp;
  939. private _onCanvasFocusObserver;
  940. private _onCanvasBlurObserver;
  941. /**
  942. * use right-handed coordinate system on this scene.
  943. * @type {boolean}
  944. */
  945. private _useRightHandedSystem;
  946. useRightHandedSystem: boolean;
  947. setStepId(newStepId: number): void;
  948. getStepId(): number;
  949. getInternalStep(): number;
  950. private _fogEnabled;
  951. /**
  952. * is fog enabled on this scene.
  953. */
  954. fogEnabled: boolean;
  955. private _fogMode;
  956. fogMode: number;
  957. fogColor: Color3;
  958. fogDensity: number;
  959. fogStart: number;
  960. fogEnd: number;
  961. /**
  962. * is shadow enabled on this scene.
  963. * @type {boolean}
  964. */
  965. private _shadowsEnabled;
  966. shadowsEnabled: boolean;
  967. /**
  968. * is light enabled on this scene.
  969. * @type {boolean}
  970. */
  971. private _lightsEnabled;
  972. lightsEnabled: boolean;
  973. /**
  974. * All of the lights added to this scene.
  975. * @see BABYLON.Light
  976. * @type {BABYLON.Light[]}
  977. */
  978. lights: Light[];
  979. /** All of the cameras added to this scene. */
  980. cameras: Camera[];
  981. /** All of the active cameras added to this scene. */
  982. activeCameras: Camera[];
  983. /** The current active camera */
  984. activeCamera: Nullable<Camera>;
  985. /**
  986. * All of the tranform nodes added to this scene.
  987. * @see BABYLON.TransformNode
  988. * @type {BABYLON.TransformNode[]}
  989. */
  990. transformNodes: TransformNode[];
  991. /**
  992. * All of the (abstract) meshes added to this scene.
  993. * @see BABYLON.AbstractMesh
  994. * @type {BABYLON.AbstractMesh[]}
  995. */
  996. meshes: AbstractMesh[];
  997. /**
  998. * All of the animation groups added to this scene.
  999. * @see BABYLON.AnimationGroup
  1000. * @type {BABYLON.AnimationGroup[]}
  1001. */
  1002. animationGroups: AnimationGroup[];
  1003. private _geometries;
  1004. materials: Material[];
  1005. multiMaterials: MultiMaterial[];
  1006. private _defaultMaterial;
  1007. /** The default material used on meshes when no material is affected */
  1008. /** The default material used on meshes when no material is affected */
  1009. defaultMaterial: Material;
  1010. private _texturesEnabled;
  1011. texturesEnabled: boolean;
  1012. textures: BaseTexture[];
  1013. particlesEnabled: boolean;
  1014. particleSystems: IParticleSystem[];
  1015. spritesEnabled: boolean;
  1016. spriteManagers: SpriteManager[];
  1017. /**
  1018. * The list of layers (background and foreground) of the scene.
  1019. */
  1020. layers: Layer[];
  1021. /**
  1022. * The list of effect layers (highlights/glow) contained in the scene.
  1023. */
  1024. effectLayers: EffectLayer[];
  1025. private _skeletonsEnabled;
  1026. skeletonsEnabled: boolean;
  1027. skeletons: Skeleton[];
  1028. morphTargetManagers: MorphTargetManager[];
  1029. lensFlaresEnabled: boolean;
  1030. lensFlareSystems: LensFlareSystem[];
  1031. collisionsEnabled: boolean;
  1032. private _workerCollisions;
  1033. collisionCoordinator: ICollisionCoordinator;
  1034. /** Defines the gravity applied to this scene */
  1035. gravity: Vector3;
  1036. postProcesses: PostProcess[];
  1037. postProcessesEnabled: boolean;
  1038. postProcessManager: PostProcessManager;
  1039. private _postProcessRenderPipelineManager;
  1040. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  1041. renderTargetsEnabled: boolean;
  1042. dumpNextRenderTargets: boolean;
  1043. customRenderTargets: RenderTargetTexture[];
  1044. useDelayedTextureLoading: boolean;
  1045. importedMeshesFiles: String[];
  1046. probesEnabled: boolean;
  1047. reflectionProbes: ReflectionProbe[];
  1048. database: Database;
  1049. /**
  1050. * This scene's action manager
  1051. * @type {BABYLON.ActionManager}
  1052. */
  1053. actionManager: ActionManager;
  1054. _actionManagers: ActionManager[];
  1055. private _meshesForIntersections;
  1056. proceduralTexturesEnabled: boolean;
  1057. _proceduralTextures: ProceduralTexture[];
  1058. private _mainSoundTrack;
  1059. soundTracks: SoundTrack[];
  1060. private _audioEnabled;
  1061. private _headphone;
  1062. readonly mainSoundTrack: SoundTrack;
  1063. VRHelper: VRExperienceHelper;
  1064. simplificationQueue: SimplificationQueue;
  1065. private _engine;
  1066. private _totalVertices;
  1067. _activeIndices: PerfCounter;
  1068. _activeParticles: PerfCounter;
  1069. _activeBones: PerfCounter;
  1070. private _animationRatio;
  1071. private _animationTimeLast;
  1072. private _animationTime;
  1073. animationTimeScale: number;
  1074. _cachedMaterial: Nullable<Material>;
  1075. _cachedEffect: Nullable<Effect>;
  1076. _cachedVisibility: Nullable<number>;
  1077. private _renderId;
  1078. private _executeWhenReadyTimeoutId;
  1079. private _intermediateRendering;
  1080. private _viewUpdateFlag;
  1081. private _projectionUpdateFlag;
  1082. private _alternateViewUpdateFlag;
  1083. private _alternateProjectionUpdateFlag;
  1084. _toBeDisposed: SmartArray<Nullable<IDisposable>>;
  1085. private _activeRequests;
  1086. private _pendingData;
  1087. private _isDisposed;
  1088. dispatchAllSubMeshesOfActiveMeshes: boolean;
  1089. private _activeMeshes;
  1090. private _processedMaterials;
  1091. private _renderTargets;
  1092. _activeParticleSystems: SmartArray<IParticleSystem>;
  1093. private _activeSkeletons;
  1094. private _softwareSkinnedMeshes;
  1095. private _renderingManager;
  1096. private _physicsEngine;
  1097. _activeAnimatables: Animatable[];
  1098. private _transformMatrix;
  1099. private _sceneUbo;
  1100. private _alternateSceneUbo;
  1101. private _pickWithRayInverseMatrix;
  1102. private _boundingBoxRenderer;
  1103. private _outlineRenderer;
  1104. private _viewMatrix;
  1105. private _projectionMatrix;
  1106. private _alternateViewMatrix;
  1107. private _alternateProjectionMatrix;
  1108. private _alternateTransformMatrix;
  1109. private _useAlternateCameraConfiguration;
  1110. private _alternateRendering;
  1111. _forcedViewPosition: Nullable<Vector3>;
  1112. readonly _isAlternateRenderingEnabled: boolean;
  1113. private _frustumPlanes;
  1114. readonly frustumPlanes: Plane[];
  1115. requireLightSorting: boolean;
  1116. private _selectionOctree;
  1117. private _pointerOverMesh;
  1118. private _pointerOverSprite;
  1119. private _debugLayer;
  1120. private _depthRenderer;
  1121. private _geometryBufferRenderer;
  1122. /**
  1123. * Gets the current geometry buffer associated to the scene.
  1124. */
  1125. /**
  1126. * Sets the current geometry buffer for the scene.
  1127. */
  1128. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  1129. private _pickedDownMesh;
  1130. private _pickedUpMesh;
  1131. private _pickedDownSprite;
  1132. private _externalData;
  1133. private _uid;
  1134. /**
  1135. * @constructor
  1136. * @param {BABYLON.Engine} engine - the engine to be used to render this scene.
  1137. */
  1138. constructor(engine: Engine);
  1139. readonly debugLayer: DebugLayer;
  1140. workerCollisions: boolean;
  1141. readonly selectionOctree: Octree<AbstractMesh>;
  1142. /**
  1143. * The mesh that is currently under the pointer.
  1144. * @return {BABYLON.AbstractMesh} mesh under the pointer/mouse cursor or null if none.
  1145. */
  1146. readonly meshUnderPointer: Nullable<AbstractMesh>;
  1147. /**
  1148. * Current on-screen X position of the pointer
  1149. * @return {number} X position of the pointer
  1150. */
  1151. readonly pointerX: number;
  1152. /**
  1153. * Current on-screen Y position of the pointer
  1154. * @return {number} Y position of the pointer
  1155. */
  1156. readonly pointerY: number;
  1157. getCachedMaterial(): Nullable<Material>;
  1158. getCachedEffect(): Nullable<Effect>;
  1159. getCachedVisibility(): Nullable<number>;
  1160. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  1161. getBoundingBoxRenderer(): BoundingBoxRenderer;
  1162. getOutlineRenderer(): OutlineRenderer;
  1163. getEngine(): Engine;
  1164. getTotalVertices(): number;
  1165. readonly totalVerticesPerfCounter: PerfCounter;
  1166. getActiveIndices(): number;
  1167. readonly totalActiveIndicesPerfCounter: PerfCounter;
  1168. getActiveParticles(): number;
  1169. readonly activeParticlesPerfCounter: PerfCounter;
  1170. getActiveBones(): number;
  1171. readonly activeBonesPerfCounter: PerfCounter;
  1172. getInterFramePerfCounter(): number;
  1173. readonly interFramePerfCounter: Nullable<PerfCounter>;
  1174. getLastFrameDuration(): number;
  1175. readonly lastFramePerfCounter: Nullable<PerfCounter>;
  1176. getEvaluateActiveMeshesDuration(): number;
  1177. readonly evaluateActiveMeshesDurationPerfCounter: Nullable<PerfCounter>;
  1178. getActiveMeshes(): SmartArray<AbstractMesh>;
  1179. getRenderTargetsDuration(): number;
  1180. getRenderDuration(): number;
  1181. readonly renderDurationPerfCounter: Nullable<PerfCounter>;
  1182. getParticlesDuration(): number;
  1183. readonly particlesDurationPerfCounter: Nullable<PerfCounter>;
  1184. getSpritesDuration(): number;
  1185. readonly spriteDuractionPerfCounter: Nullable<PerfCounter>;
  1186. getAnimationRatio(): number;
  1187. getRenderId(): number;
  1188. incrementRenderId(): void;
  1189. private _updatePointerPosition(evt);
  1190. private _createUbo();
  1191. private _createAlternateUbo();
  1192. /**
  1193. * Use this method to simulate a pointer move on a mesh
  1194. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  1195. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  1196. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  1197. */
  1198. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  1199. private _processPointerMove(pickResult, evt);
  1200. /**
  1201. * Use this method to simulate a pointer down on a mesh
  1202. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  1203. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  1204. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  1205. */
  1206. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  1207. private _processPointerDown(pickResult, evt);
  1208. /**
  1209. * Use this method to simulate a pointer up on a mesh
  1210. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  1211. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  1212. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  1213. */
  1214. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  1215. private _processPointerUp(pickResult, evt, clickInfo);
  1216. /**
  1217. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  1218. * @param attachUp defines if you want to attach events to pointerup
  1219. * @param attachDown defines if you want to attach events to pointerdown
  1220. * @param attachMove defines if you want to attach events to pointermove
  1221. */
  1222. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  1223. detachControl(): void;
  1224. /**
  1225. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  1226. * Delay loaded resources are not taking in account
  1227. * @return true if all required resources are ready
  1228. */
  1229. isReady(): boolean;
  1230. resetCachedMaterial(): void;
  1231. registerBeforeRender(func: () => void): void;
  1232. unregisterBeforeRender(func: () => void): void;
  1233. registerAfterRender(func: () => void): void;
  1234. unregisterAfterRender(func: () => void): void;
  1235. private _executeOnceBeforeRender(func);
  1236. /**
  1237. * The provided function will run before render once and will be disposed afterwards.
  1238. * A timeout delay can be provided so that the function will be executed in N ms.
  1239. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  1240. * @param func The function to be executed.
  1241. * @param timeout optional delay in ms
  1242. */
  1243. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  1244. _addPendingData(data: any): void;
  1245. _removePendingData(data: any): void;
  1246. getWaitingItemsCount(): number;
  1247. readonly isLoading: boolean;
  1248. /**
  1249. * Registers a function to be executed when the scene is ready.
  1250. * @param {Function} func - the function to be executed.
  1251. */
  1252. executeWhenReady(func: () => void): void;
  1253. /**
  1254. * Returns a promise that resolves when the scene is ready.
  1255. * @returns A promise that resolves when the scene is ready.
  1256. */
  1257. whenReadyAsync(): Promise<void>;
  1258. _checkIsReady(): void;
  1259. /**
  1260. * Will start the animation sequence of a given target
  1261. * @param target - the target
  1262. * @param {number} from - from which frame should animation start
  1263. * @param {number} to - till which frame should animation run.
  1264. * @param {boolean} [loop] - should the animation loop
  1265. * @param {number} [speedRatio] - the speed in which to run the animation
  1266. * @param {Function} [onAnimationEnd] function to be executed when the animation ended.
  1267. * @param {BABYLON.Animatable} [animatable] an animatable object. If not provided a new one will be created from the given params.
  1268. * Returns {BABYLON.Animatable} the animatable object created for this animation
  1269. * See BABYLON.Animatable
  1270. */
  1271. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable): Animatable;
  1272. /**
  1273. * Begin a new animation on a given node
  1274. * @param {BABYLON.Node} node defines the root node where the animation will take place
  1275. * @param {BABYLON.Animation[]} defines the list of animations to start
  1276. * @param {number} from defines the initial value
  1277. * @param {number} to defines the final value
  1278. * @param {boolean} loop defines if you want animation to loop (off by default)
  1279. * @param {number} speedRatio defines the speed ratio to apply to all animations
  1280. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  1281. * @returns the list of created animatables
  1282. */
  1283. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Animatable;
  1284. /**
  1285. * Begin a new animation on a given node and its hierarchy
  1286. * @param {BABYLON.Node} node defines the root node where the animation will take place
  1287. * @param {boolean} 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.
  1288. * @param {BABYLON.Animation[]} defines the list of animations to start
  1289. * @param {number} from defines the initial value
  1290. * @param {number} to defines the final value
  1291. * @param {boolean} loop defines if you want animation to loop (off by default)
  1292. * @param {number} speedRatio defines the speed ratio to apply to all animations
  1293. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  1294. * @returns the list of animatables created for all nodes
  1295. */
  1296. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Animatable[];
  1297. getAnimatableByTarget(target: any): Nullable<Animatable>;
  1298. readonly animatables: Animatable[];
  1299. /**
  1300. * Will stop the animation of the given target
  1301. * @param target - the target
  1302. * @param animationName - the name of the animation to stop (all animations will be stopped is empty)
  1303. * @see beginAnimation
  1304. */
  1305. stopAnimation(target: any, animationName?: string): void;
  1306. /**
  1307. * Stops and removes all animations that have been applied to the scene
  1308. */
  1309. stopAllAnimations(): void;
  1310. private _animate();
  1311. _switchToAlternateCameraConfiguration(active: boolean): void;
  1312. getViewMatrix(): Matrix;
  1313. getProjectionMatrix(): Matrix;
  1314. getTransformMatrix(): Matrix;
  1315. setTransformMatrix(view: Matrix, projection: Matrix): void;
  1316. _setAlternateTransformMatrix(view: Matrix, projection: Matrix): void;
  1317. getSceneUniformBuffer(): UniformBuffer;
  1318. getUniqueId(): number;
  1319. addMesh(newMesh: AbstractMesh): void;
  1320. removeMesh(toRemove: AbstractMesh): number;
  1321. addTransformNode(newTransformNode: TransformNode): void;
  1322. removeTransformNode(toRemove: TransformNode): number;
  1323. removeSkeleton(toRemove: Skeleton): number;
  1324. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  1325. removeLight(toRemove: Light): number;
  1326. removeCamera(toRemove: Camera): number;
  1327. removeParticleSystem(toRemove: IParticleSystem): number;
  1328. removeAnimation(toRemove: Animation): number;
  1329. removeMultiMaterial(toRemove: MultiMaterial): number;
  1330. removeMaterial(toRemove: Material): number;
  1331. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  1332. removeActionManager(toRemove: ActionManager): number;
  1333. addLight(newLight: Light): void;
  1334. sortLightsByPriority(): void;
  1335. addCamera(newCamera: Camera): void;
  1336. addSkeleton(newSkeleton: Skeleton): void;
  1337. addParticleSystem(newParticleSystem: IParticleSystem): void;
  1338. addAnimation(newAnimation: Animation): void;
  1339. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  1340. addMaterial(newMaterial: Material): void;
  1341. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  1342. addGeometry(newGeometrie: Geometry): void;
  1343. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  1344. addActionManager(newActionManager: ActionManager): void;
  1345. /**
  1346. * Switch active camera
  1347. * @param {Camera} newCamera - new active camera
  1348. * @param {boolean} attachControl - call attachControl for the new active camera (default: true)
  1349. */
  1350. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  1351. /**
  1352. * sets the active camera of the scene using its ID
  1353. * @param {string} id - the camera's ID
  1354. * @return {BABYLON.Camera|null} the new active camera or null if none found.
  1355. * @see activeCamera
  1356. */
  1357. setActiveCameraByID(id: string): Nullable<Camera>;
  1358. /**
  1359. * sets the active camera of the scene using its name
  1360. * @param {string} name - the camera's name
  1361. * @return {BABYLON.Camera|null} the new active camera or null if none found.
  1362. * @see activeCamera
  1363. */
  1364. setActiveCameraByName(name: string): Nullable<Camera>;
  1365. /**
  1366. * get an animation group using its name
  1367. * @param {string} the material's name
  1368. * @return {BABYLON.AnimationGroup|null} the animation group or null if none found.
  1369. */
  1370. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  1371. /**
  1372. * get a material using its id
  1373. * @param {string} the material's ID
  1374. * @return {BABYLON.Material|null} the material or null if none found.
  1375. */
  1376. getMaterialByID(id: string): Nullable<Material>;
  1377. /**
  1378. * get a material using its name
  1379. * @param {string} the material's name
  1380. * @return {BABYLON.Material|null} the material or null if none found.
  1381. */
  1382. getMaterialByName(name: string): Nullable<Material>;
  1383. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  1384. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  1385. getCameraByID(id: string): Nullable<Camera>;
  1386. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  1387. /**
  1388. * get a camera using its name
  1389. * @param {string} the camera's name
  1390. * @return {BABYLON.Camera|null} the camera or null if none found.
  1391. */
  1392. getCameraByName(name: string): Nullable<Camera>;
  1393. /**
  1394. * get a bone using its id
  1395. * @param {string} the bone's id
  1396. * @return {BABYLON.Bone|null} the bone or null if not found
  1397. */
  1398. getBoneByID(id: string): Nullable<Bone>;
  1399. /**
  1400. * get a bone using its id
  1401. * @param {string} the bone's name
  1402. * @return {BABYLON.Bone|null} the bone or null if not found
  1403. */
  1404. getBoneByName(name: string): Nullable<Bone>;
  1405. /**
  1406. * get a light node using its name
  1407. * @param {string} the light's name
  1408. * @return {BABYLON.Light|null} the light or null if none found.
  1409. */
  1410. getLightByName(name: string): Nullable<Light>;
  1411. /**
  1412. * get a light node using its ID
  1413. * @param {string} the light's id
  1414. * @return {BABYLON.Light|null} the light or null if none found.
  1415. */
  1416. getLightByID(id: string): Nullable<Light>;
  1417. /**
  1418. * get a light node using its scene-generated unique ID
  1419. * @param {number} the light's unique id
  1420. * @return {BABYLON.Light|null} the light or null if none found.
  1421. */
  1422. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  1423. /**
  1424. * get a particle system by id
  1425. * @param id {number} the particle system id
  1426. * @return {BABYLON.IParticleSystem|null} the corresponding system or null if none found.
  1427. */
  1428. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  1429. /**
  1430. * get a geometry using its ID
  1431. * @param {string} the geometry's id
  1432. * @return {BABYLON.Geometry|null} the geometry or null if none found.
  1433. */
  1434. getGeometryByID(id: string): Nullable<Geometry>;
  1435. /**
  1436. * add a new geometry to this scene.
  1437. * @param {BABYLON.Geometry} geometry - the geometry to be added to the scene.
  1438. * @param {boolean} [force] - force addition, even if a geometry with this ID already exists
  1439. * @return {boolean} was the geometry added or not
  1440. */
  1441. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  1442. /**
  1443. * Removes an existing geometry
  1444. * @param {BABYLON.Geometry} geometry - the geometry to be removed from the scene.
  1445. * @return {boolean} was the geometry removed or not
  1446. */
  1447. removeGeometry(geometry: Geometry): boolean;
  1448. getGeometries(): Geometry[];
  1449. /**
  1450. * Get the first added mesh found of a given ID
  1451. * @param {string} id - the id to search for
  1452. * @return {BABYLON.AbstractMesh|null} the mesh found or null if not found at all.
  1453. */
  1454. getMeshByID(id: string): Nullable<AbstractMesh>;
  1455. getMeshesByID(id: string): Array<AbstractMesh>;
  1456. /**
  1457. * Get the first added transform node found of a given ID
  1458. * @param {string} id - the id to search for
  1459. * @return {BABYLON.TransformNode|null} the transform node found or null if not found at all.
  1460. */
  1461. getTransformNodeByID(id: string): Nullable<TransformNode>;
  1462. getTransformNodesByID(id: string): Array<TransformNode>;
  1463. /**
  1464. * Get a mesh with its auto-generated unique id
  1465. * @param {number} uniqueId - the unique id to search for
  1466. * @return {BABYLON.AbstractMesh|null} the mesh found or null if not found at all.
  1467. */
  1468. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  1469. /**
  1470. * Get a the last added mesh found of a given ID
  1471. * @param {string} id - the id to search for
  1472. * @return {BABYLON.AbstractMesh|null} the mesh found or null if not found at all.
  1473. */
  1474. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  1475. /**
  1476. * Get a the last added node (Mesh, Camera, Light) found of a given ID
  1477. * @param {string} id - the id to search for
  1478. * @return {BABYLON.Node|null} the node found or null if not found at all.
  1479. */
  1480. getLastEntryByID(id: string): Nullable<Node>;
  1481. getNodeByID(id: string): Nullable<Node>;
  1482. getNodeByName(name: string): Nullable<Node>;
  1483. getMeshByName(name: string): Nullable<AbstractMesh>;
  1484. getTransformNodeByName(name: string): Nullable<TransformNode>;
  1485. getSoundByName(name: string): Nullable<Sound>;
  1486. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  1487. getSkeletonById(id: string): Nullable<Skeleton>;
  1488. getSkeletonByName(name: string): Nullable<Skeleton>;
  1489. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  1490. isActiveMesh(mesh: AbstractMesh): boolean;
  1491. /**
  1492. * Return a the first highlight layer of the scene with a given name.
  1493. * @param name The name of the highlight layer to look for.
  1494. * @return The highlight layer if found otherwise null.
  1495. */
  1496. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  1497. /**
  1498. * Return a the first highlight layer of the scene with a given name.
  1499. * @param name The name of the highlight layer to look for.
  1500. * @return The highlight layer if found otherwise null.
  1501. */
  1502. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  1503. /**
  1504. * Return a unique id as a string which can serve as an identifier for the scene
  1505. */
  1506. readonly uid: string;
  1507. /**
  1508. * Add an externaly attached data from its key.
  1509. * This method call will fail and return false, if such key already exists.
  1510. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  1511. * @param key the unique key that identifies the data
  1512. * @param data the data object to associate to the key for this Engine instance
  1513. * @return true if no such key were already present and the data was added successfully, false otherwise
  1514. */
  1515. addExternalData<T>(key: string, data: T): boolean;
  1516. /**
  1517. * Get an externaly attached data from its key
  1518. * @param key the unique key that identifies the data
  1519. * @return the associated data, if present (can be null), or undefined if not present
  1520. */
  1521. getExternalData<T>(key: string): Nullable<T>;
  1522. /**
  1523. * Get an externaly attached data from its key, create it using a factory if it's not already present
  1524. * @param key the unique key that identifies the data
  1525. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  1526. * @return the associated data, can be null if the factory returned null.
  1527. */
  1528. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  1529. /**
  1530. * Remove an externaly attached data from the Engine instance
  1531. * @param key the unique key that identifies the data
  1532. * @return true if the data was successfully removed, false if it doesn't exist
  1533. */
  1534. removeExternalData(key: string): boolean;
  1535. private _evaluateSubMesh(subMesh, mesh);
  1536. _isInIntermediateRendering(): boolean;
  1537. private _activeMeshCandidateProvider;
  1538. setActiveMeshCandidateProvider(provider: IActiveMeshCandidateProvider): void;
  1539. getActiveMeshCandidateProvider(): IActiveMeshCandidateProvider;
  1540. private _activeMeshesFrozen;
  1541. /**
  1542. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  1543. */
  1544. freezeActiveMeshes(): Scene;
  1545. /**
  1546. * Use this function to restart evaluating active meshes on every frame
  1547. */
  1548. unfreezeActiveMeshes(): this;
  1549. private _evaluateActiveMeshes();
  1550. private _activeMesh(sourceMesh, mesh);
  1551. updateTransformMatrix(force?: boolean): void;
  1552. updateAlternateTransformMatrix(alternateCamera: Camera): void;
  1553. private _renderForCamera(camera, rigParent?);
  1554. private _processSubCameras(camera);
  1555. private _checkIntersections();
  1556. render(): void;
  1557. private _updateAudioParameters();
  1558. audioEnabled: boolean;
  1559. private _disableAudio();
  1560. private _enableAudio();
  1561. headphone: boolean;
  1562. private _switchAudioModeForHeadphones();
  1563. private _switchAudioModeForNormalSpeakers();
  1564. /**
  1565. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  1566. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  1567. * @returns the created depth renderer
  1568. */
  1569. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  1570. /**
  1571. * Disables a depth renderer for a given camera
  1572. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  1573. */
  1574. disableDepthRenderer(camera?: Nullable<Camera>): void;
  1575. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  1576. disableGeometryBufferRenderer(): void;
  1577. freezeMaterials(): void;
  1578. unfreezeMaterials(): void;
  1579. dispose(): void;
  1580. readonly isDisposed: boolean;
  1581. disposeSounds(): void;
  1582. /**
  1583. * Get the world extend vectors with an optional filter
  1584. *
  1585. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  1586. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  1587. */
  1588. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  1589. min: Vector3;
  1590. max: Vector3;
  1591. };
  1592. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  1593. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  1594. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  1595. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  1596. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  1597. private _internalPick(rayFunction, predicate?, fastCheck?);
  1598. private _internalMultiPick(rayFunction, predicate?);
  1599. private _internalPickSprites(ray, predicate?, fastCheck?, camera?);
  1600. private _tempPickingRay;
  1601. /** Launch a ray to try to pick a mesh in the scene
  1602. * @param x position on screen
  1603. * @param y position on screen
  1604. * @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
  1605. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  1606. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  1607. */
  1608. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  1609. /** Launch a ray to try to pick a sprite in the scene
  1610. * @param x position on screen
  1611. * @param y position on screen
  1612. * @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
  1613. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  1614. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  1615. */
  1616. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  1617. private _cachedRayForTransform;
  1618. /** Use the given ray to pick a mesh in the scene
  1619. * @param ray The ray to use to pick meshes
  1620. * @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
  1621. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  1622. */
  1623. pickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  1624. /**
  1625. * Launch a ray to try to pick a mesh in the scene
  1626. * @param x X position on screen
  1627. * @param y Y position on screen
  1628. * @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
  1629. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  1630. */
  1631. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  1632. /**
  1633. * Launch a ray to try to pick a mesh in the scene
  1634. * @param ray Ray to use
  1635. * @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
  1636. */
  1637. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean): Nullable<PickingInfo[]>;
  1638. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  1639. getPointerOverMesh(): Nullable<AbstractMesh>;
  1640. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  1641. getPointerOverSprite(): Nullable<Sprite>;
  1642. getPhysicsEngine(): Nullable<PhysicsEngine>;
  1643. /**
  1644. * Enables physics to the current scene
  1645. * @param {BABYLON.Vector3} [gravity] - the scene's gravity for the physics engine
  1646. * @param {BABYLON.IPhysicsEnginePlugin} [plugin] - The physics engine to be used. defaults to OimoJS.
  1647. * @return {boolean} was the physics engine initialized
  1648. */
  1649. enablePhysics(gravity?: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  1650. disablePhysicsEngine(): void;
  1651. isPhysicsEnabled(): boolean;
  1652. deleteCompoundImpostor(compound: any): void;
  1653. _rebuildGeometries(): void;
  1654. _rebuildTextures(): void;
  1655. /**
  1656. * Creates a default light for the scene.
  1657. * @param replace Whether to replace the existing lights in the scene.
  1658. */
  1659. createDefaultLight(replace?: boolean): void;
  1660. /**
  1661. * Creates a default camera for the scene.
  1662. * @param createArcRotateCamera Whether to create an arc rotate or a free camera.
  1663. * @param replace Whether to replace the existing active camera in the scene.
  1664. * @param attachCameraControls Whether to attach camera controls to the canvas.
  1665. */
  1666. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  1667. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  1668. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number): Nullable<Mesh>;
  1669. createDefaultEnvironment(options: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  1670. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  1671. private _getByTags(list, tagsQuery, forEach?);
  1672. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  1673. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  1674. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  1675. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  1676. /**
  1677. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  1678. * This allowed control for front to back rendering or reversly depending of the special needs.
  1679. *
  1680. * @param renderingGroupId The rendering group id corresponding to its index
  1681. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  1682. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  1683. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  1684. */
  1685. 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;
  1686. /**
  1687. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  1688. *
  1689. * @param renderingGroupId The rendering group id corresponding to its index
  1690. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  1691. * @param depth Automatically clears depth between groups if true and autoClear is true.
  1692. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  1693. */
  1694. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  1695. /**
  1696. * Will flag all materials as dirty to trigger new shader compilation
  1697. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  1698. */
  1699. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  1700. _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;
  1701. /** @ignore */
  1702. _loadFileAsync(url: string, useDatabase?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  1703. }
  1704. }
  1705. declare module BABYLON {
  1706. type Nullable<T> = T | null;
  1707. type float = number;
  1708. type double = number;
  1709. type int = number;
  1710. type FloatArray = number[] | Float32Array;
  1711. type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  1712. }
  1713. declare module BABYLON {
  1714. class Action {
  1715. triggerOptions: any;
  1716. trigger: number;
  1717. _actionManager: ActionManager;
  1718. private _nextActiveAction;
  1719. private _child;
  1720. private _condition?;
  1721. private _triggerParameter;
  1722. onBeforeExecuteObservable: Observable<Action>;
  1723. constructor(triggerOptions: any, condition?: Condition);
  1724. _prepare(): void;
  1725. getTriggerParameter(): any;
  1726. _executeCurrent(evt?: ActionEvent): void;
  1727. execute(evt?: ActionEvent): void;
  1728. skipToNextActiveAction(): void;
  1729. then(action: Action): Action;
  1730. _getProperty(propertyPath: string): string;
  1731. _getEffectiveTarget(target: any, propertyPath: string): any;
  1732. serialize(parent: any): any;
  1733. protected _serialize(serializedAction: any, parent?: any): any;
  1734. static _SerializeValueAsString: (value: any) => string;
  1735. static _GetTargetProperty: (target: Scene | Node) => {
  1736. name: string;
  1737. targetType: string;
  1738. value: string;
  1739. };
  1740. }
  1741. }
  1742. declare module BABYLON {
  1743. /**
  1744. * ActionEvent is the event beint sent when an action is triggered.
  1745. */
  1746. class ActionEvent {
  1747. source: any;
  1748. pointerX: number;
  1749. pointerY: number;
  1750. meshUnderPointer: Nullable<AbstractMesh>;
  1751. sourceEvent: any;
  1752. additionalData: any;
  1753. /**
  1754. * @param source The mesh or sprite that triggered the action.
  1755. * @param pointerX The X mouse cursor position at the time of the event
  1756. * @param pointerY The Y mouse cursor position at the time of the event
  1757. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  1758. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  1759. */
  1760. constructor(source: any, pointerX: number, pointerY: number, meshUnderPointer: Nullable<AbstractMesh>, sourceEvent?: any, additionalData?: any);
  1761. /**
  1762. * Helper function to auto-create an ActionEvent from a source mesh.
  1763. * @param source The source mesh that triggered the event
  1764. * @param evt {Event} The original (browser) event
  1765. */
  1766. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  1767. /**
  1768. * Helper function to auto-create an ActionEvent from a source mesh.
  1769. * @param source The source sprite that triggered the event
  1770. * @param scene Scene associated with the sprite
  1771. * @param evt {Event} The original (browser) event
  1772. */
  1773. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  1774. /**
  1775. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  1776. * @param scene the scene where the event occurred
  1777. * @param evt {Event} The original (browser) event
  1778. */
  1779. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  1780. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  1781. }
  1782. /**
  1783. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  1784. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  1785. */
  1786. class ActionManager {
  1787. private static _NothingTrigger;
  1788. private static _OnPickTrigger;
  1789. private static _OnLeftPickTrigger;
  1790. private static _OnRightPickTrigger;
  1791. private static _OnCenterPickTrigger;
  1792. private static _OnPickDownTrigger;
  1793. private static _OnDoublePickTrigger;
  1794. private static _OnPickUpTrigger;
  1795. private static _OnLongPressTrigger;
  1796. private static _OnPointerOverTrigger;
  1797. private static _OnPointerOutTrigger;
  1798. private static _OnEveryFrameTrigger;
  1799. private static _OnIntersectionEnterTrigger;
  1800. private static _OnIntersectionExitTrigger;
  1801. private static _OnKeyDownTrigger;
  1802. private static _OnKeyUpTrigger;
  1803. private static _OnPickOutTrigger;
  1804. static readonly NothingTrigger: number;
  1805. static readonly OnPickTrigger: number;
  1806. static readonly OnLeftPickTrigger: number;
  1807. static readonly OnRightPickTrigger: number;
  1808. static readonly OnCenterPickTrigger: number;
  1809. static readonly OnPickDownTrigger: number;
  1810. static readonly OnDoublePickTrigger: number;
  1811. static readonly OnPickUpTrigger: number;
  1812. static readonly OnPickOutTrigger: number;
  1813. static readonly OnLongPressTrigger: number;
  1814. static readonly OnPointerOverTrigger: number;
  1815. static readonly OnPointerOutTrigger: number;
  1816. static readonly OnEveryFrameTrigger: number;
  1817. static readonly OnIntersectionEnterTrigger: number;
  1818. static readonly OnIntersectionExitTrigger: number;
  1819. static readonly OnKeyDownTrigger: number;
  1820. static readonly OnKeyUpTrigger: number;
  1821. static Triggers: {
  1822. [key: string]: number;
  1823. };
  1824. actions: Action[];
  1825. hoverCursor: string;
  1826. private _scene;
  1827. constructor(scene: Scene);
  1828. dispose(): void;
  1829. getScene(): Scene;
  1830. /**
  1831. * Does this action manager handles actions of any of the given triggers
  1832. * @param {number[]} triggers - the triggers to be tested
  1833. * @return {boolean} whether one (or more) of the triggers is handeled
  1834. */
  1835. hasSpecificTriggers(triggers: number[]): boolean;
  1836. /**
  1837. * Does this action manager handles actions of a given trigger
  1838. * @param {number} trigger - the trigger to be tested
  1839. * @return {boolean} whether the trigger is handeled
  1840. */
  1841. hasSpecificTrigger(trigger: number): boolean;
  1842. /**
  1843. * Does this action manager has pointer triggers
  1844. * @return {boolean} whether or not it has pointer triggers
  1845. */
  1846. readonly hasPointerTriggers: boolean;
  1847. /**
  1848. * Does this action manager has pick triggers
  1849. * @return {boolean} whether or not it has pick triggers
  1850. */
  1851. readonly hasPickTriggers: boolean;
  1852. /**
  1853. * Does exist one action manager with at least one trigger
  1854. * @return {boolean} whether or not it exists one action manager with one trigger
  1855. **/
  1856. static readonly HasTriggers: boolean;
  1857. /**
  1858. * Does exist one action manager with at least one pick trigger
  1859. * @return {boolean} whether or not it exists one action manager with one pick trigger
  1860. **/
  1861. static readonly HasPickTriggers: boolean;
  1862. /**
  1863. * Does exist one action manager that handles actions of a given trigger
  1864. * @param {number} trigger - the trigger to be tested
  1865. * @return {boolean} whether the trigger is handeled by at least one action manager
  1866. **/
  1867. static HasSpecificTrigger(trigger: number): boolean;
  1868. /**
  1869. * Registers an action to this action manager
  1870. * @param {BABYLON.Action} action - the action to be registered
  1871. * @return {BABYLON.Action} the action amended (prepared) after registration
  1872. */
  1873. registerAction(action: Action): Nullable<Action>;
  1874. /**
  1875. * Unregisters an action to this action manager
  1876. * @param action The action to be unregistered
  1877. * @return whether the action has been unregistered
  1878. */
  1879. unregisterAction(action: Action): Boolean;
  1880. /**
  1881. * Process a specific trigger
  1882. * @param {number} trigger - the trigger to process
  1883. * @param evt {BABYLON.ActionEvent} the event details to be processed
  1884. */
  1885. processTrigger(trigger: number, evt?: ActionEvent): void;
  1886. _getEffectiveTarget(target: any, propertyPath: string): any;
  1887. _getProperty(propertyPath: string): string;
  1888. serialize(name: string): any;
  1889. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  1890. static GetTriggerName(trigger: number): string;
  1891. }
  1892. }
  1893. declare module BABYLON {
  1894. class Condition {
  1895. _actionManager: ActionManager;
  1896. _evaluationId: number;
  1897. _currentResult: boolean;
  1898. constructor(actionManager: ActionManager);
  1899. isValid(): boolean;
  1900. _getProperty(propertyPath: string): string;
  1901. _getEffectiveTarget(target: any, propertyPath: string): any;
  1902. serialize(): any;
  1903. protected _serialize(serializedCondition: any): any;
  1904. }
  1905. class ValueCondition extends Condition {
  1906. propertyPath: string;
  1907. value: any;
  1908. operator: number;
  1909. private static _IsEqual;
  1910. private static _IsDifferent;
  1911. private static _IsGreater;
  1912. private static _IsLesser;
  1913. static readonly IsEqual: number;
  1914. static readonly IsDifferent: number;
  1915. static readonly IsGreater: number;
  1916. static readonly IsLesser: number;
  1917. _actionManager: ActionManager;
  1918. private _target;
  1919. private _effectiveTarget;
  1920. private _property;
  1921. constructor(actionManager: ActionManager, target: any, propertyPath: string, value: any, operator?: number);
  1922. isValid(): boolean;
  1923. serialize(): any;
  1924. static GetOperatorName(operator: number): string;
  1925. }
  1926. class PredicateCondition extends Condition {
  1927. predicate: () => boolean;
  1928. _actionManager: ActionManager;
  1929. constructor(actionManager: ActionManager, predicate: () => boolean);
  1930. isValid(): boolean;
  1931. }
  1932. class StateCondition extends Condition {
  1933. value: string;
  1934. _actionManager: ActionManager;
  1935. private _target;
  1936. constructor(actionManager: ActionManager, target: any, value: string);
  1937. isValid(): boolean;
  1938. serialize(): any;
  1939. }
  1940. }
  1941. declare module BABYLON {
  1942. class SwitchBooleanAction extends Action {
  1943. propertyPath: string;
  1944. private _target;
  1945. private _effectiveTarget;
  1946. private _property;
  1947. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  1948. _prepare(): void;
  1949. execute(): void;
  1950. serialize(parent: any): any;
  1951. }
  1952. class SetStateAction extends Action {
  1953. value: string;
  1954. private _target;
  1955. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  1956. execute(): void;
  1957. serialize(parent: any): any;
  1958. }
  1959. class SetValueAction extends Action {
  1960. propertyPath: string;
  1961. value: any;
  1962. private _target;
  1963. private _effectiveTarget;
  1964. private _property;
  1965. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  1966. _prepare(): void;
  1967. execute(): void;
  1968. serialize(parent: any): any;
  1969. }
  1970. class IncrementValueAction extends Action {
  1971. propertyPath: string;
  1972. value: any;
  1973. private _target;
  1974. private _effectiveTarget;
  1975. private _property;
  1976. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  1977. _prepare(): void;
  1978. execute(): void;
  1979. serialize(parent: any): any;
  1980. }
  1981. class PlayAnimationAction extends Action {
  1982. from: number;
  1983. to: number;
  1984. loop: boolean | undefined;
  1985. private _target;
  1986. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean | undefined, condition?: Condition);
  1987. _prepare(): void;
  1988. execute(): void;
  1989. serialize(parent: any): any;
  1990. }
  1991. class StopAnimationAction extends Action {
  1992. private _target;
  1993. constructor(triggerOptions: any, target: any, condition?: Condition);
  1994. _prepare(): void;
  1995. execute(): void;
  1996. serialize(parent: any): any;
  1997. }
  1998. class DoNothingAction extends Action {
  1999. constructor(triggerOptions?: any, condition?: Condition);
  2000. execute(): void;
  2001. serialize(parent: any): any;
  2002. }
  2003. class CombineAction extends Action {
  2004. children: Action[];
  2005. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  2006. _prepare(): void;
  2007. execute(evt: ActionEvent): void;
  2008. serialize(parent: any): any;
  2009. }
  2010. class ExecuteCodeAction extends Action {
  2011. func: (evt: ActionEvent) => void;
  2012. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  2013. execute(evt: ActionEvent): void;
  2014. }
  2015. class SetParentAction extends Action {
  2016. private _parent;
  2017. private _target;
  2018. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  2019. _prepare(): void;
  2020. execute(): void;
  2021. serialize(parent: any): any;
  2022. }
  2023. class PlaySoundAction extends Action {
  2024. private _sound;
  2025. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  2026. _prepare(): void;
  2027. execute(): void;
  2028. serialize(parent: any): any;
  2029. }
  2030. class StopSoundAction extends Action {
  2031. private _sound;
  2032. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  2033. _prepare(): void;
  2034. execute(): void;
  2035. serialize(parent: any): any;
  2036. }
  2037. }
  2038. declare module BABYLON {
  2039. class InterpolateValueAction extends Action {
  2040. propertyPath: string;
  2041. value: any;
  2042. duration: number;
  2043. stopOtherAnimations: boolean | undefined;
  2044. onInterpolationDone: (() => void) | undefined;
  2045. private _target;
  2046. private _effectiveTarget;
  2047. private _property;
  2048. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  2049. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean | undefined, onInterpolationDone?: (() => void) | undefined);
  2050. _prepare(): void;
  2051. execute(): void;
  2052. serialize(parent: any): any;
  2053. }
  2054. }
  2055. declare module BABYLON {
  2056. class Animatable {
  2057. target: any;
  2058. fromFrame: number;
  2059. toFrame: number;
  2060. loopAnimation: boolean;
  2061. onAnimationEnd: (() => void) | null | undefined;
  2062. private _localDelayOffset;
  2063. private _pausedDelay;
  2064. private _runtimeAnimations;
  2065. private _paused;
  2066. private _scene;
  2067. private _speedRatio;
  2068. animationStarted: boolean;
  2069. speedRatio: number;
  2070. constructor(scene: Scene, target: any, fromFrame?: number, toFrame?: number, loopAnimation?: boolean, speedRatio?: number, onAnimationEnd?: (() => void) | null | undefined, animations?: any);
  2071. getAnimations(): RuntimeAnimation[];
  2072. appendAnimations(target: any, animations: Animation[]): void;
  2073. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  2074. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  2075. reset(): void;
  2076. enableBlending(blendingSpeed: number): void;
  2077. disableBlending(): void;
  2078. goToFrame(frame: number): void;
  2079. pause(): void;
  2080. restart(): void;
  2081. stop(animationName?: string): void;
  2082. _animate(delay: number): boolean;
  2083. }
  2084. }
  2085. declare module BABYLON {
  2086. class AnimationRange {
  2087. name: string;
  2088. from: number;
  2089. to: number;
  2090. constructor(name: string, from: number, to: number);
  2091. clone(): AnimationRange;
  2092. }
  2093. /**
  2094. * Composed of a frame, and an action function
  2095. */
  2096. class AnimationEvent {
  2097. frame: number;
  2098. action: () => void;
  2099. onlyOnce: boolean | undefined;
  2100. isDone: boolean;
  2101. constructor(frame: number, action: () => void, onlyOnce?: boolean | undefined);
  2102. }
  2103. class PathCursor {
  2104. private path;
  2105. private _onchange;
  2106. value: number;
  2107. animations: Animation[];
  2108. constructor(path: Path2);
  2109. getPoint(): Vector3;
  2110. moveAhead(step?: number): PathCursor;
  2111. moveBack(step?: number): PathCursor;
  2112. move(step: number): PathCursor;
  2113. private ensureLimits();
  2114. private raiseOnChange();
  2115. onchange(f: (cursor: PathCursor) => void): PathCursor;
  2116. }
  2117. interface IAnimationKey {
  2118. frame: number;
  2119. value: any;
  2120. inTangent?: any;
  2121. outTangent?: any;
  2122. interpolation?: AnimationKeyInterpolation;
  2123. }
  2124. enum AnimationKeyInterpolation {
  2125. /**
  2126. * Do not interpolate between keys and use the start key value only. Tangents are ignored.
  2127. */
  2128. STEP = 1,
  2129. }
  2130. class Animation {
  2131. name: string;
  2132. targetProperty: string;
  2133. framePerSecond: number;
  2134. dataType: number;
  2135. loopMode: number | undefined;
  2136. enableBlending: boolean | undefined;
  2137. static AllowMatricesInterpolation: boolean;
  2138. private _keys;
  2139. private _easingFunction;
  2140. _runtimeAnimations: RuntimeAnimation[];
  2141. private _events;
  2142. targetPropertyPath: string[];
  2143. blendingSpeed: number;
  2144. private _ranges;
  2145. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  2146. /**
  2147. * Sets up an animation.
  2148. * @param property the property to animate
  2149. * @param animationType the animation type to apply
  2150. * @param easingFunction the easing function used in the animation
  2151. * @returns The created animation
  2152. */
  2153. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  2154. /**
  2155. * Create and start an animation on a node
  2156. * @param {string} name defines the name of the global animation that will be run on all nodes
  2157. * @param {BABYLON.Node} node defines the root node where the animation will take place
  2158. * @param {string} targetProperty defines property to animate
  2159. * @param {number} framePerSecond defines the number of frame per second yo use
  2160. * @param {number} totalFrame defines the number of frames in total
  2161. * @param {any} from defines the initial value
  2162. * @param {any} to defines the final value
  2163. * @param {number} loopMode defines which loop mode you want to use (off by default)
  2164. * @param {BABYLON.EasingFunction} easingFunction defines the easing function to use (linear by default)
  2165. * @param onAnimationEnd defines the callback to call when animation end
  2166. * @returns the animatable created for this animation
  2167. */
  2168. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  2169. /**
  2170. * Create and start an animation on a node and its descendants
  2171. * @param {string} name defines the name of the global animation that will be run on all nodes
  2172. * @param {BABYLON.Node} node defines the root node where the animation will take place
  2173. * @param {boolean} 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.
  2174. * @param {string} targetProperty defines property to animate
  2175. * @param {number} framePerSecond defines the number of frame per second yo use
  2176. * @param {number} totalFrame defines the number of frames in total
  2177. * @param {any} from defines the initial value
  2178. * @param {any} to defines the final value
  2179. * @param {number} loopMode defines which loop mode you want to use (off by default)
  2180. * @param {BABYLON.EasingFunction} easingFunction defines the easing function to use (linear by default)
  2181. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  2182. * @returns the list of animatables created for all nodes
  2183. * @example https://www.babylonjs-playground.com/#MH0VLI
  2184. */
  2185. 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[]>;
  2186. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  2187. /**
  2188. * Transition property of the Camera to the target Value.
  2189. * @param property The property to transition
  2190. * @param targetValue The target Value of the property
  2191. * @param host The object where the property to animate belongs
  2192. * @param scene Scene used to run the animation
  2193. * @param frameRate Framerate (in frame/s) to use
  2194. * @param transition The transition type we want to use
  2195. * @param duration The duration of the animation, in milliseconds
  2196. * @param onAnimationEnd Call back trigger at the end of the animation.
  2197. */
  2198. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  2199. /**
  2200. * Return the array of runtime animations currently using this animation
  2201. */
  2202. readonly runtimeAnimations: RuntimeAnimation[];
  2203. readonly hasRunningRuntimeAnimations: boolean;
  2204. constructor(name: string, targetProperty: string, framePerSecond: number, dataType: number, loopMode?: number | undefined, enableBlending?: boolean | undefined);
  2205. /**
  2206. * @param {boolean} fullDetails - support for multiple levels of logging within scene loading
  2207. */
  2208. toString(fullDetails?: boolean): string;
  2209. /**
  2210. * Add an event to this animation.
  2211. */
  2212. addEvent(event: AnimationEvent): void;
  2213. /**
  2214. * Remove all events found at the given frame
  2215. * @param frame
  2216. */
  2217. removeEvents(frame: number): void;
  2218. getEvents(): AnimationEvent[];
  2219. createRange(name: string, from: number, to: number): void;
  2220. deleteRange(name: string, deleteFrames?: boolean): void;
  2221. getRange(name: string): Nullable<AnimationRange>;
  2222. getKeys(): Array<IAnimationKey>;
  2223. getHighestFrame(): number;
  2224. getEasingFunction(): IEasingFunction;
  2225. setEasingFunction(easingFunction: EasingFunction): void;
  2226. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  2227. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  2228. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  2229. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  2230. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  2231. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  2232. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  2233. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  2234. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  2235. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  2236. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number): Matrix;
  2237. clone(): Animation;
  2238. setKeys(values: Array<IAnimationKey>): void;
  2239. serialize(): any;
  2240. private static _ANIMATIONTYPE_FLOAT;
  2241. private static _ANIMATIONTYPE_VECTOR3;
  2242. private static _ANIMATIONTYPE_QUATERNION;
  2243. private static _ANIMATIONTYPE_MATRIX;
  2244. private static _ANIMATIONTYPE_COLOR3;
  2245. private static _ANIMATIONTYPE_VECTOR2;
  2246. private static _ANIMATIONTYPE_SIZE;
  2247. private static _ANIMATIONLOOPMODE_RELATIVE;
  2248. private static _ANIMATIONLOOPMODE_CYCLE;
  2249. private static _ANIMATIONLOOPMODE_CONSTANT;
  2250. static readonly ANIMATIONTYPE_FLOAT: number;
  2251. static readonly ANIMATIONTYPE_VECTOR3: number;
  2252. static readonly ANIMATIONTYPE_VECTOR2: number;
  2253. static readonly ANIMATIONTYPE_SIZE: number;
  2254. static readonly ANIMATIONTYPE_QUATERNION: number;
  2255. static readonly ANIMATIONTYPE_MATRIX: number;
  2256. static readonly ANIMATIONTYPE_COLOR3: number;
  2257. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  2258. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  2259. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  2260. static Parse(parsedAnimation: any): Animation;
  2261. static AppendSerializedAnimations(source: IAnimatable, destination: any): any;
  2262. }
  2263. }
  2264. declare module BABYLON {
  2265. /**
  2266. * This class defines the direct association between an animation and a target
  2267. */
  2268. class TargetedAnimation {
  2269. animation: Animation;
  2270. target: any;
  2271. }
  2272. /**
  2273. * Use this class to create coordinated animations on multiple targets
  2274. */
  2275. class AnimationGroup implements IDisposable {
  2276. name: string;
  2277. private _scene;
  2278. private _targetedAnimations;
  2279. private _animatables;
  2280. private _from;
  2281. private _to;
  2282. private _isStarted;
  2283. private _speedRatio;
  2284. onAnimationEndObservable: Observable<TargetedAnimation>;
  2285. /**
  2286. * Define if the animations are started
  2287. */
  2288. readonly isStarted: boolean;
  2289. /**
  2290. * Gets or sets the speed ratio to use for all animations
  2291. */
  2292. /**
  2293. * Gets or sets the speed ratio to use for all animations
  2294. */
  2295. speedRatio: number;
  2296. /**
  2297. * Gets the targeted animations for this animation group
  2298. */
  2299. readonly targetedAnimations: Array<TargetedAnimation>;
  2300. constructor(name: string, scene?: Nullable<Scene>);
  2301. /**
  2302. * Add an animation (with its target) in the group
  2303. * @param animation defines the animation we want to add
  2304. * @param target defines the target of the animation
  2305. * @returns the {BABYLON.TargetedAnimation} object
  2306. */
  2307. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  2308. /**
  2309. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  2310. * It can add constant keys at begin or end
  2311. * @param beginFrame defines the new begin frame for all animations. It can't be bigger than the smallest begin frame of all animations
  2312. * @param endFrame defines the new end frame for all animations. It can't be smaller than the largest end frame of all animations
  2313. */
  2314. normalize(beginFrame?: number, endFrame?: number): AnimationGroup;
  2315. /**
  2316. * Start all animations on given targets
  2317. * @param loop defines if animations must loop
  2318. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  2319. */
  2320. start(loop?: boolean, speedRatio?: number): AnimationGroup;
  2321. /**
  2322. * Pause all animations
  2323. */
  2324. pause(): AnimationGroup;
  2325. /**
  2326. * Play all animations to initial state
  2327. * This function will start() the animations if they were not started or will restart() them if they were paused
  2328. * @param loop defines if animations must loop
  2329. */
  2330. play(loop?: boolean): AnimationGroup;
  2331. /**
  2332. * Reset all animations to initial state
  2333. */
  2334. reset(): AnimationGroup;
  2335. /**
  2336. * Restart animations from key 0
  2337. */
  2338. restart(): AnimationGroup;
  2339. /**
  2340. * Stop all animations
  2341. */
  2342. stop(): AnimationGroup;
  2343. /**
  2344. * Dispose all associated resources
  2345. */
  2346. dispose(): void;
  2347. }
  2348. }
  2349. declare module BABYLON {
  2350. interface IEasingFunction {
  2351. ease(gradient: number): number;
  2352. }
  2353. class EasingFunction implements IEasingFunction {
  2354. private static _EASINGMODE_EASEIN;
  2355. private static _EASINGMODE_EASEOUT;
  2356. private static _EASINGMODE_EASEINOUT;
  2357. static readonly EASINGMODE_EASEIN: number;
  2358. static readonly EASINGMODE_EASEOUT: number;
  2359. static readonly EASINGMODE_EASEINOUT: number;
  2360. private _easingMode;
  2361. setEasingMode(easingMode: number): void;
  2362. getEasingMode(): number;
  2363. easeInCore(gradient: number): number;
  2364. ease(gradient: number): number;
  2365. }
  2366. class CircleEase extends EasingFunction implements IEasingFunction {
  2367. easeInCore(gradient: number): number;
  2368. }
  2369. class BackEase extends EasingFunction implements IEasingFunction {
  2370. amplitude: number;
  2371. constructor(amplitude?: number);
  2372. easeInCore(gradient: number): number;
  2373. }
  2374. class BounceEase extends EasingFunction implements IEasingFunction {
  2375. bounces: number;
  2376. bounciness: number;
  2377. constructor(bounces?: number, bounciness?: number);
  2378. easeInCore(gradient: number): number;
  2379. }
  2380. class CubicEase extends EasingFunction implements IEasingFunction {
  2381. easeInCore(gradient: number): number;
  2382. }
  2383. class ElasticEase extends EasingFunction implements IEasingFunction {
  2384. oscillations: number;
  2385. springiness: number;
  2386. constructor(oscillations?: number, springiness?: number);
  2387. easeInCore(gradient: number): number;
  2388. }
  2389. class ExponentialEase extends EasingFunction implements IEasingFunction {
  2390. exponent: number;
  2391. constructor(exponent?: number);
  2392. easeInCore(gradient: number): number;
  2393. }
  2394. class PowerEase extends EasingFunction implements IEasingFunction {
  2395. power: number;
  2396. constructor(power?: number);
  2397. easeInCore(gradient: number): number;
  2398. }
  2399. class QuadraticEase extends EasingFunction implements IEasingFunction {
  2400. easeInCore(gradient: number): number;
  2401. }
  2402. class QuarticEase extends EasingFunction implements IEasingFunction {
  2403. easeInCore(gradient: number): number;
  2404. }
  2405. class QuinticEase extends EasingFunction implements IEasingFunction {
  2406. easeInCore(gradient: number): number;
  2407. }
  2408. class SineEase extends EasingFunction implements IEasingFunction {
  2409. easeInCore(gradient: number): number;
  2410. }
  2411. class BezierCurveEase extends EasingFunction implements IEasingFunction {
  2412. x1: number;
  2413. y1: number;
  2414. x2: number;
  2415. y2: number;
  2416. constructor(x1?: number, y1?: number, x2?: number, y2?: number);
  2417. easeInCore(gradient: number): number;
  2418. }
  2419. }
  2420. declare module BABYLON {
  2421. class RuntimeAnimation {
  2422. currentFrame: number;
  2423. private _animation;
  2424. private _target;
  2425. private _originalBlendValue;
  2426. private _offsetsCache;
  2427. private _highLimitsCache;
  2428. private _stopped;
  2429. private _blendingFactor;
  2430. constructor(target: any, animation: Animation);
  2431. readonly animation: Animation;
  2432. reset(): void;
  2433. isStopped(): boolean;
  2434. dispose(): void;
  2435. private _getKeyValue(value);
  2436. private _interpolate(currentFrame, repeatCount, loopMode?, offsetValue?, highLimitValue?);
  2437. setValue(currentValue: any, blend?: boolean): void;
  2438. goToFrame(frame: number): void;
  2439. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  2440. private _ratioOffset;
  2441. private _previousDelay;
  2442. private _previousRatio;
  2443. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, blend?: boolean): boolean;
  2444. }
  2445. }
  2446. declare module BABYLON {
  2447. class Analyser {
  2448. SMOOTHING: number;
  2449. FFT_SIZE: number;
  2450. BARGRAPHAMPLITUDE: number;
  2451. DEBUGCANVASPOS: {
  2452. x: number;
  2453. y: number;
  2454. };
  2455. DEBUGCANVASSIZE: {
  2456. width: number;
  2457. height: number;
  2458. };
  2459. private _byteFreqs;
  2460. private _byteTime;
  2461. private _floatFreqs;
  2462. private _webAudioAnalyser;
  2463. private _debugCanvas;
  2464. private _debugCanvasContext;
  2465. private _scene;
  2466. private _registerFunc;
  2467. private _audioEngine;
  2468. constructor(scene: Scene);
  2469. getFrequencyBinCount(): number;
  2470. getByteFrequencyData(): Uint8Array;
  2471. getByteTimeDomainData(): Uint8Array;
  2472. getFloatFrequencyData(): Uint8Array;
  2473. drawDebugCanvas(): void;
  2474. stopDebugCanvas(): void;
  2475. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  2476. dispose(): void;
  2477. }
  2478. }
  2479. declare module BABYLON {
  2480. class AudioEngine {
  2481. private _audioContext;
  2482. private _audioContextInitialized;
  2483. canUseWebAudio: boolean;
  2484. masterGain: GainNode;
  2485. private _connectedAnalyser;
  2486. WarnedWebAudioUnsupported: boolean;
  2487. unlocked: boolean;
  2488. onAudioUnlocked: () => any;
  2489. isMP3supported: boolean;
  2490. isOGGsupported: boolean;
  2491. readonly audioContext: Nullable<AudioContext>;
  2492. constructor();
  2493. private _unlockiOSaudio();
  2494. private _initializeAudioContext();
  2495. dispose(): void;
  2496. getGlobalVolume(): number;
  2497. setGlobalVolume(newVolume: number): void;
  2498. connectToAnalyser(analyser: Analyser): void;
  2499. }
  2500. }
  2501. declare module BABYLON {
  2502. class Sound {
  2503. name: string;
  2504. autoplay: boolean;
  2505. loop: boolean;
  2506. useCustomAttenuation: boolean;
  2507. soundTrackId: number;
  2508. spatialSound: boolean;
  2509. refDistance: number;
  2510. rolloffFactor: number;
  2511. maxDistance: number;
  2512. distanceModel: string;
  2513. private _panningModel;
  2514. onended: () => any;
  2515. private _playbackRate;
  2516. private _streaming;
  2517. private _startTime;
  2518. private _startOffset;
  2519. private _position;
  2520. private _localDirection;
  2521. private _volume;
  2522. private _isReadyToPlay;
  2523. isPlaying: boolean;
  2524. isPaused: boolean;
  2525. private _isDirectional;
  2526. private _readyToPlayCallback;
  2527. private _audioBuffer;
  2528. private _soundSource;
  2529. private _streamingSource;
  2530. private _soundPanner;
  2531. private _soundGain;
  2532. private _inputAudioNode;
  2533. private _ouputAudioNode;
  2534. private _coneInnerAngle;
  2535. private _coneOuterAngle;
  2536. private _coneOuterGain;
  2537. private _scene;
  2538. private _connectedMesh;
  2539. private _customAttenuationFunction;
  2540. private _registerFunc;
  2541. private _isOutputConnected;
  2542. private _htmlAudioElement;
  2543. private _urlType;
  2544. /**
  2545. * Create a sound and attach it to a scene
  2546. * @param name Name of your sound
  2547. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer
  2548. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  2549. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  2550. */
  2551. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: any);
  2552. dispose(): void;
  2553. isReady(): boolean;
  2554. private _soundLoaded(audioData);
  2555. setAudioBuffer(audioBuffer: AudioBuffer): void;
  2556. updateOptions(options: any): void;
  2557. private _createSpatialParameters();
  2558. private _updateSpatialParameters();
  2559. switchPanningModelToHRTF(): void;
  2560. switchPanningModelToEqualPower(): void;
  2561. private _switchPanningModel();
  2562. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  2563. /**
  2564. * Transform this sound into a directional source
  2565. * @param coneInnerAngle Size of the inner cone in degree
  2566. * @param coneOuterAngle Size of the outer cone in degree
  2567. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  2568. */
  2569. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  2570. setPosition(newPosition: Vector3): void;
  2571. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  2572. private _updateDirection();
  2573. updateDistanceFromListener(): void;
  2574. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  2575. /**
  2576. * Play the sound
  2577. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  2578. * @param offset (optional) Start the sound setting it at a specific time
  2579. */
  2580. play(time?: number, offset?: number): void;
  2581. private _onended();
  2582. /**
  2583. * Stop the sound
  2584. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  2585. */
  2586. stop(time?: number): void;
  2587. pause(): void;
  2588. setVolume(newVolume: number, time?: number): void;
  2589. setPlaybackRate(newPlaybackRate: number): void;
  2590. getVolume(): number;
  2591. attachToMesh(meshToConnectTo: AbstractMesh): void;
  2592. detachFromMesh(): void;
  2593. private _onRegisterAfterWorldMatrixUpdate(node);
  2594. clone(): Nullable<Sound>;
  2595. getAudioBuffer(): AudioBuffer | null;
  2596. serialize(): any;
  2597. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  2598. }
  2599. }
  2600. declare module BABYLON {
  2601. class SoundTrack {
  2602. private _outputAudioNode;
  2603. private _scene;
  2604. id: number;
  2605. soundCollection: Array<Sound>;
  2606. private _isMainTrack;
  2607. private _connectedAnalyser;
  2608. private _options;
  2609. private _isInitialized;
  2610. constructor(scene: Scene, options?: any);
  2611. private _initializeSoundTrackAudioGraph();
  2612. dispose(): void;
  2613. AddSound(sound: Sound): void;
  2614. RemoveSound(sound: Sound): void;
  2615. setVolume(newVolume: number): void;
  2616. switchPanningModelToHRTF(): void;
  2617. switchPanningModelToEqualPower(): void;
  2618. connectToAnalyser(analyser: Analyser): void;
  2619. }
  2620. }
  2621. declare module BABYLON {
  2622. class Bone extends Node {
  2623. name: string;
  2624. private static _tmpVecs;
  2625. private static _tmpQuat;
  2626. private static _tmpMats;
  2627. children: Bone[];
  2628. animations: Animation[];
  2629. length: number;
  2630. _index: Nullable<number>;
  2631. private _skeleton;
  2632. private _localMatrix;
  2633. private _restPose;
  2634. private _baseMatrix;
  2635. private _worldTransform;
  2636. private _absoluteTransform;
  2637. private _invertedAbsoluteTransform;
  2638. private _parent;
  2639. private _scaleMatrix;
  2640. private _scaleVector;
  2641. private _negateScaleChildren;
  2642. private _scalingDeterminant;
  2643. _matrix: Matrix;
  2644. constructor(name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  2645. getSkeleton(): Skeleton;
  2646. getParent(): Nullable<Bone>;
  2647. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  2648. getLocalMatrix(): Matrix;
  2649. getBaseMatrix(): Matrix;
  2650. getRestPose(): Matrix;
  2651. returnToRest(): void;
  2652. getWorldMatrix(): Matrix;
  2653. getInvertedAbsoluteTransform(): Matrix;
  2654. getAbsoluteTransform(): Matrix;
  2655. position: Vector3;
  2656. rotation: Vector3;
  2657. rotationQuaternion: Quaternion;
  2658. scaling: Vector3;
  2659. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean): void;
  2660. _updateDifferenceMatrix(rootMatrix?: Matrix): void;
  2661. markAsDirty(): void;
  2662. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired?: boolean, skelDimensionsRatio?: Nullable<Vector3>): boolean;
  2663. /**
  2664. * Translate the bone in local or world space.
  2665. * @param vec The amount to translate the bone.
  2666. * @param space The space that the translation is in.
  2667. * @param mesh The mesh that this bone is attached to. This is only used in world space.
  2668. */
  2669. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  2670. /**
  2671. * Set the postion of the bone in local or world space.
  2672. * @param position The position to set the bone.
  2673. * @param space The space that the position is in.
  2674. * @param mesh The mesh that this bone is attached to. This is only used in world space.
  2675. */
  2676. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  2677. /**
  2678. * Set the absolute postion of the bone (world space).
  2679. * @param position The position to set the bone.
  2680. * @param mesh The mesh that this bone is attached to.
  2681. */
  2682. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  2683. /**
  2684. * Set the scale of the bone on the x, y and z axes.
  2685. * @param x The scale of the bone on the x axis.
  2686. * @param x The scale of the bone on the y axis.
  2687. * @param z The scale of the bone on the z axis.
  2688. * @param scaleChildren Set this to true if children of the bone should be scaled.
  2689. */
  2690. setScale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  2691. /**
  2692. * Scale the bone on the x, y and z axes.
  2693. * @param x The amount to scale the bone on the x axis.
  2694. * @param x The amount to scale the bone on the y axis.
  2695. * @param z The amount to scale the bone on the z axis.
  2696. * @param scaleChildren Set this to true if children of the bone should be scaled.
  2697. */
  2698. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  2699. /**
  2700. * Set the yaw, pitch, and roll of the bone in local or world space.
  2701. * @param yaw The rotation of the bone on the y axis.
  2702. * @param pitch The rotation of the bone on the x axis.
  2703. * @param roll The rotation of the bone on the z axis.
  2704. * @param space The space that the axes of rotation are in.
  2705. * @param mesh The mesh that this bone is attached to. This is only used in world space.
  2706. */
  2707. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  2708. /**
  2709. * Rotate the bone on an axis in local or world space.
  2710. * @param axis The axis to rotate the bone on.
  2711. * @param amount The amount to rotate the bone.
  2712. * @param space The space that the axis is in.
  2713. * @param mesh The mesh that this bone is attached to. This is only used in world space.
  2714. */
  2715. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  2716. /**
  2717. * Set the rotation of the bone to a particular axis angle in local or world space.
  2718. * @param axis The axis to rotate the bone on.
  2719. * @param angle The angle that the bone should be rotated to.
  2720. * @param space The space that the axis is in.
  2721. * @param mesh The mesh that this bone is attached to. This is only used in world space.
  2722. */
  2723. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  2724. /**
  2725. * Set the euler rotation of the bone in local of world space.
  2726. * @param rotation The euler rotation that the bone should be set to.
  2727. * @param space The space that the rotation is in.
  2728. * @param mesh The mesh that this bone is attached to. This is only used in world space.
  2729. */
  2730. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  2731. /**
  2732. * Set the quaternion rotation of the bone in local of world space.
  2733. * @param quat The quaternion rotation that the bone should be set to.
  2734. * @param space The space that the rotation is in.
  2735. * @param mesh The mesh that this bone is attached to. This is only used in world space.
  2736. */
  2737. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  2738. /**
  2739. * Set the rotation matrix of the bone in local of world space.
  2740. * @param rotMat The rotation matrix that the bone should be set to.
  2741. * @param space The space that the rotation is in.
  2742. * @param mesh The mesh that this bone is attached to. This is only used in world space.
  2743. */
  2744. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  2745. private _rotateWithMatrix(rmat, space?, mesh?);
  2746. private _getNegativeRotationToRef(rotMatInv, space?, mesh?);
  2747. /**
  2748. * Get the scale of the bone
  2749. * @returns the scale of the bone
  2750. */
  2751. getScale(): Vector3;
  2752. /**
  2753. * Copy the scale of the bone to a vector3.
  2754. * @param result The vector3 to copy the scale to
  2755. */
  2756. getScaleToRef(result: Vector3): void;
  2757. /**
  2758. * Get the position of the bone in local or world space.
  2759. * @param space The space that the returned position is in.
  2760. * @param mesh The mesh that this bone is attached to. This is only used in world space.
  2761. * @returns The position of the bone
  2762. */
  2763. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  2764. /**
  2765. * Copy the position of the bone to a vector3 in local or world space.
  2766. * @param space The space that the returned position is in.
  2767. * @param mesh The mesh that this bone is attached to. This is only used in world space.
  2768. * @param result The vector3 to copy the position to.
  2769. */
  2770. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  2771. /**
  2772. * Get the absolute position of the bone (world space).
  2773. * @param mesh The mesh that this bone is attached to.
  2774. * @returns The absolute position of the bone
  2775. */
  2776. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  2777. /**
  2778. * Copy the absolute position of the bone (world space) to the result param.
  2779. * @param mesh The mesh that this bone is attached to.
  2780. * @param result The vector3 to copy the absolute position to.
  2781. */
  2782. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  2783. /**
  2784. * Compute the absolute transforms of this bone and its children.
  2785. */
  2786. computeAbsoluteTransforms(): void;
  2787. private _syncScaleVector();
  2788. /**
  2789. * Get the world direction from an axis that is in the local space of the bone.
  2790. * @param localAxis The local direction that is used to compute the world direction.
  2791. * @param mesh The mesh that this bone is attached to.
  2792. * @returns The world direction
  2793. */
  2794. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  2795. /**
  2796. * Copy the world direction to a vector3 from an axis that is in the local space of the bone.
  2797. * @param localAxis The local direction that is used to compute the world direction.
  2798. * @param mesh The mesh that this bone is attached to.
  2799. * @param result The vector3 that the world direction will be copied to.
  2800. */
  2801. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  2802. /**
  2803. * Get the euler rotation of the bone in local or world space.
  2804. * @param space The space that the rotation should be in.
  2805. * @param mesh The mesh that this bone is attached to. This is only used in world space.
  2806. * @returns The euler rotation
  2807. */
  2808. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  2809. /**
  2810. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space.
  2811. * @param space The space that the rotation should be in.
  2812. * @param mesh The mesh that this bone is attached to. This is only used in world space.
  2813. * @param result The vector3 that the rotation should be copied to.
  2814. */
  2815. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  2816. /**
  2817. * Get the quaternion rotation of the bone in either local or world space.
  2818. * @param space The space that the rotation should be in.
  2819. * @param mesh The mesh that this bone is attached to. This is only used in world space.
  2820. * @returns The quaternion rotation
  2821. */
  2822. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  2823. /**
  2824. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space.
  2825. * @param space The space that the rotation should be in.
  2826. * @param mesh The mesh that this bone is attached to. This is only used in world space.
  2827. * @param result The quaternion that the rotation should be copied to.
  2828. */
  2829. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  2830. /**
  2831. * Get the rotation matrix of the bone in local or world space.
  2832. * @param space The space that the rotation should be in.
  2833. * @param mesh The mesh that this bone is attached to. This is only used in world space.
  2834. * @returns The rotation matrix
  2835. */
  2836. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  2837. /**
  2838. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space.
  2839. * @param space The space that the rotation should be in.
  2840. * @param mesh The mesh that this bone is attached to. This is only used in world space.
  2841. * @param result The quaternion that the rotation should be copied to.
  2842. */
  2843. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  2844. /**
  2845. * Get the world position of a point that is in the local space of the bone.
  2846. * @param position The local position
  2847. * @param mesh The mesh that this bone is attached to.
  2848. * @returns The world position
  2849. */
  2850. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  2851. /**
  2852. * Get the world position of a point that is in the local space of the bone and copy it to the result param.
  2853. * @param position The local position
  2854. * @param mesh The mesh that this bone is attached to.
  2855. * @param result The vector3 that the world position should be copied to.
  2856. */
  2857. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  2858. /**
  2859. * Get the local position of a point that is in world space.
  2860. * @param position The world position
  2861. * @param mesh The mesh that this bone is attached to.
  2862. * @returns The local position
  2863. */
  2864. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  2865. /**
  2866. * Get the local position of a point that is in world space and copy it to the result param.
  2867. * @param position The world position
  2868. * @param mesh The mesh that this bone is attached to.
  2869. * @param result The vector3 that the local position should be copied to.
  2870. */
  2871. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  2872. }
  2873. }
  2874. declare module BABYLON {
  2875. class BoneIKController {
  2876. private static _tmpVecs;
  2877. private static _tmpQuat;
  2878. private static _tmpMats;
  2879. targetMesh: AbstractMesh;
  2880. poleTargetMesh: AbstractMesh;
  2881. poleTargetBone: Nullable<Bone>;
  2882. targetPosition: Vector3;
  2883. poleTargetPosition: Vector3;
  2884. poleTargetLocalOffset: Vector3;
  2885. poleAngle: number;
  2886. mesh: AbstractMesh;
  2887. slerpAmount: number;
  2888. private _bone1Quat;
  2889. private _bone1Mat;
  2890. private _bone2Ang;
  2891. private _bone1;
  2892. private _bone2;
  2893. private _bone1Length;
  2894. private _bone2Length;
  2895. private _maxAngle;
  2896. private _maxReach;
  2897. private _rightHandedSystem;
  2898. private _bendAxis;
  2899. private _slerping;
  2900. private _adjustRoll;
  2901. maxAngle: number;
  2902. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  2903. targetMesh?: AbstractMesh;
  2904. poleTargetMesh?: AbstractMesh;
  2905. poleTargetBone?: Bone;
  2906. poleTargetLocalOffset?: Vector3;
  2907. poleAngle?: number;
  2908. bendAxis?: Vector3;
  2909. maxAngle?: number;
  2910. slerpAmount?: number;
  2911. });
  2912. private _setMaxAngle(ang);
  2913. update(): void;
  2914. }
  2915. }
  2916. declare module BABYLON {
  2917. class BoneLookController {
  2918. private static _tmpVecs;
  2919. private static _tmpQuat;
  2920. private static _tmpMats;
  2921. /**
  2922. * The target Vector3 that the bone will look at.
  2923. */
  2924. target: Vector3;
  2925. /**
  2926. * The mesh that the bone is attached to.
  2927. */
  2928. mesh: AbstractMesh;
  2929. /**
  2930. * The bone that will be looking to the target.
  2931. */
  2932. bone: Bone;
  2933. /**
  2934. * The up axis of the coordinate system that is used when the bone is rotated.
  2935. */
  2936. upAxis: Vector3;
  2937. /**
  2938. * The space that the up axis is in - BABYLON.Space.BONE, BABYLON.Space.LOCAL (default), or BABYLON.Space.WORLD.
  2939. */
  2940. upAxisSpace: Space;
  2941. /**
  2942. * Used to make an adjustment to the yaw of the bone.
  2943. */
  2944. adjustYaw: number;
  2945. /**
  2946. * Used to make an adjustment to the pitch of the bone.
  2947. */
  2948. adjustPitch: number;
  2949. /**
  2950. * Used to make an adjustment to the roll of the bone.
  2951. */
  2952. adjustRoll: number;
  2953. /**
  2954. * 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).
  2955. */
  2956. slerpAmount: number;
  2957. private _minYaw;
  2958. private _maxYaw;
  2959. private _minPitch;
  2960. private _maxPitch;
  2961. private _minYawSin;
  2962. private _minYawCos;
  2963. private _maxYawSin;
  2964. private _maxYawCos;
  2965. private _midYawConstraint;
  2966. private _minPitchTan;
  2967. private _maxPitchTan;
  2968. private _boneQuat;
  2969. private _slerping;
  2970. private _transformYawPitch;
  2971. private _transformYawPitchInv;
  2972. private _firstFrameSkipped;
  2973. private _yawRange;
  2974. private _fowardAxis;
  2975. /**
  2976. * Get/set the minimum yaw angle that the bone can look to.
  2977. */
  2978. minYaw: number;
  2979. /**
  2980. * Get/set the maximum yaw angle that the bone can look to.
  2981. */
  2982. maxYaw: number;
  2983. /**
  2984. * Get/set the minimum pitch angle that the bone can look to.
  2985. */
  2986. minPitch: number;
  2987. /**
  2988. * Get/set the maximum pitch angle that the bone can look to.
  2989. */
  2990. maxPitch: number;
  2991. /**
  2992. * Create a BoneLookController
  2993. * @param mesh the mesh that the bone belongs to
  2994. * @param bone the bone that will be looking to the target
  2995. * @param target the target Vector3 to look at
  2996. * @param settings optional settings:
  2997. * - maxYaw: the maximum angle the bone will yaw to
  2998. * - minYaw: the minimum angle the bone will yaw to
  2999. * - maxPitch: the maximum angle the bone will pitch to
  3000. * - minPitch: the minimum angle the bone will yaw to
  3001. * - slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  3002. * - upAxis: the up axis of the coordinate system
  3003. * - upAxisSpace: the space that the up axis is in - BABYLON.Space.BONE, BABYLON.Space.LOCAL (default), or BABYLON.Space.WORLD.
  3004. * - yawAxis: set yawAxis if the bone does not yaw on the y axis
  3005. * - pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  3006. * - adjustYaw: used to make an adjustment to the yaw of the bone
  3007. * - adjustPitch: used to make an adjustment to the pitch of the bone
  3008. * - adjustRoll: used to make an adjustment to the roll of the bone
  3009. **/
  3010. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  3011. maxYaw?: number;
  3012. minYaw?: number;
  3013. maxPitch?: number;
  3014. minPitch?: number;
  3015. slerpAmount?: number;
  3016. upAxis?: Vector3;
  3017. upAxisSpace?: Space;
  3018. yawAxis?: Vector3;
  3019. pitchAxis?: Vector3;
  3020. adjustYaw?: number;
  3021. adjustPitch?: number;
  3022. adjustRoll?: number;
  3023. });
  3024. /**
  3025. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender()).
  3026. */
  3027. update(): void;
  3028. private _getAngleDiff(ang1, ang2);
  3029. private _getAngleBetween(ang1, ang2);
  3030. private _isAngleBetween(ang, ang1, ang2);
  3031. }
  3032. }
  3033. declare module BABYLON {
  3034. class Skeleton implements IAnimatable {
  3035. name: string;
  3036. id: string;
  3037. bones: Bone[];
  3038. dimensionsAtRest: Vector3;
  3039. needInitialSkinMatrix: boolean;
  3040. animations: Array<Animation>;
  3041. private _scene;
  3042. private _isDirty;
  3043. private _transformMatrices;
  3044. private _meshesWithPoseMatrix;
  3045. private _animatables;
  3046. private _identity;
  3047. private _synchronizedWithMesh;
  3048. private _ranges;
  3049. private _lastAbsoluteTransformsUpdateId;
  3050. /**
  3051. * Specifies if the skeleton should be serialized.
  3052. */
  3053. doNotSerialize: boolean;
  3054. /**
  3055. * An event triggered before computing the skeleton's matrices
  3056. * @type {BABYLON.Observable}
  3057. */
  3058. onBeforeComputeObservable: Observable<Skeleton>;
  3059. constructor(name: string, id: string, scene: Scene);
  3060. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  3061. getScene(): Scene;
  3062. /**
  3063. * @param {boolean} fullDetails - support for multiple levels of logging within scene loading
  3064. */
  3065. toString(fullDetails?: boolean): string;
  3066. /**
  3067. * Get bone's index searching by name
  3068. * @param {string} name is bone's name to search for
  3069. * @return {number} Indice of the bone. Returns -1 if not found
  3070. */
  3071. getBoneIndexByName(name: string): number;
  3072. createAnimationRange(name: string, from: number, to: number): void;
  3073. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  3074. getAnimationRange(name: string): Nullable<AnimationRange>;
  3075. /**
  3076. * Returns as an Array, all AnimationRanges defined on this skeleton
  3077. */
  3078. getAnimationRanges(): Nullable<AnimationRange>[];
  3079. /**
  3080. * note: This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  3081. */
  3082. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  3083. returnToRest(): void;
  3084. private _getHighestAnimationFrame();
  3085. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  3086. _markAsDirty(): void;
  3087. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  3088. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  3089. _computeTransformMatrices(targetMatrix: Float32Array, initialSkinMatrix: Nullable<Matrix>): void;
  3090. prepare(): void;
  3091. getAnimatables(): IAnimatable[];
  3092. clone(name: string, id: string): Skeleton;
  3093. enableBlending(blendingSpeed?: number): void;
  3094. dispose(): void;
  3095. serialize(): any;
  3096. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  3097. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  3098. getPoseMatrix(): Nullable<Matrix>;
  3099. sortBones(): void;
  3100. private _sortBones(index, bones, visited);
  3101. }
  3102. }
  3103. declare module BABYLON {
  3104. interface Behavior<T extends Node> {
  3105. name: string;
  3106. init(): void;
  3107. attach(node: T): void;
  3108. detach(): void;
  3109. }
  3110. }
  3111. declare module BABYLON {
  3112. class Collider {
  3113. /** Define if a collision was found */
  3114. collisionFound: boolean;
  3115. /**
  3116. * Define last intersection point in local space
  3117. */
  3118. intersectionPoint: Vector3;
  3119. /**
  3120. * Define last collided mesh
  3121. */
  3122. collidedMesh: Nullable<AbstractMesh>;
  3123. private _collisionPoint;
  3124. private _planeIntersectionPoint;
  3125. private _tempVector;
  3126. private _tempVector2;
  3127. private _tempVector3;
  3128. private _tempVector4;
  3129. private _edge;
  3130. private _baseToVertex;
  3131. private _destinationPoint;
  3132. private _slidePlaneNormal;
  3133. private _displacementVector;
  3134. _radius: Vector3;
  3135. _retry: number;
  3136. private _velocity;
  3137. private _basePoint;
  3138. private _epsilon;
  3139. _velocityWorldLength: number;
  3140. _basePointWorld: Vector3;
  3141. private _velocityWorld;
  3142. private _normalizedVelocity;
  3143. _initialVelocity: Vector3;
  3144. _initialPosition: Vector3;
  3145. private _nearestDistance;
  3146. private _collisionMask;
  3147. collisionMask: number;
  3148. /**
  3149. * Gets the plane normal used to compute the sliding response (in local space)
  3150. */
  3151. readonly slidePlaneNormal: Vector3;
  3152. _initialize(source: Vector3, dir: Vector3, e: number): void;
  3153. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  3154. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  3155. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  3156. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  3157. _getResponse(pos: Vector3, vel: Vector3): void;
  3158. }
  3159. }
  3160. declare module BABYLON {
  3161. var CollisionWorker: string;
  3162. interface ICollisionCoordinator {
  3163. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  3164. init(scene: Scene): void;
  3165. destroy(): void;
  3166. onMeshAdded(mesh: AbstractMesh): void;
  3167. onMeshUpdated(mesh: AbstractMesh): void;
  3168. onMeshRemoved(mesh: AbstractMesh): void;
  3169. onGeometryAdded(geometry: Geometry): void;
  3170. onGeometryUpdated(geometry: Geometry): void;
  3171. onGeometryDeleted(geometry: Geometry): void;
  3172. }
  3173. interface SerializedMesh {
  3174. id: string;
  3175. name: string;
  3176. uniqueId: number;
  3177. geometryId: Nullable<string>;
  3178. sphereCenter: Array<number>;
  3179. sphereRadius: number;
  3180. boxMinimum: Array<number>;
  3181. boxMaximum: Array<number>;
  3182. worldMatrixFromCache: any;
  3183. subMeshes: Array<SerializedSubMesh>;
  3184. checkCollisions: boolean;
  3185. }
  3186. interface SerializedSubMesh {
  3187. position: number;
  3188. verticesStart: number;
  3189. verticesCount: number;
  3190. indexStart: number;
  3191. indexCount: number;
  3192. hasMaterial: boolean;
  3193. sphereCenter: Array<number>;
  3194. sphereRadius: number;
  3195. boxMinimum: Array<number>;
  3196. boxMaximum: Array<number>;
  3197. }
  3198. /**
  3199. * Interface describing the value associated with a geometry
  3200. */
  3201. interface SerializedGeometry {
  3202. /**
  3203. * Defines the unique ID of the geometry
  3204. */
  3205. id: string;
  3206. /**
  3207. * Defines the array containing the positions
  3208. */
  3209. positions: Float32Array;
  3210. /**
  3211. * Defines the array containing the indices
  3212. */
  3213. indices: Uint32Array;
  3214. /**
  3215. * Defines the array containing the normals
  3216. */
  3217. normals: Float32Array;
  3218. }
  3219. interface BabylonMessage {
  3220. taskType: WorkerTaskType;
  3221. payload: InitPayload | CollidePayload | UpdatePayload;
  3222. }
  3223. interface SerializedColliderToWorker {
  3224. position: Array<number>;
  3225. velocity: Array<number>;
  3226. radius: Array<number>;
  3227. }
  3228. enum WorkerTaskType {
  3229. INIT = 0,
  3230. UPDATE = 1,
  3231. COLLIDE = 2,
  3232. }
  3233. interface WorkerReply {
  3234. error: WorkerReplyType;
  3235. taskType: WorkerTaskType;
  3236. payload?: any;
  3237. }
  3238. interface CollisionReplyPayload {
  3239. newPosition: Array<number>;
  3240. collisionId: number;
  3241. collidedMeshUniqueId: number;
  3242. }
  3243. interface InitPayload {
  3244. }
  3245. interface CollidePayload {
  3246. collisionId: number;
  3247. collider: SerializedColliderToWorker;
  3248. maximumRetry: number;
  3249. excludedMeshUniqueId: Nullable<number>;
  3250. }
  3251. interface UpdatePayload {
  3252. updatedMeshes: {
  3253. [n: number]: SerializedMesh;
  3254. };
  3255. updatedGeometries: {
  3256. [s: string]: SerializedGeometry;
  3257. };
  3258. removedMeshes: Array<number>;
  3259. removedGeometries: Array<string>;
  3260. }
  3261. enum WorkerReplyType {
  3262. SUCCESS = 0,
  3263. UNKNOWN_ERROR = 1,
  3264. }
  3265. class CollisionCoordinatorWorker implements ICollisionCoordinator {
  3266. private _scene;
  3267. private _scaledPosition;
  3268. private _scaledVelocity;
  3269. private _collisionsCallbackArray;
  3270. private _init;
  3271. private _runningUpdated;
  3272. private _worker;
  3273. private _addUpdateMeshesList;
  3274. private _addUpdateGeometriesList;
  3275. private _toRemoveMeshesArray;
  3276. private _toRemoveGeometryArray;
  3277. constructor();
  3278. static SerializeMesh: (mesh: AbstractMesh) => SerializedMesh;
  3279. static SerializeGeometry: (geometry: Geometry) => SerializedGeometry;
  3280. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  3281. init(scene: Scene): void;
  3282. destroy(): void;
  3283. onMeshAdded(mesh: AbstractMesh): void;
  3284. onMeshUpdated: (transformNode: TransformNode) => void;
  3285. onMeshRemoved(mesh: AbstractMesh): void;
  3286. onGeometryAdded(geometry: Geometry): void;
  3287. onGeometryUpdated: (geometry: Geometry) => void;
  3288. onGeometryDeleted(geometry: Geometry): void;
  3289. private _afterRender;
  3290. private _onMessageFromWorker;
  3291. }
  3292. class CollisionCoordinatorLegacy implements ICollisionCoordinator {
  3293. private _scene;
  3294. private _scaledPosition;
  3295. private _scaledVelocity;
  3296. private _finalPosition;
  3297. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  3298. init(scene: Scene): void;
  3299. destroy(): void;
  3300. onMeshAdded(mesh: AbstractMesh): void;
  3301. onMeshUpdated(mesh: AbstractMesh): void;
  3302. onMeshRemoved(mesh: AbstractMesh): void;
  3303. onGeometryAdded(geometry: Geometry): void;
  3304. onGeometryUpdated(geometry: Geometry): void;
  3305. onGeometryDeleted(geometry: Geometry): void;
  3306. private _collideWithWorld(position, velocity, collider, maximumRetry, finalPosition, excludedMesh?);
  3307. }
  3308. }
  3309. declare function importScripts(...urls: string[]): void;
  3310. declare module BABYLON {
  3311. var WorkerIncluded: boolean;
  3312. class CollisionCache {
  3313. private _meshes;
  3314. private _geometries;
  3315. getMeshes(): {
  3316. [n: number]: SerializedMesh;
  3317. };
  3318. getGeometries(): {
  3319. [s: number]: SerializedGeometry;
  3320. };
  3321. getMesh(id: any): SerializedMesh;
  3322. addMesh(mesh: SerializedMesh): void;
  3323. removeMesh(uniqueId: number): void;
  3324. getGeometry(id: string): SerializedGeometry;
  3325. addGeometry(geometry: SerializedGeometry): void;
  3326. removeGeometry(id: string): void;
  3327. }
  3328. class CollideWorker {
  3329. collider: Collider;
  3330. private _collisionCache;
  3331. private finalPosition;
  3332. private collisionsScalingMatrix;
  3333. private collisionTranformationMatrix;
  3334. constructor(collider: Collider, _collisionCache: CollisionCache, finalPosition: Vector3);
  3335. collideWithWorld(position: Vector3, velocity: Vector3, maximumRetry: number, excludedMeshUniqueId: Nullable<number>): void;
  3336. private checkCollision(mesh);
  3337. private processCollisionsForSubMeshes(transformMatrix, mesh);
  3338. private collideForSubMesh(subMesh, transformMatrix, meshGeometry);
  3339. private checkSubmeshCollision(subMesh);
  3340. }
  3341. interface ICollisionDetector {
  3342. onInit(payload: InitPayload): void;
  3343. onUpdate(payload: UpdatePayload): void;
  3344. onCollision(payload: CollidePayload): void;
  3345. }
  3346. class CollisionDetectorTransferable implements ICollisionDetector {
  3347. private _collisionCache;
  3348. onInit(payload: InitPayload): void;
  3349. onUpdate(payload: UpdatePayload): void;
  3350. onCollision(payload: CollidePayload): void;
  3351. }
  3352. }
  3353. declare module BABYLON {
  3354. class IntersectionInfo {
  3355. bu: Nullable<number>;
  3356. bv: Nullable<number>;
  3357. distance: number;
  3358. faceId: number;
  3359. subMeshId: number;
  3360. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  3361. }
  3362. class PickingInfo {
  3363. hit: boolean;
  3364. distance: number;
  3365. pickedPoint: Nullable<Vector3>;
  3366. pickedMesh: Nullable<AbstractMesh>;
  3367. bu: number;
  3368. bv: number;
  3369. faceId: number;
  3370. subMeshId: number;
  3371. pickedSprite: Nullable<Sprite>;
  3372. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  3373. getTextureCoordinates(): Nullable<Vector2>;
  3374. }
  3375. }
  3376. declare module BABYLON {
  3377. class ArcRotateCamera extends TargetCamera {
  3378. alpha: number;
  3379. beta: number;
  3380. radius: number;
  3381. protected _target: Vector3;
  3382. protected _targetHost: Nullable<AbstractMesh>;
  3383. target: Vector3;
  3384. inertialAlphaOffset: number;
  3385. inertialBetaOffset: number;
  3386. inertialRadiusOffset: number;
  3387. lowerAlphaLimit: Nullable<number>;
  3388. upperAlphaLimit: Nullable<number>;
  3389. lowerBetaLimit: number;
  3390. upperBetaLimit: number;
  3391. lowerRadiusLimit: Nullable<number>;
  3392. upperRadiusLimit: Nullable<number>;
  3393. inertialPanningX: number;
  3394. inertialPanningY: number;
  3395. pinchToPanMaxDistance: number;
  3396. panningDistanceLimit: Nullable<number>;
  3397. panningOriginTarget: Vector3;
  3398. panningInertia: number;
  3399. angularSensibilityX: number;
  3400. angularSensibilityY: number;
  3401. pinchPrecision: number;
  3402. pinchDeltaPercentage: number;
  3403. panningSensibility: number;
  3404. keysUp: number[];
  3405. keysDown: number[];
  3406. keysLeft: number[];
  3407. keysRight: number[];
  3408. wheelPrecision: number;
  3409. wheelDeltaPercentage: number;
  3410. zoomOnFactor: number;
  3411. targetScreenOffset: Vector2;
  3412. allowUpsideDown: boolean;
  3413. _viewMatrix: Matrix;
  3414. _useCtrlForPanning: boolean;
  3415. _panningMouseButton: number;
  3416. inputs: ArcRotateCameraInputsManager;
  3417. _reset: () => void;
  3418. panningAxis: Vector3;
  3419. protected _localDirection: Vector3;
  3420. protected _transformedDirection: Vector3;
  3421. private _bouncingBehavior;
  3422. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  3423. useBouncingBehavior: boolean;
  3424. private _framingBehavior;
  3425. readonly framingBehavior: Nullable<FramingBehavior>;
  3426. useFramingBehavior: boolean;
  3427. private _autoRotationBehavior;
  3428. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  3429. useAutoRotationBehavior: boolean;
  3430. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  3431. onCollide: (collidedMesh: AbstractMesh) => void;
  3432. checkCollisions: boolean;
  3433. collisionRadius: Vector3;
  3434. protected _collider: Collider;
  3435. protected _previousPosition: Vector3;
  3436. protected _collisionVelocity: Vector3;
  3437. protected _newPosition: Vector3;
  3438. protected _previousAlpha: number;
  3439. protected _previousBeta: number;
  3440. protected _previousRadius: number;
  3441. protected _collisionTriggered: boolean;
  3442. protected _targetBoundingCenter: Nullable<Vector3>;
  3443. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene);
  3444. _initCache(): void;
  3445. _updateCache(ignoreParentClass?: boolean): void;
  3446. protected _getTargetPosition(): Vector3;
  3447. /**
  3448. * Store current camera state (fov, position, etc..)
  3449. */
  3450. private _storedAlpha;
  3451. private _storedBeta;
  3452. private _storedRadius;
  3453. private _storedTarget;
  3454. storeState(): Camera;
  3455. /**
  3456. * Restored camera state. You must call storeState() first
  3457. */
  3458. _restoreStateValues(): boolean;
  3459. _isSynchronizedViewMatrix(): boolean;
  3460. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  3461. detachControl(element: HTMLElement): void;
  3462. _checkInputs(): void;
  3463. protected _checkLimits(): void;
  3464. rebuildAnglesAndRadius(): void;
  3465. setPosition(position: Vector3): void;
  3466. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  3467. _getViewMatrix(): Matrix;
  3468. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  3469. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  3470. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  3471. min: Vector3;
  3472. max: Vector3;
  3473. distance: number;
  3474. }, doNotUpdateMaxZ?: boolean): void;
  3475. /**
  3476. * @override
  3477. * Override Camera.createRigCamera
  3478. */
  3479. createRigCamera(name: string, cameraIndex: number): Camera;
  3480. /**
  3481. * @override
  3482. * Override Camera._updateRigCameras
  3483. */
  3484. _updateRigCameras(): void;
  3485. dispose(): void;
  3486. getClassName(): string;
  3487. }
  3488. }
  3489. declare module BABYLON {
  3490. class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  3491. constructor(camera: ArcRotateCamera);
  3492. addMouseWheel(): ArcRotateCameraInputsManager;
  3493. addPointers(): ArcRotateCameraInputsManager;
  3494. addKeyboard(): ArcRotateCameraInputsManager;
  3495. addGamepad(): ArcRotateCameraInputsManager;
  3496. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  3497. }
  3498. }
  3499. declare module BABYLON {
  3500. class Camera extends Node {
  3501. inputs: CameraInputsManager<Camera>;
  3502. private static _PERSPECTIVE_CAMERA;
  3503. private static _ORTHOGRAPHIC_CAMERA;
  3504. private static _FOVMODE_VERTICAL_FIXED;
  3505. private static _FOVMODE_HORIZONTAL_FIXED;
  3506. private static _RIG_MODE_NONE;
  3507. private static _RIG_MODE_STEREOSCOPIC_ANAGLYPH;
  3508. private static _RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL;
  3509. private static _RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED;
  3510. private static _RIG_MODE_STEREOSCOPIC_OVERUNDER;
  3511. private static _RIG_MODE_VR;
  3512. private static _RIG_MODE_WEBVR;
  3513. static readonly PERSPECTIVE_CAMERA: number;
  3514. static readonly ORTHOGRAPHIC_CAMERA: number;
  3515. /**
  3516. * This is the default FOV mode for perspective cameras.
  3517. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  3518. *
  3519. */
  3520. static readonly FOVMODE_VERTICAL_FIXED: number;
  3521. /**
  3522. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  3523. *
  3524. */
  3525. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  3526. static readonly RIG_MODE_NONE: number;
  3527. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  3528. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  3529. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  3530. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  3531. static readonly RIG_MODE_VR: number;
  3532. static readonly RIG_MODE_WEBVR: number;
  3533. static ForceAttachControlToAlwaysPreventDefault: boolean;
  3534. static UseAlternateWebVRRendering: boolean;
  3535. position: Vector3;
  3536. /**
  3537. * The vector the camera should consider as up.
  3538. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  3539. */
  3540. upVector: Vector3;
  3541. orthoLeft: Nullable<number>;
  3542. orthoRight: Nullable<number>;
  3543. orthoBottom: Nullable<number>;
  3544. orthoTop: Nullable<number>;
  3545. /**
  3546. * FOV is set in Radians. (default is 0.8)
  3547. */
  3548. fov: number;
  3549. minZ: number;
  3550. maxZ: number;
  3551. inertia: number;
  3552. mode: number;
  3553. isIntermediate: boolean;
  3554. viewport: Viewport;
  3555. /**
  3556. * Restricts the camera to viewing objects with the same layerMask.
  3557. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  3558. */
  3559. layerMask: number;
  3560. /**
  3561. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  3562. */
  3563. fovMode: number;
  3564. cameraRigMode: number;
  3565. interaxialDistance: number;
  3566. isStereoscopicSideBySide: boolean;
  3567. _cameraRigParams: any;
  3568. _rigCameras: Camera[];
  3569. _rigPostProcess: Nullable<PostProcess>;
  3570. protected _webvrViewMatrix: Matrix;
  3571. _skipRendering: boolean;
  3572. _alternateCamera: Camera;
  3573. customRenderTargets: RenderTargetTexture[];
  3574. onViewMatrixChangedObservable: Observable<Camera>;
  3575. onProjectionMatrixChangedObservable: Observable<Camera>;
  3576. onAfterCheckInputsObservable: Observable<Camera>;
  3577. onRestoreStateObservable: Observable<Camera>;
  3578. private _computedViewMatrix;
  3579. _projectionMatrix: Matrix;
  3580. private _doNotComputeProjectionMatrix;
  3581. private _worldMatrix;
  3582. _postProcesses: PostProcess[];
  3583. private _transformMatrix;
  3584. _activeMeshes: SmartArray<AbstractMesh>;
  3585. private _globalPosition;
  3586. private _frustumPlanes;
  3587. private _refreshFrustumPlanes;
  3588. constructor(name: string, position: Vector3, scene: Scene);
  3589. private _storedFov;
  3590. private _stateStored;
  3591. /**
  3592. * Store current camera state (fov, position, etc..)
  3593. */
  3594. storeState(): Camera;
  3595. /**
  3596. * Restores the camera state values if it has been stored. You must call storeState() first
  3597. */
  3598. protected _restoreStateValues(): boolean;
  3599. /**
  3600. * Restored camera state. You must call storeState() first
  3601. */
  3602. restoreState(): boolean;
  3603. getClassName(): string;
  3604. /**
  3605. * @param {boolean} fullDetails - support for multiple levels of logging within scene loading
  3606. */
  3607. toString(fullDetails?: boolean): string;
  3608. readonly globalPosition: Vector3;
  3609. getActiveMeshes(): SmartArray<AbstractMesh>;
  3610. isActiveMesh(mesh: Mesh): boolean;
  3611. _initCache(): void;
  3612. _updateCache(ignoreParentClass?: boolean): void;
  3613. _isSynchronized(): boolean;
  3614. _isSynchronizedViewMatrix(): boolean;
  3615. _isSynchronizedProjectionMatrix(): boolean;
  3616. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  3617. detachControl(element: HTMLElement): void;
  3618. update(): void;
  3619. _checkInputs(): void;
  3620. readonly rigCameras: Camera[];
  3621. readonly rigPostProcess: Nullable<PostProcess>;
  3622. private _cascadePostProcessesToRigCams();
  3623. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  3624. detachPostProcess(postProcess: PostProcess): void;
  3625. getWorldMatrix(): Matrix;
  3626. _getViewMatrix(): Matrix;
  3627. getViewMatrix(force?: boolean): Matrix;
  3628. freezeProjectionMatrix(projection?: Matrix): void;
  3629. unfreezeProjectionMatrix(): void;
  3630. getProjectionMatrix(force?: boolean): Matrix;
  3631. getTranformationMatrix(): Matrix;
  3632. private updateFrustumPlanes();
  3633. isInFrustum(target: ICullable): boolean;
  3634. isCompletelyInFrustum(target: ICullable): boolean;
  3635. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  3636. dispose(): void;
  3637. readonly leftCamera: Nullable<FreeCamera>;
  3638. readonly rightCamera: Nullable<FreeCamera>;
  3639. getLeftTarget(): Nullable<Vector3>;
  3640. getRightTarget(): Nullable<Vector3>;
  3641. setCameraRigMode(mode: number, rigParams: any): void;
  3642. private _getVRProjectionMatrix();
  3643. protected _updateCameraRotationMatrix(): void;
  3644. protected _updateWebVRCameraRotationMatrix(): void;
  3645. /**
  3646. * This function MUST be overwritten by the different WebVR cameras available.
  3647. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  3648. */
  3649. protected _getWebVRProjectionMatrix(): Matrix;
  3650. /**
  3651. * This function MUST be overwritten by the different WebVR cameras available.
  3652. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  3653. */
  3654. protected _getWebVRViewMatrix(): Matrix;
  3655. setCameraRigParameter(name: string, value: any): void;
  3656. /**
  3657. * needs to be overridden by children so sub has required properties to be copied
  3658. */
  3659. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  3660. /**
  3661. * May need to be overridden by children
  3662. */
  3663. _updateRigCameras(): void;
  3664. _setupInputs(): void;
  3665. serialize(): any;
  3666. clone(name: string): Camera;
  3667. getDirection(localAxis: Vector3): Vector3;
  3668. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  3669. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  3670. computeWorldMatrix(): Matrix;
  3671. static Parse(parsedCamera: any, scene: Scene): Camera;
  3672. }
  3673. }
  3674. declare module BABYLON {
  3675. var CameraInputTypes: {};
  3676. interface ICameraInput<TCamera extends Camera> {
  3677. camera: Nullable<TCamera>;
  3678. getClassName(): string;
  3679. getSimpleName(): string;
  3680. attachControl: (element: HTMLElement, noPreventDefault?: boolean) => void;
  3681. detachControl: (element: Nullable<HTMLElement>) => void;
  3682. checkInputs?: () => void;
  3683. }
  3684. interface CameraInputsMap<TCamera extends Camera> {
  3685. [name: string]: ICameraInput<TCamera>;
  3686. [idx: number]: ICameraInput<TCamera>;
  3687. }
  3688. class CameraInputsManager<TCamera extends Camera> {
  3689. attached: CameraInputsMap<TCamera>;
  3690. attachedElement: Nullable<HTMLElement>;
  3691. noPreventDefault: boolean;
  3692. camera: TCamera;
  3693. checkInputs: () => void;
  3694. constructor(camera: TCamera);
  3695. /**
  3696. * Add an input method to a camera.
  3697. * builtin inputs example: camera.inputs.addGamepad();
  3698. * custom inputs example: camera.inputs.add(new BABYLON.FreeCameraGamepadInput());
  3699. * @param input camera input method
  3700. */
  3701. add(input: ICameraInput<TCamera>): void;
  3702. /**
  3703. * Remove a specific input method from a camera
  3704. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  3705. * @param inputToRemove camera input method
  3706. */
  3707. remove(inputToRemove: ICameraInput<TCamera>): void;
  3708. removeByType(inputType: string): void;
  3709. private _addCheckInputs(fn);
  3710. attachInput(input: ICameraInput<TCamera>): void;
  3711. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  3712. detachElement(element: HTMLElement, disconnect?: boolean): void;
  3713. rebuildInputCheck(): void;
  3714. /**
  3715. * Remove all attached input methods from a camera
  3716. */
  3717. clear(): void;
  3718. serialize(serializedCamera: any): void;
  3719. parse(parsedCamera: any): void;
  3720. }
  3721. }
  3722. declare module BABYLON {
  3723. /**
  3724. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  3725. * being tilted forward or back and left or right.
  3726. */
  3727. class DeviceOrientationCamera extends FreeCamera {
  3728. private _initialQuaternion;
  3729. private _quaternionCache;
  3730. /**
  3731. * Creates a new device orientation camera. @see DeviceOrientationCamera
  3732. * @param name The name of the camera
  3733. * @param position The start position camera
  3734. * @param scene The scene the camera belongs to
  3735. */
  3736. constructor(name: string, position: Vector3, scene: Scene);
  3737. /**
  3738. * Gets the current instance class name ("DeviceOrientationCamera").
  3739. * This helps avoiding instanceof at run time.
  3740. * @returns the class name
  3741. */
  3742. getClassName(): string;
  3743. /**
  3744. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  3745. */
  3746. _checkInputs(): void;
  3747. /**
  3748. * Reset the camera to its default orientation on the specified axis only.
  3749. * @param axis The axis to reset
  3750. */
  3751. resetToCurrentRotation(axis?: Axis): void;
  3752. }
  3753. }
  3754. declare module BABYLON {
  3755. class FollowCamera extends TargetCamera {
  3756. radius: number;
  3757. rotationOffset: number;
  3758. heightOffset: number;
  3759. cameraAcceleration: number;
  3760. maxCameraSpeed: number;
  3761. lockedTarget: Nullable<AbstractMesh>;
  3762. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  3763. private getRadians(degrees);
  3764. private follow(cameraTarget);
  3765. _checkInputs(): void;
  3766. getClassName(): string;
  3767. }
  3768. class ArcFollowCamera extends TargetCamera {
  3769. alpha: number;
  3770. beta: number;
  3771. radius: number;
  3772. target: Nullable<AbstractMesh>;
  3773. private _cartesianCoordinates;
  3774. constructor(name: string, alpha: number, beta: number, radius: number, target: Nullable<AbstractMesh>, scene: Scene);
  3775. private follow();
  3776. _checkInputs(): void;
  3777. getClassName(): string;
  3778. }
  3779. }
  3780. declare module BABYLON {
  3781. class FreeCamera extends TargetCamera {
  3782. ellipsoid: Vector3;
  3783. ellipsoidOffset: Vector3;
  3784. checkCollisions: boolean;
  3785. applyGravity: boolean;
  3786. inputs: FreeCameraInputsManager;
  3787. /**
  3788. * Gets the input sensibility for a mouse input. (default is 2000.0)
  3789. * Higher values reduce sensitivity.
  3790. */
  3791. /**
  3792. * Sets the input sensibility for a mouse input. (default is 2000.0)
  3793. * Higher values reduce sensitivity.
  3794. */
  3795. angularSensibility: number;
  3796. keysUp: number[];
  3797. keysDown: number[];
  3798. keysLeft: number[];
  3799. keysRight: number[];
  3800. onCollide: (collidedMesh: AbstractMesh) => void;
  3801. private _collider;
  3802. private _needMoveForGravity;
  3803. private _oldPosition;
  3804. private _diffPosition;
  3805. private _newPosition;
  3806. _localDirection: Vector3;
  3807. _transformedDirection: Vector3;
  3808. constructor(name: string, position: Vector3, scene: Scene);
  3809. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  3810. detachControl(element: HTMLElement): void;
  3811. private _collisionMask;
  3812. collisionMask: number;
  3813. _collideWithWorld(displacement: Vector3): void;
  3814. private _onCollisionPositionChange;
  3815. _checkInputs(): void;
  3816. _decideIfNeedsToMove(): boolean;
  3817. _updatePosition(): void;
  3818. dispose(): void;
  3819. getClassName(): string;
  3820. }
  3821. }
  3822. declare module BABYLON {
  3823. class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  3824. constructor(camera: FreeCamera);
  3825. addKeyboard(): FreeCameraInputsManager;
  3826. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  3827. addGamepad(): FreeCameraInputsManager;
  3828. addDeviceOrientation(): FreeCameraInputsManager;
  3829. addTouch(): FreeCameraInputsManager;
  3830. addVirtualJoystick(): FreeCameraInputsManager;
  3831. }
  3832. }
  3833. declare module BABYLON {
  3834. class GamepadCamera extends UniversalCamera {
  3835. gamepadAngularSensibility: number;
  3836. gamepadMoveSensibility: number;
  3837. constructor(name: string, position: Vector3, scene: Scene);
  3838. getClassName(): string;
  3839. }
  3840. }
  3841. declare module BABYLON {
  3842. class AnaglyphFreeCamera extends FreeCamera {
  3843. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  3844. getClassName(): string;
  3845. }
  3846. class AnaglyphArcRotateCamera extends ArcRotateCamera {
  3847. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  3848. getClassName(): string;
  3849. }
  3850. class AnaglyphGamepadCamera extends GamepadCamera {
  3851. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  3852. getClassName(): string;
  3853. }
  3854. class AnaglyphUniversalCamera extends UniversalCamera {
  3855. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  3856. getClassName(): string;
  3857. }
  3858. class StereoscopicFreeCamera extends FreeCamera {
  3859. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  3860. getClassName(): string;
  3861. }
  3862. class StereoscopicArcRotateCamera extends ArcRotateCamera {
  3863. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  3864. getClassName(): string;
  3865. }
  3866. class StereoscopicGamepadCamera extends GamepadCamera {
  3867. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  3868. getClassName(): string;
  3869. }
  3870. class StereoscopicUniversalCamera extends UniversalCamera {
  3871. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  3872. getClassName(): string;
  3873. }
  3874. }
  3875. declare module BABYLON {
  3876. class TargetCamera extends Camera {
  3877. cameraDirection: Vector3;
  3878. cameraRotation: Vector2;
  3879. rotation: Vector3;
  3880. rotationQuaternion: Quaternion;
  3881. speed: number;
  3882. noRotationConstraint: boolean;
  3883. lockedTarget: any;
  3884. _currentTarget: Vector3;
  3885. _viewMatrix: Matrix;
  3886. _camMatrix: Matrix;
  3887. _cameraTransformMatrix: Matrix;
  3888. _cameraRotationMatrix: Matrix;
  3889. private _rigCamTransformMatrix;
  3890. _referencePoint: Vector3;
  3891. private _currentUpVector;
  3892. _transformedReferencePoint: Vector3;
  3893. _lookAtTemp: Matrix;
  3894. _tempMatrix: Matrix;
  3895. _reset: () => void;
  3896. constructor(name: string, position: Vector3, scene: Scene);
  3897. getFrontPosition(distance: number): Vector3;
  3898. _getLockedTargetPosition(): Nullable<Vector3>;
  3899. /**
  3900. * Store current camera state (fov, position, etc..)
  3901. */
  3902. private _storedPosition;
  3903. private _storedRotation;
  3904. private _storedRotationQuaternion;
  3905. storeState(): Camera;
  3906. /**
  3907. * Restored camera state. You must call storeState() first
  3908. */
  3909. _restoreStateValues(): boolean;
  3910. _initCache(): void;
  3911. _updateCache(ignoreParentClass?: boolean): void;
  3912. _isSynchronizedViewMatrix(): boolean;
  3913. _computeLocalCameraSpeed(): number;
  3914. setTarget(target: Vector3): void;
  3915. /**
  3916. * Return the current target position of the camera. This value is expressed in local space.
  3917. */
  3918. getTarget(): Vector3;
  3919. _decideIfNeedsToMove(): boolean;
  3920. _updatePosition(): void;
  3921. _checkInputs(): void;
  3922. protected _updateCameraRotationMatrix(): void;
  3923. _getViewMatrix(): Matrix;
  3924. /**
  3925. * @override
  3926. * Override Camera.createRigCamera
  3927. */
  3928. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  3929. /**
  3930. * @override
  3931. * Override Camera._updateRigCameras
  3932. */
  3933. _updateRigCameras(): void;
  3934. private _getRigCamPosition(halfSpace, result);
  3935. getClassName(): string;
  3936. }
  3937. }
  3938. declare module BABYLON {
  3939. class TouchCamera extends FreeCamera {
  3940. touchAngularSensibility: number;
  3941. touchMoveSensibility: number;
  3942. constructor(name: string, position: Vector3, scene: Scene);
  3943. getClassName(): string;
  3944. _setupInputs(): void;
  3945. }
  3946. }
  3947. declare module BABYLON {
  3948. class UniversalCamera extends TouchCamera {
  3949. gamepadAngularSensibility: number;
  3950. gamepadMoveSensibility: number;
  3951. constructor(name: string, position: Vector3, scene: Scene);
  3952. getClassName(): string;
  3953. }
  3954. }
  3955. declare module BABYLON {
  3956. class VirtualJoysticksCamera extends FreeCamera {
  3957. constructor(name: string, position: Vector3, scene: Scene);
  3958. getClassName(): string;
  3959. }
  3960. }
  3961. declare module BABYLON {
  3962. class BoundingBox implements ICullable {
  3963. minimum: Vector3;
  3964. maximum: Vector3;
  3965. vectors: Vector3[];
  3966. center: Vector3;
  3967. centerWorld: Vector3;
  3968. extendSize: Vector3;
  3969. extendSizeWorld: Vector3;
  3970. directions: Vector3[];
  3971. vectorsWorld: Vector3[];
  3972. minimumWorld: Vector3;
  3973. maximumWorld: Vector3;
  3974. private _worldMatrix;
  3975. constructor(minimum: Vector3, maximum: Vector3);
  3976. getWorldMatrix(): Matrix;
  3977. setWorldMatrix(matrix: Matrix): BoundingBox;
  3978. _update(world: Matrix): void;
  3979. isInFrustum(frustumPlanes: Plane[]): boolean;
  3980. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  3981. intersectsPoint(point: Vector3): boolean;
  3982. intersectsSphere(sphere: BoundingSphere): boolean;
  3983. intersectsMinMax(min: Vector3, max: Vector3): boolean;
  3984. static Intersects(box0: BoundingBox, box1: BoundingBox): boolean;
  3985. static IntersectsSphere(minPoint: Vector3, maxPoint: Vector3, sphereCenter: Vector3, sphereRadius: number): boolean;
  3986. static IsCompletelyInFrustum(boundingVectors: Vector3[], frustumPlanes: Plane[]): boolean;
  3987. static IsInFrustum(boundingVectors: Vector3[], frustumPlanes: Plane[]): boolean;
  3988. }
  3989. }
  3990. declare module BABYLON {
  3991. interface ICullable {
  3992. isInFrustum(frustumPlanes: Plane[]): boolean;
  3993. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  3994. }
  3995. class BoundingInfo implements ICullable {
  3996. minimum: Vector3;
  3997. maximum: Vector3;
  3998. boundingBox: BoundingBox;
  3999. boundingSphere: BoundingSphere;
  4000. private _isLocked;
  4001. constructor(minimum: Vector3, maximum: Vector3);
  4002. isLocked: boolean;
  4003. update(world: Matrix): void;
  4004. /**
  4005. * Recreate the bounding info to be centered around a specific point given a specific extend.
  4006. * @param center New center of the bounding info
  4007. * @param extend New extend of the bounding info
  4008. */
  4009. centerOn(center: Vector3, extend: Vector3): BoundingInfo;
  4010. isInFrustum(frustumPlanes: Plane[]): boolean;
  4011. /**
  4012. * Gets the world distance between the min and max points of the bounding box
  4013. */
  4014. readonly diagonalLength: number;
  4015. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  4016. _checkCollision(collider: Collider): boolean;
  4017. intersectsPoint(point: Vector3): boolean;
  4018. intersects(boundingInfo: BoundingInfo, precise: boolean): boolean;
  4019. }
  4020. }
  4021. declare module BABYLON {
  4022. class BoundingSphere {
  4023. minimum: Vector3;
  4024. maximum: Vector3;
  4025. center: Vector3;
  4026. radius: number;
  4027. centerWorld: Vector3;
  4028. radiusWorld: number;
  4029. private _tempRadiusVector;
  4030. constructor(minimum: Vector3, maximum: Vector3);
  4031. _update(world: Matrix): void;
  4032. isInFrustum(frustumPlanes: Plane[]): boolean;
  4033. intersectsPoint(point: Vector3): boolean;
  4034. static Intersects(sphere0: BoundingSphere, sphere1: BoundingSphere): boolean;
  4035. }
  4036. }
  4037. declare module BABYLON {
  4038. class Ray {
  4039. origin: Vector3;
  4040. direction: Vector3;
  4041. length: number;
  4042. private _edge1;
  4043. private _edge2;
  4044. private _pvec;
  4045. private _tvec;
  4046. private _qvec;
  4047. private _tmpRay;
  4048. constructor(origin: Vector3, direction: Vector3, length?: number);
  4049. intersectsBoxMinMax(minimum: Vector3, maximum: Vector3): boolean;
  4050. intersectsBox(box: BoundingBox): boolean;
  4051. intersectsSphere(sphere: BoundingSphere): boolean;
  4052. intersectsTriangle(vertex0: Vector3, vertex1: Vector3, vertex2: Vector3): Nullable<IntersectionInfo>;
  4053. intersectsPlane(plane: Plane): Nullable<number>;
  4054. intersectsMesh(mesh: AbstractMesh, fastCheck?: boolean): PickingInfo;
  4055. intersectsMeshes(meshes: Array<AbstractMesh>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  4056. private _comparePickingInfo(pickingInfoA, pickingInfoB);
  4057. private static smallnum;
  4058. private static rayl;
  4059. /**
  4060. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  4061. * @param sega the first point of the segment to test the intersection against
  4062. * @param segb the second point of the segment to test the intersection against
  4063. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  4064. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  4065. */
  4066. intersectionSegment(sega: Vector3, segb: Vector3, threshold: number): number;
  4067. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix): Ray;
  4068. static Zero(): Ray;
  4069. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix): Ray;
  4070. /**
  4071. * 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
  4072. * transformed to the given world matrix.
  4073. * @param origin The origin point
  4074. * @param end The end point
  4075. * @param world a matrix to transform the ray to. Default is the identity matrix.
  4076. */
  4077. static CreateNewFromTo(origin: Vector3, end: Vector3, world?: Matrix): Ray;
  4078. static Transform(ray: Ray, matrix: Matrix): Ray;
  4079. static TransformToRef(ray: Ray, matrix: Matrix, result: Ray): void;
  4080. }
  4081. }
  4082. declare module BABYLON {
  4083. class DebugLayer {
  4084. private _scene;
  4085. static InspectorURL: string;
  4086. private _inspector;
  4087. private BJSINSPECTOR;
  4088. constructor(scene: Scene);
  4089. /** Creates the inspector window. */
  4090. private _createInspector(config?);
  4091. isVisible(): boolean;
  4092. hide(): void;
  4093. show(config?: {
  4094. popup?: boolean;
  4095. initialTab?: number;
  4096. parentElement?: HTMLElement;
  4097. newColors?: {
  4098. backgroundColor?: string;
  4099. backgroundColorLighter?: string;
  4100. backgroundColorLighter2?: string;
  4101. backgroundColorLighter3?: string;
  4102. color?: string;
  4103. colorTop?: string;
  4104. colorBot?: string;
  4105. };
  4106. }): void;
  4107. }
  4108. }
  4109. declare module BABYLON {
  4110. class Debug {
  4111. static AxesViewer: {
  4112. new (scene: Scene, scaleLines?: number): {
  4113. _xline: Vector3[];
  4114. _yline: Vector3[];
  4115. _zline: Vector3[];
  4116. _xmesh: Nullable<LinesMesh>;
  4117. _ymesh: Nullable<LinesMesh>;
  4118. _zmesh: Nullable<LinesMesh>;
  4119. scene: Nullable<Scene>;
  4120. scaleLines: number;
  4121. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  4122. dispose(): void;
  4123. };
  4124. };
  4125. static BoneAxesViewer: {
  4126. new (scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number): {
  4127. mesh: Nullable<Mesh>;
  4128. bone: Nullable<Bone>;
  4129. pos: Vector3;
  4130. xaxis: Vector3;
  4131. yaxis: Vector3;
  4132. zaxis: Vector3;
  4133. update(): void;
  4134. dispose(): void;
  4135. _xline: Vector3[];
  4136. _yline: Vector3[];
  4137. _zline: Vector3[];
  4138. _xmesh: Nullable<LinesMesh>;
  4139. _ymesh: Nullable<LinesMesh>;
  4140. _zmesh: Nullable<LinesMesh>;
  4141. scene: Nullable<Scene>;
  4142. scaleLines: number;
  4143. };
  4144. };
  4145. static PhysicsViewer: {
  4146. new (scene: Scene): {
  4147. _impostors: Nullable<PhysicsImpostor>[];
  4148. _meshes: Nullable<AbstractMesh>[];
  4149. _scene: Nullable<Scene>;
  4150. _numMeshes: number;
  4151. _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  4152. _renderFunction: () => void;
  4153. _debugBoxMesh: Mesh;
  4154. _debugSphereMesh: Mesh;
  4155. _debugMaterial: StandardMaterial;
  4156. _updateDebugMeshes(): void;
  4157. showImpostor(impostor: PhysicsImpostor): void;
  4158. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  4159. _getDebugMaterial(scene: Scene): Material;
  4160. _getDebugBoxMesh(scene: Scene): AbstractMesh;
  4161. _getDebugSphereMesh(scene: Scene): AbstractMesh;
  4162. _getDebugMesh(impostor: PhysicsImpostor, scene: Scene): Nullable<AbstractMesh>;
  4163. dispose(): void;
  4164. };
  4165. };
  4166. static SkeletonViewer: {
  4167. new (skeleton: Skeleton, mesh: AbstractMesh, scene: Scene, autoUpdateBonesMatrices?: boolean, renderingGroupId?: number): {
  4168. color: Color3;
  4169. _scene: Scene;
  4170. _debugLines: Vector3[][];
  4171. _debugMesh: Nullable<LinesMesh>;
  4172. _isEnabled: boolean;
  4173. _renderFunction: () => void;
  4174. skeleton: Skeleton;
  4175. mesh: AbstractMesh;
  4176. autoUpdateBonesMatrices: boolean;
  4177. renderingGroupId: number;
  4178. isEnabled: boolean;
  4179. _getBonePosition(position: Vector3, bone: Bone, meshMat: Matrix, x?: number, y?: number, z?: number): void;
  4180. _getLinesForBonesWithLength(bones: Bone[], meshMat: Matrix): void;
  4181. _getLinesForBonesNoLength(bones: Bone[], meshMat: Matrix): void;
  4182. update(): void;
  4183. dispose(): void;
  4184. };
  4185. };
  4186. }
  4187. }
  4188. declare module BABYLON {
  4189. class RayHelper {
  4190. ray: Nullable<Ray>;
  4191. private _renderPoints;
  4192. private _renderLine;
  4193. private _renderFunction;
  4194. private _scene;
  4195. private _updateToMeshFunction;
  4196. private _attachedToMesh;
  4197. private _meshSpaceDirection;
  4198. private _meshSpaceOrigin;
  4199. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  4200. constructor(ray: Ray);
  4201. show(scene: Scene, color: Color3): void;
  4202. hide(): void;
  4203. private _render();
  4204. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  4205. detachFromMesh(): void;
  4206. private _updateToMesh();
  4207. dispose(): void;
  4208. }
  4209. }
  4210. declare module BABYLON {
  4211. class InstancingAttributeInfo {
  4212. /**
  4213. * Index/offset of the attribute in the vertex shader
  4214. */
  4215. index: number;
  4216. /**
  4217. * size of the attribute, 1, 2, 3 or 4
  4218. */
  4219. attributeSize: number;
  4220. /**
  4221. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  4222. * default is FLOAT
  4223. */
  4224. attribyteType: number;
  4225. /**
  4226. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  4227. */
  4228. normalized: boolean;
  4229. /**
  4230. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  4231. */
  4232. offset: number;
  4233. /**
  4234. * Name of the GLSL attribute, for debugging purpose only
  4235. */
  4236. attributeName: string;
  4237. }
  4238. /**
  4239. * Define options used to create a render target texture
  4240. */
  4241. class RenderTargetCreationOptions {
  4242. generateMipMaps?: boolean;
  4243. generateDepthBuffer?: boolean;
  4244. generateStencilBuffer?: boolean;
  4245. type?: number;
  4246. samplingMode?: number;
  4247. }
  4248. /**
  4249. * Define options used to create a depth texture
  4250. */
  4251. class DepthTextureCreationOptions {
  4252. /** Specifies wether or not a stencil should be allocated in the texture */
  4253. generateStencil?: boolean;
  4254. /** Specifies wether or not bilinear filtering is enable on the texture */
  4255. bilinearFiltering?: boolean;
  4256. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  4257. comparisonFunction?: number;
  4258. }
  4259. /**
  4260. * Regroup several parameters relative to the browser in use
  4261. */
  4262. class EngineCapabilities {
  4263. /** The maximum textures image */
  4264. maxTexturesImageUnits: number;
  4265. maxVertexTextureImageUnits: number;
  4266. maxCombinedTexturesImageUnits: number;
  4267. /** The maximum texture size */
  4268. maxTextureSize: number;
  4269. maxCubemapTextureSize: number;
  4270. maxRenderTextureSize: number;
  4271. maxVertexAttribs: number;
  4272. maxVaryingVectors: number;
  4273. maxVertexUniformVectors: number;
  4274. maxFragmentUniformVectors: number;
  4275. standardDerivatives: boolean;
  4276. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  4277. pvrtc: any;
  4278. etc1: any;
  4279. etc2: any;
  4280. astc: any;
  4281. textureFloat: boolean;
  4282. vertexArrayObject: boolean;
  4283. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  4284. maxAnisotropy: number;
  4285. instancedArrays: boolean;
  4286. uintIndices: boolean;
  4287. highPrecisionShaderSupported: boolean;
  4288. fragmentDepthSupported: boolean;
  4289. textureFloatLinearFiltering: boolean;
  4290. textureFloatRender: boolean;
  4291. textureHalfFloat: boolean;
  4292. textureHalfFloatLinearFiltering: boolean;
  4293. textureHalfFloatRender: boolean;
  4294. textureLOD: boolean;
  4295. drawBuffersExtension: boolean;
  4296. depthTextureExtension: boolean;
  4297. colorBufferFloat: boolean;
  4298. timerQuery: EXT_disjoint_timer_query;
  4299. canUseTimestampForTimerQuery: boolean;
  4300. }
  4301. interface EngineOptions extends WebGLContextAttributes {
  4302. limitDeviceRatio?: number;
  4303. autoEnableWebVR?: boolean;
  4304. disableWebGL2Support?: boolean;
  4305. audioEngine?: boolean;
  4306. deterministicLockstep?: boolean;
  4307. lockstepMaxSteps?: number;
  4308. doNotHandleContextLost?: boolean;
  4309. }
  4310. interface IDisplayChangedEventArgs {
  4311. vrDisplay: Nullable<any>;
  4312. vrSupported: boolean;
  4313. }
  4314. /**
  4315. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio.
  4316. */
  4317. class Engine {
  4318. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  4319. static ExceptionList: ({
  4320. key: string;
  4321. capture: string;
  4322. captureConstraint: number;
  4323. targets: string[];
  4324. } | {
  4325. key: string;
  4326. capture: null;
  4327. captureConstraint: null;
  4328. targets: string[];
  4329. })[];
  4330. static Instances: Engine[];
  4331. static readonly LastCreatedEngine: Nullable<Engine>;
  4332. static readonly LastCreatedScene: Nullable<Scene>;
  4333. /**
  4334. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  4335. */
  4336. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  4337. private static _ALPHA_DISABLE;
  4338. private static _ALPHA_ADD;
  4339. private static _ALPHA_COMBINE;
  4340. private static _ALPHA_SUBTRACT;
  4341. private static _ALPHA_MULTIPLY;
  4342. private static _ALPHA_MAXIMIZED;
  4343. private static _ALPHA_ONEONE;
  4344. private static _ALPHA_PREMULTIPLIED;
  4345. private static _ALPHA_PREMULTIPLIED_PORTERDUFF;
  4346. private static _ALPHA_INTERPOLATE;
  4347. private static _ALPHA_SCREENMODE;
  4348. private static _DELAYLOADSTATE_NONE;
  4349. private static _DELAYLOADSTATE_LOADED;
  4350. private static _DELAYLOADSTATE_LOADING;
  4351. private static _DELAYLOADSTATE_NOTLOADED;
  4352. private static _TEXTUREFORMAT_ALPHA;
  4353. private static _TEXTUREFORMAT_LUMINANCE;
  4354. private static _TEXTUREFORMAT_LUMINANCE_ALPHA;
  4355. private static _TEXTUREFORMAT_RGB;
  4356. private static _TEXTUREFORMAT_RGBA;
  4357. private static _TEXTUREFORMAT_R32F;
  4358. private static _TEXTUREFORMAT_RG32F;
  4359. private static _TEXTUREFORMAT_RGB32F;
  4360. private static _TEXTUREFORMAT_RGBA32F;
  4361. private static _TEXTURETYPE_UNSIGNED_INT;
  4362. private static _TEXTURETYPE_FLOAT;
  4363. private static _TEXTURETYPE_HALF_FLOAT;
  4364. private static _NEVER;
  4365. private static _ALWAYS;
  4366. private static _LESS;
  4367. private static _EQUAL;
  4368. private static _LEQUAL;
  4369. private static _GREATER;
  4370. private static _GEQUAL;
  4371. private static _NOTEQUAL;
  4372. static readonly NEVER: number;
  4373. static readonly ALWAYS: number;
  4374. static readonly LESS: number;
  4375. static readonly EQUAL: number;
  4376. static readonly LEQUAL: number;
  4377. static readonly GREATER: number;
  4378. static readonly GEQUAL: number;
  4379. static readonly NOTEQUAL: number;
  4380. private static _KEEP;
  4381. private static _REPLACE;
  4382. private static _INCR;
  4383. private static _DECR;
  4384. private static _INVERT;
  4385. private static _INCR_WRAP;
  4386. private static _DECR_WRAP;
  4387. static readonly KEEP: number;
  4388. static readonly REPLACE: number;
  4389. static readonly INCR: number;
  4390. static readonly DECR: number;
  4391. static readonly INVERT: number;
  4392. static readonly INCR_WRAP: number;
  4393. static readonly DECR_WRAP: number;
  4394. static readonly ALPHA_DISABLE: number;
  4395. static readonly ALPHA_ONEONE: number;
  4396. static readonly ALPHA_ADD: number;
  4397. static readonly ALPHA_COMBINE: number;
  4398. static readonly ALPHA_SUBTRACT: number;
  4399. static readonly ALPHA_MULTIPLY: number;
  4400. static readonly ALPHA_MAXIMIZED: number;
  4401. static readonly ALPHA_PREMULTIPLIED: number;
  4402. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  4403. static readonly ALPHA_INTERPOLATE: number;
  4404. static readonly ALPHA_SCREENMODE: number;
  4405. static readonly DELAYLOADSTATE_NONE: number;
  4406. static readonly DELAYLOADSTATE_LOADED: number;
  4407. static readonly DELAYLOADSTATE_LOADING: number;
  4408. static readonly DELAYLOADSTATE_NOTLOADED: number;
  4409. static readonly TEXTUREFORMAT_ALPHA: number;
  4410. static readonly TEXTUREFORMAT_LUMINANCE: number;
  4411. /**
  4412. * R32F
  4413. */
  4414. static readonly TEXTUREFORMAT_R32F: number;
  4415. /**
  4416. * RG32F
  4417. */
  4418. static readonly TEXTUREFORMAT_RG32F: number;
  4419. /**
  4420. * RGB32F
  4421. */
  4422. static readonly TEXTUREFORMAT_RGB32F: number;
  4423. /**
  4424. * RGBA32F
  4425. */
  4426. static readonly TEXTUREFORMAT_RGBA32F: number;
  4427. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  4428. static readonly TEXTUREFORMAT_RGB: number;
  4429. static readonly TEXTUREFORMAT_RGBA: number;
  4430. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  4431. static readonly TEXTURETYPE_FLOAT: number;
  4432. static readonly TEXTURETYPE_HALF_FLOAT: number;
  4433. private static _SCALEMODE_FLOOR;
  4434. private static _SCALEMODE_NEAREST;
  4435. private static _SCALEMODE_CEILING;
  4436. static readonly SCALEMODE_FLOOR: number;
  4437. static readonly SCALEMODE_NEAREST: number;
  4438. static readonly SCALEMODE_CEILING: number;
  4439. static readonly Version: string;
  4440. static CollisionsEpsilon: number;
  4441. static CodeRepository: string;
  4442. static ShadersRepository: string;
  4443. forcePOTTextures: boolean;
  4444. isFullscreen: boolean;
  4445. isPointerLock: boolean;
  4446. cullBackFaces: boolean;
  4447. renderEvenInBackground: boolean;
  4448. preventCacheWipeBetweenFrames: boolean;
  4449. enableOfflineSupport: boolean;
  4450. scenes: Scene[];
  4451. postProcesses: PostProcess[];
  4452. /**
  4453. * Observable event triggered each time the rendering canvas is resized
  4454. */
  4455. onResizeObservable: Observable<Engine>;
  4456. /**
  4457. * Observable event triggered each time the canvas loses focus
  4458. */
  4459. onCanvasBlurObservable: Observable<Engine>;
  4460. /**
  4461. * Observable event triggered each time the canvas gains focus
  4462. */
  4463. onCanvasFocusObservable: Observable<Engine>;
  4464. /**
  4465. * Observable event triggered each time the canvas receives pointerout event
  4466. */
  4467. onCanvasPointerOutObservable: Observable<PointerEvent>;
  4468. /**
  4469. * Observable event triggered before each texture is initialized
  4470. */
  4471. onBeforeTextureInitObservable: Observable<Texture>;
  4472. private _vrDisplay;
  4473. private _vrSupported;
  4474. private _oldSize;
  4475. private _oldHardwareScaleFactor;
  4476. private _vrExclusivePointerMode;
  4477. private _webVRInitPromise;
  4478. readonly isInVRExclusivePointerMode: boolean;
  4479. disableUniformBuffers: boolean;
  4480. _uniformBuffers: UniformBuffer[];
  4481. readonly supportsUniformBuffers: boolean;
  4482. /**
  4483. * Observable raised when the engine begins a new frame
  4484. */
  4485. onBeginFrameObservable: Observable<Engine>;
  4486. /**
  4487. * Observable raised when the engine ends the current frame
  4488. */
  4489. onEndFrameObservable: Observable<Engine>;
  4490. /**
  4491. * Observable raised when the engine is about to compile a shader
  4492. */
  4493. onBeforeShaderCompilationObservable: Observable<Engine>;
  4494. /**
  4495. * Observable raised when the engine has jsut compiled a shader
  4496. */
  4497. onAfterShaderCompilationObservable: Observable<Engine>;
  4498. private _gl;
  4499. private _renderingCanvas;
  4500. private _windowIsBackground;
  4501. private _webGLVersion;
  4502. readonly needPOTTextures: boolean;
  4503. private _badOS;
  4504. readonly badOS: boolean;
  4505. private _badDesktopOS;
  4506. readonly badDesktopOS: boolean;
  4507. /**
  4508. * Gets or sets a value indicating if we want to disable texture binding optmization.
  4509. * This could be required on some buggy drivers which wants to have textures bound in a progressive order
  4510. * By default Babylon.js will try to let textures bound where they are and only update the samplers to point where the texture is.
  4511. */
  4512. disableTextureBindingOptimization: boolean;
  4513. static audioEngine: AudioEngine;
  4514. private _onFocus;
  4515. private _onBlur;
  4516. private _onCanvasPointerOut;
  4517. private _onCanvasBlur;
  4518. private _onCanvasFocus;
  4519. private _onFullscreenChange;
  4520. private _onPointerLockChange;
  4521. private _onVRDisplayPointerRestricted;
  4522. private _onVRDisplayPointerUnrestricted;
  4523. private _onVrDisplayConnect;
  4524. private _onVrDisplayDisconnect;
  4525. private _onVrDisplayPresentChange;
  4526. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  4527. onVRRequestPresentComplete: Observable<boolean>;
  4528. onVRRequestPresentStart: Observable<Engine>;
  4529. private _hardwareScalingLevel;
  4530. protected _caps: EngineCapabilities;
  4531. private _pointerLockRequested;
  4532. private _isStencilEnable;
  4533. private _colorWrite;
  4534. private _loadingScreen;
  4535. _drawCalls: PerfCounter;
  4536. _textureCollisions: PerfCounter;
  4537. private _glVersion;
  4538. private _glRenderer;
  4539. private _glVendor;
  4540. private _videoTextureSupported;
  4541. private _renderingQueueLaunched;
  4542. private _activeRenderLoops;
  4543. private _deterministicLockstep;
  4544. private _lockstepMaxSteps;
  4545. onContextLostObservable: Observable<Engine>;
  4546. onContextRestoredObservable: Observable<Engine>;
  4547. private _onContextLost;
  4548. private _onContextRestored;
  4549. private _contextWasLost;
  4550. private _doNotHandleContextLost;
  4551. private _performanceMonitor;
  4552. private _fps;
  4553. private _deltaTime;
  4554. /**
  4555. * Turn this value on if you want to pause FPS computation when in background
  4556. */
  4557. disablePerformanceMonitorInBackground: boolean;
  4558. readonly performanceMonitor: PerformanceMonitor;
  4559. protected _depthCullingState: _DepthCullingState;
  4560. protected _stencilState: _StencilState;
  4561. protected _alphaState: _AlphaState;
  4562. protected _alphaMode: number;
  4563. private _internalTexturesCache;
  4564. protected _activeChannel: number;
  4565. private _currentTextureChannel;
  4566. protected _boundTexturesCache: {
  4567. [key: string]: Nullable<InternalTexture>;
  4568. };
  4569. protected _currentEffect: Nullable<Effect>;
  4570. protected _currentProgram: Nullable<WebGLProgram>;
  4571. private _compiledEffects;
  4572. private _vertexAttribArraysEnabled;
  4573. protected _cachedViewport: Nullable<Viewport>;
  4574. private _cachedVertexArrayObject;
  4575. protected _cachedVertexBuffers: any;
  4576. protected _cachedIndexBuffer: Nullable<WebGLBuffer>;
  4577. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  4578. protected _currentRenderTarget: Nullable<InternalTexture>;
  4579. private _uintIndicesCurrentlySet;
  4580. private _currentBoundBuffer;
  4581. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  4582. private _currentBufferPointers;
  4583. private _currentInstanceLocations;
  4584. private _currentInstanceBuffers;
  4585. private _textureUnits;
  4586. private _firstBoundInternalTextureTracker;
  4587. private _lastBoundInternalTextureTracker;
  4588. private _workingCanvas;
  4589. private _workingContext;
  4590. private _rescalePostProcess;
  4591. private _dummyFramebuffer;
  4592. private _externalData;
  4593. private _bindedRenderFunction;
  4594. private _vaoRecordInProgress;
  4595. private _mustWipeVertexAttributes;
  4596. private _emptyTexture;
  4597. private _emptyCubeTexture;
  4598. private _emptyTexture3D;
  4599. private _frameHandler;
  4600. private _nextFreeTextureSlots;
  4601. private _maxSimultaneousTextures;
  4602. private _activeRequests;
  4603. private _texturesSupported;
  4604. private _textureFormatInUse;
  4605. readonly texturesSupported: Array<string>;
  4606. readonly textureFormatInUse: Nullable<string>;
  4607. readonly currentViewport: Nullable<Viewport>;
  4608. readonly emptyTexture: InternalTexture;
  4609. readonly emptyTexture3D: InternalTexture;
  4610. readonly emptyCubeTexture: InternalTexture;
  4611. /**
  4612. * @constructor
  4613. * @param canvasOrContext defines the canvas or WebGL context to use for rendering
  4614. * @param antialias defines enable antialiasing (default: false)
  4615. * @param options defines further options to be sent to the getContext() function
  4616. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  4617. */
  4618. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  4619. private _rebuildInternalTextures();
  4620. private _rebuildEffects();
  4621. private _rebuildBuffers();
  4622. private _initGLContext();
  4623. readonly webGLVersion: number;
  4624. /**
  4625. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  4626. */
  4627. readonly isStencilEnable: boolean;
  4628. private _prepareWorkingCanvas();
  4629. resetTextureCache(): void;
  4630. isDeterministicLockStep(): boolean;
  4631. getLockstepMaxSteps(): number;
  4632. getGlInfo(): {
  4633. vendor: string;
  4634. renderer: string;
  4635. version: string;
  4636. };
  4637. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  4638. getRenderWidth(useScreen?: boolean): number;
  4639. getRenderHeight(useScreen?: boolean): number;
  4640. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  4641. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  4642. setHardwareScalingLevel(level: number): void;
  4643. getHardwareScalingLevel(): number;
  4644. getLoadedTexturesCache(): InternalTexture[];
  4645. getCaps(): EngineCapabilities;
  4646. /** The number of draw calls submitted last frame */
  4647. readonly drawCalls: number;
  4648. readonly drawCallsPerfCounter: Nullable<PerfCounter>;
  4649. getDepthFunction(): Nullable<number>;
  4650. setDepthFunction(depthFunc: number): void;
  4651. setDepthFunctionToGreater(): void;
  4652. setDepthFunctionToGreaterOrEqual(): void;
  4653. setDepthFunctionToLess(): void;
  4654. setDepthFunctionToLessOrEqual(): void;
  4655. getStencilBuffer(): boolean;
  4656. setStencilBuffer(enable: boolean): void;
  4657. getStencilMask(): number;
  4658. setStencilMask(mask: number): void;
  4659. getStencilFunction(): number;
  4660. getStencilFunctionReference(): number;
  4661. getStencilFunctionMask(): number;
  4662. setStencilFunction(stencilFunc: number): void;
  4663. setStencilFunctionReference(reference: number): void;
  4664. setStencilFunctionMask(mask: number): void;
  4665. getStencilOperationFail(): number;
  4666. getStencilOperationDepthFail(): number;
  4667. getStencilOperationPass(): number;
  4668. setStencilOperationFail(operation: number): void;
  4669. setStencilOperationDepthFail(operation: number): void;
  4670. setStencilOperationPass(operation: number): void;
  4671. setDitheringState(value: boolean): void;
  4672. setRasterizerState(value: boolean): void;
  4673. /**
  4674. * stop executing a render loop function and remove it from the execution array
  4675. * @param {Function} [renderFunction] the function to be removed. If not provided all functions will be removed.
  4676. */
  4677. stopRenderLoop(renderFunction?: () => void): void;
  4678. _renderLoop(): void;
  4679. /**
  4680. * Register and execute a render loop. The engine can have more than one render function.
  4681. * @param {Function} renderFunction - the function to continuously execute starting the next render loop.
  4682. * @example
  4683. * engine.runRenderLoop(function () {
  4684. * scene.render()
  4685. * })
  4686. */
  4687. runRenderLoop(renderFunction: () => void): void;
  4688. /**
  4689. * Toggle full screen mode.
  4690. * @param {boolean} requestPointerLock - should a pointer lock be requested from the user
  4691. * @param {any} options - an options object to be sent to the requestFullscreen function
  4692. */
  4693. switchFullscreen(requestPointerLock: boolean): void;
  4694. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  4695. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  4696. /**
  4697. * Set the WebGL's viewport
  4698. * @param {BABYLON.Viewport} viewport - the viewport element to be used.
  4699. * @param {number} [requiredWidth] - the width required for rendering. If not provided the rendering canvas' width is used.
  4700. * @param {number} [requiredHeight] - the height required for rendering. If not provided the rendering canvas' height is used.
  4701. */
  4702. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  4703. /**
  4704. * Directly set the WebGL Viewport
  4705. * The x, y, width & height are directly passed to the WebGL call
  4706. * @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.
  4707. */
  4708. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  4709. beginFrame(): void;
  4710. endFrame(): void;
  4711. /**
  4712. * resize the view according to the canvas' size.
  4713. * @example
  4714. * window.addEventListener("resize", function () {
  4715. * engine.resize();
  4716. * });
  4717. */
  4718. resize(): void;
  4719. /**
  4720. * force a specific size of the canvas
  4721. * @param {number} width - the new canvas' width
  4722. * @param {number} height - the new canvas' height
  4723. */
  4724. setSize(width: number, height: number): void;
  4725. isVRDevicePresent(): boolean;
  4726. getVRDevice(): any;
  4727. /**
  4728. * Initializes a webVR display and starts listening to display change events.
  4729. * The onVRDisplayChangedObservable will be notified upon these changes.
  4730. * @returns The onVRDisplayChangedObservable.
  4731. */
  4732. initWebVR(): Observable<IDisplayChangedEventArgs>;
  4733. /**
  4734. * Initializes a webVR display and starts listening to display change events.
  4735. * The onVRDisplayChangedObservable will be notified upon these changes.
  4736. * @returns A promise containing a VRDisplay and if vr is supported.
  4737. */
  4738. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  4739. enableVR(): void;
  4740. disableVR(): void;
  4741. private _onVRFullScreenTriggered;
  4742. private _getVRDisplaysAsync();
  4743. /**
  4744. * Binds the frame buffer to the specified texture.
  4745. * @param texture The texture to render to or null for the default canvas
  4746. * @param faceIndex The face of the texture to render to in case of cube texture
  4747. * @param requiredWidth The width of the target to render to
  4748. * @param requiredHeight The height of the target to render to
  4749. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  4750. * @param depthStencilTexture The depth stencil texture to use to render
  4751. */
  4752. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture): void;
  4753. private bindUnboundFramebuffer(framebuffer);
  4754. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  4755. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  4756. generateMipMapsForCubemap(texture: InternalTexture): void;
  4757. flushFramebuffer(): void;
  4758. restoreDefaultFramebuffer(): void;
  4759. createUniformBuffer(elements: FloatArray): WebGLBuffer;
  4760. createDynamicUniformBuffer(elements: FloatArray): WebGLBuffer;
  4761. updateUniformBuffer(uniformBuffer: WebGLBuffer, elements: FloatArray, offset?: number, count?: number): void;
  4762. private _resetVertexBufferBinding();
  4763. createVertexBuffer(vertices: FloatArray): WebGLBuffer;
  4764. createDynamicVertexBuffer(vertices: FloatArray): WebGLBuffer;
  4765. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  4766. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, offset?: number, count?: number): void;
  4767. private _resetIndexBufferBinding();
  4768. createIndexBuffer(indices: IndicesArray, updatable?: boolean): WebGLBuffer;
  4769. bindArrayBuffer(buffer: Nullable<WebGLBuffer>): void;
  4770. bindUniformBuffer(buffer: Nullable<WebGLBuffer>): void;
  4771. bindUniformBufferBase(buffer: WebGLBuffer, location: number): void;
  4772. bindUniformBlock(shaderProgram: WebGLProgram, blockName: string, index: number): void;
  4773. private bindIndexBuffer(buffer);
  4774. private bindBuffer(buffer, target);
  4775. updateArrayBuffer(data: Float32Array): void;
  4776. private vertexAttribPointer(buffer, indx, size, type, normalized, stride, offset);
  4777. private _bindIndexBufferWithCache(indexBuffer);
  4778. private _bindVertexBuffersAttributes(vertexBuffers, effect);
  4779. recordVertexArrayObject(vertexBuffers: {
  4780. [key: string]: VertexBuffer;
  4781. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): WebGLVertexArrayObject;
  4782. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<WebGLBuffer>): void;
  4783. bindBuffersDirectly(vertexBuffer: WebGLBuffer, indexBuffer: WebGLBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  4784. private _unbindVertexArrayObject();
  4785. bindBuffers(vertexBuffers: {
  4786. [key: string]: Nullable<VertexBuffer>;
  4787. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): void;
  4788. unbindInstanceAttributes(): void;
  4789. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  4790. _releaseBuffer(buffer: WebGLBuffer): boolean;
  4791. createInstancesBuffer(capacity: number): WebGLBuffer;
  4792. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  4793. updateAndBindInstancesBuffer(instancesBuffer: WebGLBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  4794. applyStates(): void;
  4795. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  4796. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  4797. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  4798. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  4799. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  4800. private DrawMode(fillMode);
  4801. _releaseEffect(effect: Effect): void;
  4802. _deleteProgram(program: WebGLProgram): void;
  4803. /**
  4804. * @param baseName The base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  4805. * @param samplers An array of string used to represent textures
  4806. */
  4807. 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;
  4808. createEffectForParticles(fragmentName: string, uniformsNames?: string[], samplers?: string[], defines?: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  4809. createRawShaderProgram(vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  4810. createShaderProgram(vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  4811. private _createShaderProgram(vertexShader, fragmentShader, context, transformFeedbackVaryings?);
  4812. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  4813. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  4814. enableEffect(effect: Nullable<Effect>): void;
  4815. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  4816. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  4817. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  4818. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  4819. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  4820. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  4821. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  4822. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  4823. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  4824. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  4825. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  4826. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  4827. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  4828. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  4829. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  4830. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  4831. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  4832. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  4833. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  4834. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  4835. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  4836. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  4837. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  4838. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  4839. /**
  4840. * Sets a Color4 on a uniform variable
  4841. * @param uniform defines the uniform location
  4842. * @param color4 defines the value to be set
  4843. */
  4844. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  4845. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  4846. setZOffset(value: number): void;
  4847. getZOffset(): number;
  4848. setDepthBuffer(enable: boolean): void;
  4849. getDepthWrite(): boolean;
  4850. setDepthWrite(enable: boolean): void;
  4851. setColorWrite(enable: boolean): void;
  4852. getColorWrite(): boolean;
  4853. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  4854. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  4855. getAlphaMode(): number;
  4856. wipeCaches(bruteForce?: boolean): void;
  4857. /**
  4858. * Set the compressed texture format to use, based on the formats you have, and the formats
  4859. * supported by the hardware / browser.
  4860. *
  4861. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  4862. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  4863. * to API arguments needed to compressed textures. This puts the burden on the container
  4864. * generator to house the arcane code for determining these for current & future formats.
  4865. *
  4866. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  4867. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  4868. *
  4869. * Note: The result of this call is not taken into account when a texture is base64.
  4870. *
  4871. * @param {Array<string>} formatsAvailable- The list of those format families you have created
  4872. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  4873. *
  4874. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  4875. * @returns The extension selected.
  4876. */
  4877. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  4878. _createTexture(): WebGLTexture;
  4879. /**
  4880. * Usually called from BABYLON.Texture.ts. Passed information to create a WebGLTexture.
  4881. * @param {string} urlArg- This contains one of the following:
  4882. * 1. A conventional http URL, e.g. 'http://...' or 'file://...'
  4883. * 2. A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  4884. * 3. An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  4885. *
  4886. * @param {boolean} noMipmap- When true, no mipmaps shall be generated. Ignored for compressed textures. They must be in the file.
  4887. * @param {boolean} invertY- When true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file.
  4888. * @param {Scene} scene- Needed for loading to the correct scene.
  4889. * @param {number} samplingMode- Mode with should be used sample / access the texture. Default: TRILINEAR
  4890. * @param {callback} onLoad- Optional callback to be called upon successful completion.
  4891. * @param {callback} onError- Optional callback to be called upon failure.
  4892. * @param {ArrayBuffer | HTMLImageElement} buffer- A source of a file previously fetched as either an ArrayBuffer (compressed or image format) or HTMLImageElement (image format)
  4893. * @param {WebGLTexture} fallback- An internal argument in case the function must be called again, due to etc1 not having alpha capabilities.
  4894. * @param {number} format- Internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures.
  4895. *
  4896. * @returns {WebGLTexture} for assignment back into BABYLON.Texture
  4897. */
  4898. 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<ArrayBuffer | HTMLImageElement>, fallBack?: Nullable<InternalTexture>, format?: Nullable<number>): InternalTexture;
  4899. private _rescaleTexture(source, destination, scene, internalFormat, onComplete);
  4900. private _getInternalFormat(format);
  4901. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, type?: number): void;
  4902. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  4903. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  4904. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  4905. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  4906. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  4907. /**
  4908. * Updates a depth texture Comparison Mode and Function.
  4909. * If the comparison Function is equal to 0, the mode will be set to none.
  4910. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  4911. * @param texture The texture to set the comparison function for
  4912. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  4913. */
  4914. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  4915. private _setupDepthStencilTexture(internalTexture, size, generateStencil, bilinearFiltering, comparisonFunction);
  4916. /**
  4917. * Creates a depth stencil texture.
  4918. * This is only available in WebGL 2 or with the depth texture extension available.
  4919. * @param size The size of face edge in the texture.
  4920. * @param options The options defining the texture.
  4921. * @returns The texture
  4922. */
  4923. createDepthStencilTexture(size: number | {
  4924. width: number;
  4925. height: number;
  4926. }, options: DepthTextureCreationOptions): InternalTexture;
  4927. /**
  4928. * Creates a depth stencil cube texture.
  4929. * This is only available in WebGL 2.
  4930. * @param size The size of face edge in the cube texture.
  4931. * @param options The options defining the cube texture.
  4932. * @returns The cube texture
  4933. */
  4934. createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  4935. /**
  4936. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  4937. * @param renderTarget The render target to set the frame buffer for
  4938. */
  4939. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  4940. createRenderTargetTexture(size: number | {
  4941. width: number;
  4942. height: number;
  4943. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  4944. createMultipleRenderTarget(size: any, options: any): InternalTexture[];
  4945. private _setupFramebufferDepthAttachments(generateStencilBuffer, generateDepthBuffer, width, height, samples?);
  4946. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  4947. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  4948. _uploadDataToTexture(target: number, lod: number, internalFormat: number, width: number, height: number, format: number, type: number, data: ArrayBufferView): void;
  4949. _uploadCompressedDataToTexture(target: number, lod: number, internalFormat: number, width: number, height: number, data: ArrayBufferView): void;
  4950. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  4951. 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): InternalTexture;
  4952. 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): InternalTexture;
  4953. private setCubeMapTextureParams(gl, loadMipmap);
  4954. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>, level?: number): void;
  4955. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  4956. createRawCubeTextureFromUrl(url: string, scene: Scene, size: number, format: number, type: number, noMipmap: boolean, callback: (ArrayBuffer: ArrayBuffer) => Nullable<ArrayBufferView[]>, mipmmapGenerator: Nullable<((faces: ArrayBufferView[]) => ArrayBufferView[][])>, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, samplingMode?: number, invertY?: boolean): InternalTexture;
  4957. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>): void;
  4958. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  4959. private _prepareWebGLTextureContinuation(texture, scene, noMipmap, isCompressed, samplingMode);
  4960. private _prepareWebGLTexture(texture, scene, width, height, invertY, noMipmap, isCompressed, processFunction, samplingMode?);
  4961. private _convertRGBtoRGBATextureData(rgbData, width, height, textureType);
  4962. _releaseFramebufferObjects(texture: InternalTexture): void;
  4963. _releaseTexture(texture: InternalTexture): void;
  4964. private setProgram(program);
  4965. private _boundUniforms;
  4966. bindSamplers(effect: Effect): void;
  4967. private _moveBoundTextureOnTop(internalTexture);
  4968. private _getCorrectTextureChannel(channel, internalTexture);
  4969. private _linkTrackers(previous, next);
  4970. private _removeDesignatedSlot(internalTexture);
  4971. private _activateCurrentTexture();
  4972. protected _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean): void;
  4973. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  4974. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  4975. unbindAllTextures(): void;
  4976. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  4977. private _bindSamplerUniformToChannel(sourceSlot, destination);
  4978. private _setTexture(channel, texture, isPartOfTextureArray?);
  4979. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  4980. _setAnisotropicLevel(key: number, texture: BaseTexture): void;
  4981. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  4982. /**
  4983. * Add an externaly attached data from its key.
  4984. * This method call will fail and return false, if such key already exists.
  4985. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  4986. * @param key the unique key that identifies the data
  4987. * @param data the data object to associate to the key for this Engine instance
  4988. * @return true if no such key were already present and the data was added successfully, false otherwise
  4989. */
  4990. addExternalData<T>(key: string, data: T): boolean;
  4991. /**
  4992. * Get an externaly attached data from its key
  4993. * @param key the unique key that identifies the data
  4994. * @return the associated data, if present (can be null), or undefined if not present
  4995. */
  4996. getExternalData<T>(key: string): T;
  4997. /**
  4998. * Get an externaly attached data from its key, create it using a factory if it's not already present
  4999. * @param key the unique key that identifies the data
  5000. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  5001. * @return the associated data, can be null if the factory returned null.
  5002. */
  5003. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  5004. /**
  5005. * Remove an externaly attached data from the Engine instance
  5006. * @param key the unique key that identifies the data
  5007. * @return true if the data was successfully removed, false if it doesn't exist
  5008. */
  5009. removeExternalData(key: string): boolean;
  5010. unbindAllAttributes(): void;
  5011. releaseEffects(): void;
  5012. dispose(): void;
  5013. displayLoadingUI(): void;
  5014. hideLoadingUI(): void;
  5015. loadingScreen: ILoadingScreen;
  5016. loadingUIText: string;
  5017. loadingUIBackgroundColor: string;
  5018. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  5019. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  5020. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  5021. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  5022. getError(): number;
  5023. getFps(): number;
  5024. getDeltaTime(): number;
  5025. private _measureFps();
  5026. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number): ArrayBufferView;
  5027. private _canRenderToFloatFramebuffer();
  5028. private _canRenderToHalfFloatFramebuffer();
  5029. private _canRenderToFramebuffer(type);
  5030. _getWebGLTextureType(type: number): number;
  5031. /** @ignore */
  5032. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  5033. _getRGBAMultiSampleBufferFormat(type: number): number;
  5034. createQuery(): WebGLQuery;
  5035. deleteQuery(query: WebGLQuery): Engine;
  5036. isQueryResultAvailable(query: WebGLQuery): boolean;
  5037. getQueryResult(query: WebGLQuery): number;
  5038. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  5039. endOcclusionQuery(algorithmType: number): Engine;
  5040. private _createTimeQuery();
  5041. private _deleteTimeQuery(query);
  5042. private _getTimeQueryResult(query);
  5043. private _getTimeQueryAvailability(query);
  5044. private _currentNonTimestampToken;
  5045. startTimeQuery(): Nullable<_TimeToken>;
  5046. endTimeQuery(token: _TimeToken): int;
  5047. private getGlAlgorithmType(algorithmType);
  5048. createTransformFeedback(): WebGLTransformFeedback;
  5049. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  5050. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  5051. beginTransformFeedback(usePoints?: boolean): void;
  5052. endTransformFeedback(): void;
  5053. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  5054. bindTransformFeedbackBuffer(value: Nullable<WebGLBuffer>): void;
  5055. _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;
  5056. /** @ignore */
  5057. _loadFileAsync(url: string, database?: Database, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  5058. private _partialLoadFile(url, index, loadedFiles, scene, onfinish, onErrorCallBack?);
  5059. private _cascadeLoadFiles(scene, onfinish, files, onError?);
  5060. static isSupported(): boolean;
  5061. }
  5062. }
  5063. declare module BABYLON {
  5064. class NullEngineOptions {
  5065. renderWidth: number;
  5066. renderHeight: number;
  5067. textureSize: number;
  5068. deterministicLockstep: boolean;
  5069. lockstepMaxSteps: number;
  5070. }
  5071. /**
  5072. * The null engine class provides support for headless version of babylon.js.
  5073. * This can be used in server side scenario or for testing purposes
  5074. */
  5075. class NullEngine extends Engine {
  5076. private _options;
  5077. isDeterministicLockStep(): boolean;
  5078. getLockstepMaxSteps(): number;
  5079. getHardwareScalingLevel(): number;
  5080. constructor(options?: NullEngineOptions);
  5081. createVertexBuffer(vertices: FloatArray): WebGLBuffer;
  5082. createIndexBuffer(indices: IndicesArray): WebGLBuffer;
  5083. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  5084. getRenderWidth(useScreen?: boolean): number;
  5085. getRenderHeight(useScreen?: boolean): number;
  5086. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  5087. createShaderProgram(vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  5088. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): WebGLUniformLocation[];
  5089. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  5090. bindSamplers(effect: Effect): void;
  5091. enableEffect(effect: Effect): void;
  5092. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  5093. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  5094. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  5095. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  5096. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  5097. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  5098. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  5099. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  5100. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  5101. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  5102. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  5103. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  5104. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  5105. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  5106. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  5107. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  5108. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  5109. setFloat(uniform: WebGLUniformLocation, value: number): void;
  5110. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  5111. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  5112. setBool(uniform: WebGLUniformLocation, bool: number): void;
  5113. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  5114. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  5115. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  5116. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  5117. bindBuffers(vertexBuffers: {
  5118. [key: string]: VertexBuffer;
  5119. }, indexBuffer: WebGLBuffer, effect: Effect): void;
  5120. wipeCaches(bruteForce?: boolean): void;
  5121. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  5122. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  5123. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  5124. _createTexture(): WebGLTexture;
  5125. 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;
  5126. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  5127. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  5128. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  5129. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  5130. createDynamicVertexBuffer(vertices: FloatArray): WebGLBuffer;
  5131. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  5132. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, offset?: number, count?: number): void;
  5133. protected _bindTextureDirectly(target: number, texture: InternalTexture): void;
  5134. _bindTexture(channel: number, texture: InternalTexture): void;
  5135. _releaseBuffer(buffer: WebGLBuffer): boolean;
  5136. }
  5137. }
  5138. interface WebGLRenderingContext {
  5139. readonly RASTERIZER_DISCARD: number;
  5140. readonly DEPTH_COMPONENT24: number;
  5141. readonly TEXTURE_3D: number;
  5142. readonly TEXTURE_2D_ARRAY: number;
  5143. readonly TEXTURE_COMPARE_FUNC: number;
  5144. readonly TEXTURE_COMPARE_MODE: number;
  5145. readonly COMPARE_REF_TO_TEXTURE: number;
  5146. readonly TEXTURE_WRAP_R: number;
  5147. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  5148. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  5149. 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;
  5150. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  5151. readonly TRANSFORM_FEEDBACK: number;
  5152. readonly INTERLEAVED_ATTRIBS: number;
  5153. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  5154. createTransformFeedback(): WebGLTransformFeedback;
  5155. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  5156. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  5157. beginTransformFeedback(primitiveMode: number): void;
  5158. endTransformFeedback(): void;
  5159. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  5160. }
  5161. interface ImageBitmap {
  5162. readonly width: number;
  5163. readonly height: number;
  5164. close(): void;
  5165. }
  5166. interface WebGLQuery extends WebGLObject {
  5167. }
  5168. declare var WebGLQuery: {
  5169. prototype: WebGLQuery;
  5170. new (): WebGLQuery;
  5171. };
  5172. interface WebGLSampler extends WebGLObject {
  5173. }
  5174. declare var WebGLSampler: {
  5175. prototype: WebGLSampler;
  5176. new (): WebGLSampler;
  5177. };
  5178. interface WebGLSync extends WebGLObject {
  5179. }
  5180. declare var WebGLSync: {
  5181. prototype: WebGLSync;
  5182. new (): WebGLSync;
  5183. };
  5184. interface WebGLTransformFeedback extends WebGLObject {
  5185. }
  5186. declare var WebGLTransformFeedback: {
  5187. prototype: WebGLTransformFeedback;
  5188. new (): WebGLTransformFeedback;
  5189. };
  5190. interface WebGLVertexArrayObject extends WebGLObject {
  5191. }
  5192. declare var WebGLVertexArrayObject: {
  5193. prototype: WebGLVertexArrayObject;
  5194. new (): WebGLVertexArrayObject;
  5195. };
  5196. declare module BABYLON {
  5197. class KeyboardEventTypes {
  5198. static _KEYDOWN: number;
  5199. static _KEYUP: number;
  5200. static readonly KEYDOWN: number;
  5201. static readonly KEYUP: number;
  5202. }
  5203. class KeyboardInfo {
  5204. type: number;
  5205. event: KeyboardEvent;
  5206. constructor(type: number, event: KeyboardEvent);
  5207. }
  5208. /**
  5209. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  5210. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  5211. */
  5212. class KeyboardInfoPre extends KeyboardInfo {
  5213. constructor(type: number, event: KeyboardEvent);
  5214. skipOnPointerObservable: boolean;
  5215. }
  5216. }
  5217. declare module BABYLON {
  5218. class PointerEventTypes {
  5219. static _POINTERDOWN: number;
  5220. static _POINTERUP: number;
  5221. static _POINTERMOVE: number;
  5222. static _POINTERWHEEL: number;
  5223. static _POINTERPICK: number;
  5224. static _POINTERTAP: number;
  5225. static _POINTERDOUBLETAP: number;
  5226. static readonly POINTERDOWN: number;
  5227. static readonly POINTERUP: number;
  5228. static readonly POINTERMOVE: number;
  5229. static readonly POINTERWHEEL: number;
  5230. static readonly POINTERPICK: number;
  5231. static readonly POINTERTAP: number;
  5232. static readonly POINTERDOUBLETAP: number;
  5233. }
  5234. class PointerInfoBase {
  5235. type: number;
  5236. event: PointerEvent | MouseWheelEvent;
  5237. constructor(type: number, event: PointerEvent | MouseWheelEvent);
  5238. }
  5239. /**
  5240. * This class is used to store pointer related info for the onPrePointerObservable event.
  5241. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  5242. */
  5243. class PointerInfoPre extends PointerInfoBase {
  5244. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  5245. localPosition: Vector2;
  5246. skipOnPointerObservable: boolean;
  5247. }
  5248. /**
  5249. * This type contains all the data related to a pointer event in Babylon.js.
  5250. * 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.
  5251. */
  5252. class PointerInfo extends PointerInfoBase {
  5253. pickInfo: Nullable<PickingInfo>;
  5254. constructor(type: number, event: PointerEvent | MouseWheelEvent, pickInfo: Nullable<PickingInfo>);
  5255. }
  5256. }
  5257. declare module BABYLON {
  5258. /**
  5259. * Represents the different options available during the creation of
  5260. * a Environment helper.
  5261. *
  5262. * This can control the default ground, skybox and image processing setup of your scene.
  5263. */
  5264. interface IEnvironmentHelperOptions {
  5265. /**
  5266. * Specifies wether or not to create a ground.
  5267. * True by default.
  5268. */
  5269. createGround: boolean;
  5270. /**
  5271. * Specifies the ground size.
  5272. * 15 by default.
  5273. */
  5274. groundSize: number;
  5275. /**
  5276. * The texture used on the ground for the main color.
  5277. * Comes from the BabylonJS CDN by default.
  5278. *
  5279. * Remarks: Can be either a texture or a url.
  5280. */
  5281. groundTexture: string | BaseTexture;
  5282. /**
  5283. * The color mixed in the ground texture by default.
  5284. * BabylonJS clearColor by default.
  5285. */
  5286. groundColor: Color3;
  5287. /**
  5288. * Specifies the ground opacity.
  5289. * 1 by default.
  5290. */
  5291. groundOpacity: number;
  5292. /**
  5293. * Enables the ground to receive shadows.
  5294. * True by default.
  5295. */
  5296. enableGroundShadow: boolean;
  5297. /**
  5298. * Helps preventing the shadow to be fully black on the ground.
  5299. * 0.5 by default.
  5300. */
  5301. groundShadowLevel: number;
  5302. /**
  5303. * Creates a mirror texture attach to the ground.
  5304. * false by default.
  5305. */
  5306. enableGroundMirror: boolean;
  5307. /**
  5308. * Specifies the ground mirror size ratio.
  5309. * 0.3 by default as the default kernel is 64.
  5310. */
  5311. groundMirrorSizeRatio: number;
  5312. /**
  5313. * Specifies the ground mirror blur kernel size.
  5314. * 64 by default.
  5315. */
  5316. groundMirrorBlurKernel: number;
  5317. /**
  5318. * Specifies the ground mirror visibility amount.
  5319. * 1 by default
  5320. */
  5321. groundMirrorAmount: number;
  5322. /**
  5323. * Specifies the ground mirror reflectance weight.
  5324. * This uses the standard weight of the background material to setup the fresnel effect
  5325. * of the mirror.
  5326. * 1 by default.
  5327. */
  5328. groundMirrorFresnelWeight: number;
  5329. /**
  5330. * Specifies the ground mirror Falloff distance.
  5331. * This can helps reducing the size of the reflection.
  5332. * 0 by Default.
  5333. */
  5334. groundMirrorFallOffDistance: number;
  5335. /**
  5336. * Specifies the ground mirror texture type.
  5337. * Unsigned Int by Default.
  5338. */
  5339. groundMirrorTextureType: number;
  5340. /**
  5341. * Specifies a bias applied to the ground vertical position to prevent z-fighyting with
  5342. * the shown objects.
  5343. */
  5344. groundYBias: number;
  5345. /**
  5346. * Specifies wether or not to create a skybox.
  5347. * True by default.
  5348. */
  5349. createSkybox: boolean;
  5350. /**
  5351. * Specifies the skybox size.
  5352. * 20 by default.
  5353. */
  5354. skyboxSize: number;
  5355. /**
  5356. * The texture used on the skybox for the main color.
  5357. * Comes from the BabylonJS CDN by default.
  5358. *
  5359. * Remarks: Can be either a texture or a url.
  5360. */
  5361. skyboxTexture: string | BaseTexture;
  5362. /**
  5363. * The color mixed in the skybox texture by default.
  5364. * BabylonJS clearColor by default.
  5365. */
  5366. skyboxColor: Color3;
  5367. /**
  5368. * The background rotation around the Y axis of the scene.
  5369. * This helps aligning the key lights of your scene with the background.
  5370. * 0 by default.
  5371. */
  5372. backgroundYRotation: number;
  5373. /**
  5374. * Compute automatically the size of the elements to best fit with the scene.
  5375. */
  5376. sizeAuto: boolean;
  5377. /**
  5378. * Default position of the rootMesh if autoSize is not true.
  5379. */
  5380. rootPosition: Vector3;
  5381. /**
  5382. * Sets up the image processing in the scene.
  5383. * true by default.
  5384. */
  5385. setupImageProcessing: boolean;
  5386. /**
  5387. * The texture used as your environment texture in the scene.
  5388. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  5389. *
  5390. * Remarks: Can be either a texture or a url.
  5391. */
  5392. environmentTexture: string | BaseTexture;
  5393. /**
  5394. * The value of the exposure to apply to the scene.
  5395. * 0.6 by default if setupImageProcessing is true.
  5396. */
  5397. cameraExposure: number;
  5398. /**
  5399. * The value of the contrast to apply to the scene.
  5400. * 1.6 by default if setupImageProcessing is true.
  5401. */
  5402. cameraContrast: number;
  5403. /**
  5404. * Specifies wether or not tonemapping should be enabled in the scene.
  5405. * true by default if setupImageProcessing is true.
  5406. */
  5407. toneMappingEnabled: boolean;
  5408. }
  5409. /**
  5410. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  5411. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  5412. * It also helps with the default setup of your imageProcessing configuration.
  5413. */
  5414. class EnvironmentHelper {
  5415. /**
  5416. * Default ground texture URL.
  5417. */
  5418. private static _groundTextureCDNUrl;
  5419. /**
  5420. * Default skybox texture URL.
  5421. */
  5422. private static _skyboxTextureCDNUrl;
  5423. /**
  5424. * Default environment texture URL.
  5425. */
  5426. private static _environmentTextureCDNUrl;
  5427. /**
  5428. * Creates the default options for the helper.
  5429. */
  5430. private static _getDefaultOptions();
  5431. private _rootMesh;
  5432. /**
  5433. * Gets the root mesh created by the helper.
  5434. */
  5435. readonly rootMesh: Mesh;
  5436. private _skybox;
  5437. /**
  5438. * Gets the skybox created by the helper.
  5439. */
  5440. readonly skybox: Nullable<Mesh>;
  5441. private _skyboxTexture;
  5442. /**
  5443. * Gets the skybox texture created by the helper.
  5444. */
  5445. readonly skyboxTexture: Nullable<BaseTexture>;
  5446. private _skyboxMaterial;
  5447. /**
  5448. * Gets the skybox material created by the helper.
  5449. */
  5450. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  5451. private _ground;
  5452. /**
  5453. * Gets the ground mesh created by the helper.
  5454. */
  5455. readonly ground: Nullable<Mesh>;
  5456. private _groundTexture;
  5457. /**
  5458. * Gets the ground texture created by the helper.
  5459. */
  5460. readonly groundTexture: Nullable<BaseTexture>;
  5461. private _groundMirror;
  5462. /**
  5463. * Gets the ground mirror created by the helper.
  5464. */
  5465. readonly groundMirror: Nullable<MirrorTexture>;
  5466. /**
  5467. * Gets the ground mirror render list to helps pushing the meshes
  5468. * you wish in the ground reflection.
  5469. */
  5470. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  5471. private _groundMaterial;
  5472. /**
  5473. * Gets the ground material created by the helper.
  5474. */
  5475. readonly groundMaterial: Nullable<BackgroundMaterial>;
  5476. /**
  5477. * Stores the creation options.
  5478. */
  5479. private readonly _scene;
  5480. private _options;
  5481. /**
  5482. * constructor
  5483. * @param options
  5484. * @param scene The scene to add the material to
  5485. */
  5486. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  5487. /**
  5488. * Updates the background according to the new options
  5489. * @param options
  5490. */
  5491. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  5492. /**
  5493. * Sets the primary color of all the available elements.
  5494. * @param color
  5495. */
  5496. setMainColor(color: Color3): void;
  5497. /**
  5498. * Setup the image processing according to the specified options.
  5499. */
  5500. private _setupImageProcessing();
  5501. /**
  5502. * Setup the environment texture according to the specified options.
  5503. */
  5504. private _setupEnvironmentTexture();
  5505. /**
  5506. * Setup the background according to the specified options.
  5507. */
  5508. private _setupBackground();
  5509. /**
  5510. * Get the scene sizes according to the setup.
  5511. */
  5512. private _getSceneSize();
  5513. /**
  5514. * Setup the ground according to the specified options.
  5515. */
  5516. private _setupGround(sceneSize);
  5517. /**
  5518. * Setup the ground material according to the specified options.
  5519. */
  5520. private _setupGroundMaterial();
  5521. /**
  5522. * Setup the ground diffuse texture according to the specified options.
  5523. */
  5524. private _setupGroundDiffuseTexture();
  5525. /**
  5526. * Setup the ground mirror texture according to the specified options.
  5527. */
  5528. private _setupGroundMirrorTexture(sceneSize);
  5529. /**
  5530. * Setup the ground to receive the mirror texture.
  5531. */
  5532. private _setupMirrorInGroundMaterial();
  5533. /**
  5534. * Setup the skybox according to the specified options.
  5535. */
  5536. private _setupSkybox(sceneSize);
  5537. /**
  5538. * Setup the skybox material according to the specified options.
  5539. */
  5540. private _setupSkyboxMaterial();
  5541. /**
  5542. * Setup the skybox reflection texture according to the specified options.
  5543. */
  5544. private _setupSkyboxReflectionTexture();
  5545. /**
  5546. * Dispose all the elements created by the Helper.
  5547. */
  5548. dispose(): void;
  5549. }
  5550. }
  5551. declare module BABYLON {
  5552. /**
  5553. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  5554. * As a subclass of Node, this allow parenting to the camera or multiple videos with different locations in the scene.
  5555. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  5556. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  5557. */
  5558. class VideoDome extends Node {
  5559. /**
  5560. * The video texture being displayed on the sphere
  5561. */
  5562. protected _videoTexture: VideoTexture;
  5563. /**
  5564. * The skybox material
  5565. */
  5566. protected _material: BackgroundMaterial;
  5567. /**
  5568. * The surface used for the skybox
  5569. */
  5570. protected _mesh: Mesh;
  5571. /**
  5572. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  5573. * Also see the options.resolution property.
  5574. */
  5575. fovMultiplier: number;
  5576. /**
  5577. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  5578. * @param name Element's name, child elements will append suffixes for their own names.
  5579. * @param urlsOrVideo
  5580. * @param options An object containing optional or exposed sub element properties:
  5581. * @param options **resolution=12** Integer, lower resolutions have more artifacts at extreme fovs
  5582. * @param options **clickToPlay=false** Add a click to play listener to the video, does not prevent autoplay.
  5583. * @param options **autoPlay=true** Automatically attempt to being playing the video.
  5584. * @param options **loop=true** Automatically loop video on end.
  5585. * @param options **size=1000** Physical radius to create the dome at, defaults to approximately half the far clip plane.
  5586. */
  5587. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  5588. resolution?: number;
  5589. clickToPlay?: boolean;
  5590. autoPlay?: boolean;
  5591. loop?: boolean;
  5592. size?: number;
  5593. }, scene: Scene);
  5594. /**
  5595. * Releases all associated resources
  5596. */
  5597. dispose(): void;
  5598. }
  5599. }
  5600. declare module BABYLON {
  5601. class StickValues {
  5602. x: number;
  5603. y: number;
  5604. constructor(x: number, y: number);
  5605. }
  5606. interface GamepadButtonChanges {
  5607. changed: boolean;
  5608. pressChanged: boolean;
  5609. touchChanged: boolean;
  5610. valueChanged: boolean;
  5611. }
  5612. class Gamepad {
  5613. id: string;
  5614. index: number;
  5615. browserGamepad: any;
  5616. type: number;
  5617. private _leftStick;
  5618. private _rightStick;
  5619. _isConnected: boolean;
  5620. private _leftStickAxisX;
  5621. private _leftStickAxisY;
  5622. private _rightStickAxisX;
  5623. private _rightStickAxisY;
  5624. private _onleftstickchanged;
  5625. private _onrightstickchanged;
  5626. static GAMEPAD: number;
  5627. static GENERIC: number;
  5628. static XBOX: number;
  5629. static POSE_ENABLED: number;
  5630. protected _invertLeftStickY: boolean;
  5631. readonly isConnected: boolean;
  5632. constructor(id: string, index: number, browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  5633. onleftstickchanged(callback: (values: StickValues) => void): void;
  5634. onrightstickchanged(callback: (values: StickValues) => void): void;
  5635. leftStick: StickValues;
  5636. rightStick: StickValues;
  5637. update(): void;
  5638. dispose(): void;
  5639. }
  5640. class GenericPad extends Gamepad {
  5641. private _buttons;
  5642. private _onbuttondown;
  5643. private _onbuttonup;
  5644. onButtonDownObservable: Observable<number>;
  5645. onButtonUpObservable: Observable<number>;
  5646. onbuttondown(callback: (buttonPressed: number) => void): void;
  5647. onbuttonup(callback: (buttonReleased: number) => void): void;
  5648. constructor(id: string, index: number, browserGamepad: any);
  5649. private _setButtonValue(newValue, currentValue, buttonIndex);
  5650. update(): void;
  5651. dispose(): void;
  5652. }
  5653. }
  5654. declare module BABYLON {
  5655. class GamepadManager {
  5656. private _scene;
  5657. private _babylonGamepads;
  5658. private _oneGamepadConnected;
  5659. _isMonitoring: boolean;
  5660. private _gamepadEventSupported;
  5661. private _gamepadSupport;
  5662. onGamepadConnectedObservable: Observable<Gamepad>;
  5663. onGamepadDisconnectedObservable: Observable<Gamepad>;
  5664. private _onGamepadConnectedEvent;
  5665. private _onGamepadDisconnectedEvent;
  5666. constructor(_scene?: Scene | undefined);
  5667. readonly gamepads: Gamepad[];
  5668. getGamepadByType(type?: number): Nullable<Gamepad>;
  5669. dispose(): void;
  5670. private _addNewGamepad(gamepad);
  5671. private _startMonitoringGamepads();
  5672. private _stopMonitoringGamepads();
  5673. _checkGamepadsStatus(): void;
  5674. private _updateGamepadObjects();
  5675. }
  5676. }
  5677. declare module BABYLON {
  5678. enum Xbox360Button {
  5679. A = 0,
  5680. B = 1,
  5681. X = 2,
  5682. Y = 3,
  5683. Start = 4,
  5684. Back = 5,
  5685. LB = 6,
  5686. RB = 7,
  5687. LeftStick = 8,
  5688. RightStick = 9,
  5689. }
  5690. enum Xbox360Dpad {
  5691. Up = 0,
  5692. Down = 1,
  5693. Left = 2,
  5694. Right = 3,
  5695. }
  5696. class Xbox360Pad extends Gamepad {
  5697. private _leftTrigger;
  5698. private _rightTrigger;
  5699. private _onlefttriggerchanged;
  5700. private _onrighttriggerchanged;
  5701. private _onbuttondown;
  5702. private _onbuttonup;
  5703. private _ondpaddown;
  5704. private _ondpadup;
  5705. onButtonDownObservable: Observable<Xbox360Button>;
  5706. onButtonUpObservable: Observable<Xbox360Button>;
  5707. onPadDownObservable: Observable<Xbox360Dpad>;
  5708. onPadUpObservable: Observable<Xbox360Dpad>;
  5709. private _buttonA;
  5710. private _buttonB;
  5711. private _buttonX;
  5712. private _buttonY;
  5713. private _buttonBack;
  5714. private _buttonStart;
  5715. private _buttonLB;
  5716. private _buttonRB;
  5717. private _buttonLeftStick;
  5718. private _buttonRightStick;
  5719. private _dPadUp;
  5720. private _dPadDown;
  5721. private _dPadLeft;
  5722. private _dPadRight;
  5723. private _isXboxOnePad;
  5724. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  5725. onlefttriggerchanged(callback: (value: number) => void): void;
  5726. onrighttriggerchanged(callback: (value: number) => void): void;
  5727. leftTrigger: number;
  5728. rightTrigger: number;
  5729. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  5730. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  5731. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  5732. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  5733. private _setButtonValue(newValue, currentValue, buttonType);
  5734. private _setDPadValue(newValue, currentValue, buttonType);
  5735. buttonA: number;
  5736. buttonB: number;
  5737. buttonX: number;
  5738. buttonY: number;
  5739. buttonStart: number;
  5740. buttonBack: number;
  5741. buttonLB: number;
  5742. buttonRB: number;
  5743. buttonLeftStick: number;
  5744. buttonRightStick: number;
  5745. dPadUp: number;
  5746. dPadDown: number;
  5747. dPadLeft: number;
  5748. dPadRight: number;
  5749. update(): void;
  5750. dispose(): void;
  5751. }
  5752. }
  5753. declare module BABYLON {
  5754. /**
  5755. * This class can be used to get instrumentation data from a Babylon engine
  5756. */
  5757. class EngineInstrumentation implements IDisposable {
  5758. engine: Engine;
  5759. private _captureGPUFrameTime;
  5760. private _gpuFrameTimeToken;
  5761. private _gpuFrameTime;
  5762. private _captureShaderCompilationTime;
  5763. private _shaderCompilationTime;
  5764. private _onBeginFrameObserver;
  5765. private _onEndFrameObserver;
  5766. private _onBeforeShaderCompilationObserver;
  5767. private _onAfterShaderCompilationObserver;
  5768. /**
  5769. * Gets the perf counter used for GPU frame time
  5770. */
  5771. readonly gpuFrameTimeCounter: PerfCounter;
  5772. /**
  5773. * Gets the GPU frame time capture status
  5774. */
  5775. /**
  5776. * Enable or disable the GPU frame time capture
  5777. */
  5778. captureGPUFrameTime: boolean;
  5779. /**
  5780. * Gets the perf counter used for shader compilation time
  5781. */
  5782. readonly shaderCompilationTimeCounter: PerfCounter;
  5783. /**
  5784. * Gets the shader compilation time capture status
  5785. */
  5786. /**
  5787. * Enable or disable the shader compilation time capture
  5788. */
  5789. captureShaderCompilationTime: boolean;
  5790. constructor(engine: Engine);
  5791. dispose(): void;
  5792. }
  5793. }
  5794. declare module BABYLON {
  5795. /**
  5796. * This class can be used to get instrumentation data from a Babylon engine
  5797. */
  5798. class SceneInstrumentation implements IDisposable {
  5799. scene: Scene;
  5800. private _captureActiveMeshesEvaluationTime;
  5801. private _activeMeshesEvaluationTime;
  5802. private _captureRenderTargetsRenderTime;
  5803. private _renderTargetsRenderTime;
  5804. private _captureFrameTime;
  5805. private _frameTime;
  5806. private _captureRenderTime;
  5807. private _renderTime;
  5808. private _captureInterFrameTime;
  5809. private _interFrameTime;
  5810. private _captureParticlesRenderTime;
  5811. private _particlesRenderTime;
  5812. private _captureSpritesRenderTime;
  5813. private _spritesRenderTime;
  5814. private _capturePhysicsTime;
  5815. private _physicsTime;
  5816. private _captureAnimationsTime;
  5817. private _animationsTime;
  5818. private _onBeforeActiveMeshesEvaluationObserver;
  5819. private _onAfterActiveMeshesEvaluationObserver;
  5820. private _onBeforeRenderTargetsRenderObserver;
  5821. private _onAfterRenderTargetsRenderObserver;
  5822. private _onAfterRenderObserver;
  5823. private _onBeforeDrawPhaseObserver;
  5824. private _onAfterDrawPhaseObserver;
  5825. private _onBeforeAnimationsObserver;
  5826. private _onBeforeParticlesRenderingObserver;
  5827. private _onAfterParticlesRenderingObserver;
  5828. private _onBeforeSpritesRenderingObserver;
  5829. private _onAfterSpritesRenderingObserver;
  5830. private _onBeforePhysicsObserver;
  5831. private _onAfterPhysicsObserver;
  5832. private _onAfterAnimationsObserver;
  5833. /**
  5834. * Gets the perf counter used for active meshes evaluation time
  5835. */
  5836. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  5837. /**
  5838. * Gets the active meshes evaluation time capture status
  5839. */
  5840. /**
  5841. * Enable or disable the active meshes evaluation time capture
  5842. */
  5843. captureActiveMeshesEvaluationTime: boolean;
  5844. /**
  5845. * Gets the perf counter used for render targets render time
  5846. */
  5847. readonly renderTargetsRenderTimeCounter: PerfCounter;
  5848. /**
  5849. * Gets the render targets render time capture status
  5850. */
  5851. /**
  5852. * Enable or disable the render targets render time capture
  5853. */
  5854. captureRenderTargetsRenderTime: boolean;
  5855. /**
  5856. * Gets the perf counter used for particles render time
  5857. */
  5858. readonly particlesRenderTimeCounter: PerfCounter;
  5859. /**
  5860. * Gets the particles render time capture status
  5861. */
  5862. /**
  5863. * Enable or disable the particles render time capture
  5864. */
  5865. captureParticlesRenderTime: boolean;
  5866. /**
  5867. * Gets the perf counter used for sprites render time
  5868. */
  5869. readonly spritesRenderTimeCounter: PerfCounter;
  5870. /**
  5871. * Gets the sprites render time capture status
  5872. */
  5873. /**
  5874. * Enable or disable the sprites render time capture
  5875. */
  5876. captureSpritesRenderTime: boolean;
  5877. /**
  5878. * Gets the perf counter used for physics time
  5879. */
  5880. readonly physicsTimeCounter: PerfCounter;
  5881. /**
  5882. * Gets the physics time capture status
  5883. */
  5884. /**
  5885. * Enable or disable the physics time capture
  5886. */
  5887. capturePhysicsTime: boolean;
  5888. /**
  5889. * Gets the perf counter used for animations time
  5890. */
  5891. readonly animationsTimeCounter: PerfCounter;
  5892. /**
  5893. * Gets the animations time capture status
  5894. */
  5895. /**
  5896. * Enable or disable the animations time capture
  5897. */
  5898. captureAnimationsTime: boolean;
  5899. /**
  5900. * Gets the perf counter used for frame time capture
  5901. */
  5902. readonly frameTimeCounter: PerfCounter;
  5903. /**
  5904. * Gets the frame time capture status
  5905. */
  5906. /**
  5907. * Enable or disable the frame time capture
  5908. */
  5909. captureFrameTime: boolean;
  5910. /**
  5911. * Gets the perf counter used for inter-frames time capture
  5912. */
  5913. readonly interFrameTimeCounter: PerfCounter;
  5914. /**
  5915. * Gets the inter-frames time capture status
  5916. */
  5917. /**
  5918. * Enable or disable the inter-frames time capture
  5919. */
  5920. captureInterFrameTime: boolean;
  5921. /**
  5922. * Gets the perf counter used for render time capture
  5923. */
  5924. readonly renderTimeCounter: PerfCounter;
  5925. /**
  5926. * Gets the render time capture status
  5927. */
  5928. /**
  5929. * Enable or disable the render time capture
  5930. */
  5931. captureRenderTime: boolean;
  5932. /**
  5933. * Gets the perf counter used for draw calls
  5934. */
  5935. readonly drawCallsCounter: PerfCounter;
  5936. /**
  5937. * Gets the perf counter used for texture collisions
  5938. */
  5939. readonly textureCollisionsCounter: PerfCounter;
  5940. constructor(scene: Scene);
  5941. dispose(): void;
  5942. }
  5943. }
  5944. declare module BABYLON {
  5945. class _TimeToken {
  5946. _startTimeQuery: Nullable<WebGLQuery>;
  5947. _endTimeQuery: Nullable<WebGLQuery>;
  5948. _timeElapsedQuery: Nullable<WebGLQuery>;
  5949. _timeElapsedQueryEnded: boolean;
  5950. }
  5951. }
  5952. declare module BABYLON {
  5953. /**
  5954. * Effect layer options. This helps customizing the behaviour
  5955. * of the effect layer.
  5956. */
  5957. interface IEffectLayerOptions {
  5958. /**
  5959. * Multiplication factor apply to the canvas size to compute the render target size
  5960. * used to generated the objects (the smaller the faster).
  5961. */
  5962. mainTextureRatio: number;
  5963. /**
  5964. * Enforces a fixed size texture to ensure effect stability across devices.
  5965. */
  5966. mainTextureFixedSize?: number;
  5967. /**
  5968. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  5969. */
  5970. alphaBlendingMode: number;
  5971. /**
  5972. * The camera attached to the layer.
  5973. */
  5974. camera: Nullable<Camera>;
  5975. }
  5976. /**
  5977. * The effect layer Helps adding post process effect blended with the main pass.
  5978. *
  5979. * This can be for instance use to generate glow or higlight effects on the scene.
  5980. *
  5981. * The effect layer class can not be used directly and is intented to inherited from to be
  5982. * customized per effects.
  5983. */
  5984. abstract class EffectLayer {
  5985. /** The Friendly of the effect in the scene */
  5986. name: string;
  5987. private _vertexBuffers;
  5988. private _indexBuffer;
  5989. private _cachedDefines;
  5990. private _effectLayerMapGenerationEffect;
  5991. private _effectLayerOptions;
  5992. private _mergeEffect;
  5993. protected _scene: Scene;
  5994. protected _engine: Engine;
  5995. protected _maxSize: number;
  5996. protected _mainTextureDesiredSize: ISize;
  5997. protected _mainTexture: RenderTargetTexture;
  5998. protected _shouldRender: boolean;
  5999. protected _postProcesses: PostProcess[];
  6000. protected _textures: BaseTexture[];
  6001. protected _emissiveTextureAndColor: {
  6002. texture: Nullable<BaseTexture>;
  6003. color: Color4;
  6004. };
  6005. /**
  6006. * The clear color of the texture used to generate the glow map.
  6007. */
  6008. neutralColor: Color4;
  6009. /**
  6010. * Specifies wether the highlight layer is enabled or not.
  6011. */
  6012. isEnabled: boolean;
  6013. /**
  6014. * Gets the camera attached to the layer.
  6015. */
  6016. readonly camera: Nullable<Camera>;
  6017. /**
  6018. * An event triggered when the effect layer has been disposed.
  6019. */
  6020. onDisposeObservable: Observable<EffectLayer>;
  6021. /**
  6022. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  6023. */
  6024. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  6025. /**
  6026. * An event triggered when the generated texture is being merged in the scene.
  6027. */
  6028. onBeforeComposeObservable: Observable<EffectLayer>;
  6029. /**
  6030. * An event triggered when the generated texture has been merged in the scene.
  6031. */
  6032. onAfterComposeObservable: Observable<EffectLayer>;
  6033. /**
  6034. * An event triggered when the efffect layer changes its size.
  6035. */
  6036. onSizeChangedObservable: Observable<EffectLayer>;
  6037. /**
  6038. * Instantiates a new effect Layer and references it in the scene.
  6039. * @param name The name of the layer
  6040. * @param scene The scene to use the layer in
  6041. */
  6042. constructor(
  6043. /** The Friendly of the effect in the scene */
  6044. name: string, scene: Scene);
  6045. /**
  6046. * Get the effect name of the layer.
  6047. * @return The effect name
  6048. */
  6049. abstract getEffectName(): string;
  6050. /**
  6051. * Checks for the readiness of the element composing the layer.
  6052. * @param subMesh the mesh to check for
  6053. * @param useInstances specify wether or not to use instances to render the mesh
  6054. * @return true if ready otherwise, false
  6055. */
  6056. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  6057. /**
  6058. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  6059. * @returns true if the effect requires stencil during the main canvas render pass.
  6060. */
  6061. abstract needStencil(): boolean;
  6062. /**
  6063. * Create the merge effect. This is the shader use to blit the information back
  6064. * to the main canvas at the end of the scene rendering.
  6065. * @returns The effect containing the shader used to merge the effect on the main canvas
  6066. */
  6067. protected abstract _createMergeEffect(): Effect;
  6068. /**
  6069. * Creates the render target textures and post processes used in the effect layer.
  6070. */
  6071. protected abstract _createTextureAndPostProcesses(): void;
  6072. /**
  6073. * Implementation specific of rendering the generating effect on the main canvas.
  6074. * @param effect The effect used to render through
  6075. */
  6076. protected abstract _internalRender(effect: Effect): void;
  6077. /**
  6078. * Sets the required values for both the emissive texture and and the main color.
  6079. */
  6080. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  6081. /**
  6082. * Free any resources and references associated to a mesh.
  6083. * Internal use
  6084. * @param mesh The mesh to free.
  6085. */
  6086. abstract _disposeMesh(mesh: Mesh): void;
  6087. /**
  6088. * Initializes the effect layer with the required options.
  6089. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  6090. */
  6091. protected _init(options: Partial<IEffectLayerOptions>): void;
  6092. /**
  6093. * Generates the index buffer of the full screen quad blending to the main canvas.
  6094. */
  6095. private _generateIndexBuffer();
  6096. /**
  6097. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  6098. */
  6099. private _genrateVertexBuffer();
  6100. /**
  6101. * Sets the main texture desired size which is the closest power of two
  6102. * of the engine canvas size.
  6103. */
  6104. private _setMainTextureSize();
  6105. /**
  6106. * Creates the main texture for the effect layer.
  6107. */
  6108. protected _createMainTexture(): void;
  6109. /**
  6110. * Checks for the readiness of the element composing the layer.
  6111. * @param subMesh the mesh to check for
  6112. * @param useInstances specify wether or not to use instances to render the mesh
  6113. * @param emissiveTexture the associated emissive texture used to generate the glow
  6114. * @return true if ready otherwise, false
  6115. */
  6116. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  6117. /**
  6118. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  6119. */
  6120. render(): void;
  6121. /**
  6122. * Determine if a given mesh will be used in the current effect.
  6123. * @param mesh mesh to test
  6124. * @returns true if the mesh will be used
  6125. */
  6126. hasMesh(mesh: AbstractMesh): boolean;
  6127. /**
  6128. * Returns true if the layer contains information to display, otherwise false.
  6129. * @returns true if the glow layer should be rendered
  6130. */
  6131. shouldRender(): boolean;
  6132. /**
  6133. * Returns true if the mesh should render, otherwise false.
  6134. * @param mesh The mesh to render
  6135. * @returns true if it should render otherwise false
  6136. */
  6137. protected _shouldRenderMesh(mesh: Mesh): boolean;
  6138. /**
  6139. * Returns true if the mesh should render, otherwise false.
  6140. * @param mesh The mesh to render
  6141. * @returns true if it should render otherwise false
  6142. */
  6143. protected _shouldRenderEmissiveTextureForMesh(mesh: Mesh): boolean;
  6144. /**
  6145. * Renders the submesh passed in parameter to the generation map.
  6146. */
  6147. protected _renderSubMesh(subMesh: SubMesh): void;
  6148. /**
  6149. * Rebuild the required buffers.
  6150. * @ignore Internal use only.
  6151. */
  6152. _rebuild(): void;
  6153. /**
  6154. * Dispose only the render target textures and post process.
  6155. */
  6156. private _disposeTextureAndPostProcesses();
  6157. /**
  6158. * Dispose the highlight layer and free resources.
  6159. */
  6160. dispose(): void;
  6161. }
  6162. }
  6163. declare module BABYLON {
  6164. /**
  6165. * Glow layer options. This helps customizing the behaviour
  6166. * of the glow layer.
  6167. */
  6168. interface IGlowLayerOptions {
  6169. /**
  6170. * Multiplication factor apply to the canvas size to compute the render target size
  6171. * used to generated the glowing objects (the smaller the faster).
  6172. */
  6173. mainTextureRatio: number;
  6174. /**
  6175. * Enforces a fixed size texture to ensure resize independant blur.
  6176. */
  6177. mainTextureFixedSize?: number;
  6178. /**
  6179. * How big is the kernel of the blur texture.
  6180. */
  6181. blurKernelSize: number;
  6182. /**
  6183. * The camera attached to the layer.
  6184. */
  6185. camera: Nullable<Camera>;
  6186. /**
  6187. * Enable MSAA by chosing the number of samples.
  6188. */
  6189. mainTextureSamples?: number;
  6190. }
  6191. /**
  6192. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  6193. *
  6194. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  6195. * glowy meshes to your scene.
  6196. *
  6197. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  6198. */
  6199. class GlowLayer extends EffectLayer {
  6200. name: string;
  6201. /**
  6202. * Effect Name of the layer.
  6203. */
  6204. static readonly EffectName: string;
  6205. /**
  6206. * The default blur kernel size used for the glow.
  6207. */
  6208. static DefaultBlurKernelSize: number;
  6209. /**
  6210. * The default texture size ratio used for the glow.
  6211. */
  6212. static DefaultTextureRatio: number;
  6213. /**
  6214. * Gets the kernel size of the blur.
  6215. */
  6216. /**
  6217. * Sets the kernel size of the blur.
  6218. */
  6219. blurKernelSize: number;
  6220. /**
  6221. * Gets the glow intensity.
  6222. */
  6223. /**
  6224. * Sets the glow intensity.
  6225. */
  6226. intensity: number;
  6227. private _options;
  6228. private _intensity;
  6229. private _horizontalBlurPostprocess1;
  6230. private _verticalBlurPostprocess1;
  6231. private _horizontalBlurPostprocess2;
  6232. private _verticalBlurPostprocess2;
  6233. private _blurTexture1;
  6234. private _blurTexture2;
  6235. private _postProcesses1;
  6236. private _postProcesses2;
  6237. private _includedOnlyMeshes;
  6238. private _excludedMeshes;
  6239. /**
  6240. * Callback used to let the user override the color selection on a per mesh basis
  6241. */
  6242. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  6243. /**
  6244. * Callback used to let the user override the texture selection on a per mesh basis
  6245. */
  6246. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  6247. /**
  6248. * Instantiates a new glow Layer and references it to the scene.
  6249. * @param name The name of the layer
  6250. * @param scene The scene to use the layer in
  6251. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  6252. */
  6253. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  6254. /**
  6255. * Get the effect name of the layer.
  6256. * @return The effect name
  6257. */
  6258. getEffectName(): string;
  6259. /**
  6260. * Create the merge effect. This is the shader use to blit the information back
  6261. * to the main canvas at the end of the scene rendering.
  6262. */
  6263. protected _createMergeEffect(): Effect;
  6264. /**
  6265. * Creates the render target textures and post processes used in the glow layer.
  6266. */
  6267. protected _createTextureAndPostProcesses(): void;
  6268. /**
  6269. * Checks for the readiness of the element composing the layer.
  6270. * @param subMesh the mesh to check for
  6271. * @param useInstances specify wether or not to use instances to render the mesh
  6272. * @param emissiveTexture the associated emissive texture used to generate the glow
  6273. * @return true if ready otherwise, false
  6274. */
  6275. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  6276. /**
  6277. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  6278. */
  6279. needStencil(): boolean;
  6280. /**
  6281. * Implementation specific of rendering the generating effect on the main canvas.
  6282. * @param effect The effect used to render through
  6283. */
  6284. protected _internalRender(effect: Effect): void;
  6285. /**
  6286. * Sets the required values for both the emissive texture and and the main color.
  6287. */
  6288. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  6289. /**
  6290. * Returns true if the mesh should render, otherwise false.
  6291. * @param mesh The mesh to render
  6292. * @returns true if it should render otherwise false
  6293. */
  6294. protected _shouldRenderMesh(mesh: Mesh): boolean;
  6295. /**
  6296. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  6297. * @param mesh The mesh to exclude from the glow layer
  6298. */
  6299. addExcludedMesh(mesh: Mesh): void;
  6300. /**
  6301. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  6302. * @param mesh The mesh to remove
  6303. */
  6304. removeExcludedMesh(mesh: Mesh): void;
  6305. /**
  6306. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  6307. * @param mesh The mesh to include in the glow layer
  6308. */
  6309. addIncludedOnlyMesh(mesh: Mesh): void;
  6310. /**
  6311. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  6312. * @param mesh The mesh to remove
  6313. */
  6314. removeIncludedOnlyMesh(mesh: Mesh): void;
  6315. /**
  6316. * Determine if a given mesh will be used in the glow layer
  6317. * @param mesh The mesh to test
  6318. * @returns true if the mesh will be highlighted by the current glow layer
  6319. */
  6320. hasMesh(mesh: AbstractMesh): boolean;
  6321. /**
  6322. * Free any resources and references associated to a mesh.
  6323. * Internal use
  6324. * @param mesh The mesh to free.
  6325. */
  6326. _disposeMesh(mesh: Mesh): void;
  6327. }
  6328. }
  6329. declare module BABYLON {
  6330. /**
  6331. * Highlight layer options. This helps customizing the behaviour
  6332. * of the highlight layer.
  6333. */
  6334. interface IHighlightLayerOptions {
  6335. /**
  6336. * Multiplication factor apply to the canvas size to compute the render target size
  6337. * used to generated the glowing objects (the smaller the faster).
  6338. */
  6339. mainTextureRatio: number;
  6340. /**
  6341. * Enforces a fixed size texture to ensure resize independant blur.
  6342. */
  6343. mainTextureFixedSize?: number;
  6344. /**
  6345. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  6346. * of the picture to blur (the smaller the faster).
  6347. */
  6348. blurTextureSizeRatio: number;
  6349. /**
  6350. * How big in texel of the blur texture is the vertical blur.
  6351. */
  6352. blurVerticalSize: number;
  6353. /**
  6354. * How big in texel of the blur texture is the horizontal blur.
  6355. */
  6356. blurHorizontalSize: number;
  6357. /**
  6358. * Alpha blending mode used to apply the blur. Default is combine.
  6359. */
  6360. alphaBlendingMode: number;
  6361. /**
  6362. * The camera attached to the layer.
  6363. */
  6364. camera: Nullable<Camera>;
  6365. /**
  6366. * Should we display highlight as a solid stroke?
  6367. */
  6368. isStroke?: boolean;
  6369. }
  6370. /**
  6371. * The highlight layer Helps adding a glow effect around a mesh.
  6372. *
  6373. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  6374. * glowy meshes to your scene.
  6375. *
  6376. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  6377. */
  6378. class HighlightLayer extends EffectLayer {
  6379. name: string;
  6380. /**
  6381. * Effect Name of the highlight layer.
  6382. */
  6383. static readonly EffectName: string;
  6384. /**
  6385. * The neutral color used during the preparation of the glow effect.
  6386. * This is black by default as the blend operation is a blend operation.
  6387. */
  6388. static NeutralColor: Color4;
  6389. /**
  6390. * Stencil value used for glowing meshes.
  6391. */
  6392. static GlowingMeshStencilReference: number;
  6393. /**
  6394. * Stencil value used for the other meshes in the scene.
  6395. */
  6396. static NormalMeshStencilReference: number;
  6397. /**
  6398. * Specifies whether or not the inner glow is ACTIVE in the layer.
  6399. */
  6400. innerGlow: boolean;
  6401. /**
  6402. * Specifies whether or not the outer glow is ACTIVE in the layer.
  6403. */
  6404. outerGlow: boolean;
  6405. /**
  6406. * Gets the horizontal size of the blur.
  6407. */
  6408. /**
  6409. * Specifies the horizontal size of the blur.
  6410. */
  6411. blurHorizontalSize: number;
  6412. /**
  6413. * Gets the vertical size of the blur.
  6414. */
  6415. /**
  6416. * Specifies the vertical size of the blur.
  6417. */
  6418. blurVerticalSize: number;
  6419. /**
  6420. * An event triggered when the highlight layer is being blurred.
  6421. */
  6422. onBeforeBlurObservable: Observable<HighlightLayer>;
  6423. /**
  6424. * An event triggered when the highlight layer has been blurred.
  6425. */
  6426. onAfterBlurObservable: Observable<HighlightLayer>;
  6427. private _instanceGlowingMeshStencilReference;
  6428. private _options;
  6429. private _downSamplePostprocess;
  6430. private _horizontalBlurPostprocess;
  6431. private _verticalBlurPostprocess;
  6432. private _blurTexture;
  6433. private _meshes;
  6434. private _excludedMeshes;
  6435. /**
  6436. * Instantiates a new highlight Layer and references it to the scene..
  6437. * @param name The name of the layer
  6438. * @param scene The scene to use the layer in
  6439. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  6440. */
  6441. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  6442. /**
  6443. * Get the effect name of the layer.
  6444. * @return The effect name
  6445. */
  6446. getEffectName(): string;
  6447. /**
  6448. * Create the merge effect. This is the shader use to blit the information back
  6449. * to the main canvas at the end of the scene rendering.
  6450. */
  6451. protected _createMergeEffect(): Effect;
  6452. /**
  6453. * Creates the render target textures and post processes used in the highlight layer.
  6454. */
  6455. protected _createTextureAndPostProcesses(): void;
  6456. /**
  6457. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  6458. */
  6459. needStencil(): boolean;
  6460. /**
  6461. * Checks for the readiness of the element composing the layer.
  6462. * @param subMesh the mesh to check for
  6463. * @param useInstances specify wether or not to use instances to render the mesh
  6464. * @param emissiveTexture the associated emissive texture used to generate the glow
  6465. * @return true if ready otherwise, false
  6466. */
  6467. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  6468. /**
  6469. * Implementation specific of rendering the generating effect on the main canvas.
  6470. * @param effect The effect used to render through
  6471. */
  6472. protected _internalRender(effect: Effect): void;
  6473. /**
  6474. * Returns true if the layer contains information to display, otherwise false.
  6475. */
  6476. shouldRender(): boolean;
  6477. /**
  6478. * Returns true if the mesh should render, otherwise false.
  6479. * @param mesh The mesh to render
  6480. * @returns true if it should render otherwise false
  6481. */
  6482. protected _shouldRenderMesh(mesh: Mesh): boolean;
  6483. /**
  6484. * Sets the required values for both the emissive texture and and the main color.
  6485. */
  6486. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  6487. /**
  6488. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  6489. * @param mesh The mesh to exclude from the highlight layer
  6490. */
  6491. addExcludedMesh(mesh: Mesh): void;
  6492. /**
  6493. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  6494. * @param mesh The mesh to highlight
  6495. */
  6496. removeExcludedMesh(mesh: Mesh): void;
  6497. /**
  6498. * Determine if a given mesh will be highlighted by the current HighlightLayer
  6499. * @param mesh mesh to test
  6500. * @returns true if the mesh will be highlighted by the current HighlightLayer
  6501. */
  6502. hasMesh(mesh: AbstractMesh): boolean;
  6503. /**
  6504. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  6505. * @param mesh The mesh to highlight
  6506. * @param color The color of the highlight
  6507. * @param glowEmissiveOnly Extract the glow from the emissive texture
  6508. */
  6509. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  6510. /**
  6511. * Remove a mesh from the highlight layer in order to make it stop glowing.
  6512. * @param mesh The mesh to highlight
  6513. */
  6514. removeMesh(mesh: Mesh): void;
  6515. /**
  6516. * Force the stencil to the normal expected value for none glowing parts
  6517. */
  6518. private _defaultStencilReference(mesh);
  6519. /**
  6520. * Free any resources and references associated to a mesh.
  6521. * Internal use
  6522. * @param mesh The mesh to free.
  6523. */
  6524. _disposeMesh(mesh: Mesh): void;
  6525. /**
  6526. * Dispose the highlight layer and free resources.
  6527. */
  6528. dispose(): void;
  6529. }
  6530. }
  6531. declare module BABYLON {
  6532. class Layer {
  6533. name: string;
  6534. texture: Nullable<Texture>;
  6535. isBackground: boolean;
  6536. color: Color4;
  6537. scale: Vector2;
  6538. offset: Vector2;
  6539. alphaBlendingMode: number;
  6540. alphaTest: boolean;
  6541. layerMask: number;
  6542. private _scene;
  6543. private _vertexBuffers;
  6544. private _indexBuffer;
  6545. private _effect;
  6546. private _alphaTestEffect;
  6547. /**
  6548. * An event triggered when the layer is disposed.
  6549. * @type {BABYLON.Observable}
  6550. */
  6551. onDisposeObservable: Observable<Layer>;
  6552. private _onDisposeObserver;
  6553. onDispose: () => void;
  6554. /**
  6555. * An event triggered before rendering the scene
  6556. * @type {BABYLON.Observable}
  6557. */
  6558. onBeforeRenderObservable: Observable<Layer>;
  6559. private _onBeforeRenderObserver;
  6560. onBeforeRender: () => void;
  6561. /**
  6562. * An event triggered after rendering the scene
  6563. * @type {BABYLON.Observable}
  6564. */
  6565. onAfterRenderObservable: Observable<Layer>;
  6566. private _onAfterRenderObserver;
  6567. onAfterRender: () => void;
  6568. constructor(name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  6569. private _createIndexBuffer();
  6570. _rebuild(): void;
  6571. render(): void;
  6572. dispose(): void;
  6573. }
  6574. }
  6575. declare module BABYLON {
  6576. class LensFlare {
  6577. size: number;
  6578. position: number;
  6579. color: Color3;
  6580. texture: Nullable<Texture>;
  6581. alphaMode: number;
  6582. private _system;
  6583. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  6584. constructor(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  6585. dispose(): void;
  6586. }
  6587. }
  6588. declare module BABYLON {
  6589. class LensFlareSystem {
  6590. name: string;
  6591. lensFlares: LensFlare[];
  6592. borderLimit: number;
  6593. viewportBorder: number;
  6594. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  6595. layerMask: number;
  6596. id: string;
  6597. private _scene;
  6598. private _emitter;
  6599. private _vertexBuffers;
  6600. private _indexBuffer;
  6601. private _effect;
  6602. private _positionX;
  6603. private _positionY;
  6604. private _isEnabled;
  6605. constructor(name: string, emitter: any, scene: Scene);
  6606. isEnabled: boolean;
  6607. getScene(): Scene;
  6608. getEmitter(): any;
  6609. setEmitter(newEmitter: any): void;
  6610. getEmitterPosition(): Vector3;
  6611. computeEffectivePosition(globalViewport: Viewport): boolean;
  6612. _isVisible(): boolean;
  6613. render(): boolean;
  6614. dispose(): void;
  6615. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  6616. serialize(): any;
  6617. }
  6618. }
  6619. declare module BABYLON {
  6620. interface ILoadingScreen {
  6621. displayLoadingUI: () => void;
  6622. hideLoadingUI: () => void;
  6623. loadingUIBackgroundColor: string;
  6624. loadingUIText: string;
  6625. }
  6626. class DefaultLoadingScreen implements ILoadingScreen {
  6627. private _renderingCanvas;
  6628. private _loadingText;
  6629. private _loadingDivBackgroundColor;
  6630. private _loadingDiv;
  6631. private _loadingTextDiv;
  6632. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  6633. displayLoadingUI(): void;
  6634. hideLoadingUI(): void;
  6635. loadingUIText: string;
  6636. loadingUIBackgroundColor: string;
  6637. private _resizeLoadingUI;
  6638. }
  6639. }
  6640. declare module BABYLON {
  6641. class SceneLoaderProgressEvent {
  6642. readonly lengthComputable: boolean;
  6643. readonly loaded: number;
  6644. readonly total: number;
  6645. constructor(lengthComputable: boolean, loaded: number, total: number);
  6646. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  6647. }
  6648. interface ISceneLoaderPluginExtensions {
  6649. [extension: string]: {
  6650. isBinary: boolean;
  6651. };
  6652. }
  6653. interface ISceneLoaderPluginFactory {
  6654. name: string;
  6655. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  6656. canDirectLoad?: (data: string) => boolean;
  6657. }
  6658. interface ISceneLoaderPlugin {
  6659. /**
  6660. * The friendly name of this plugin.
  6661. */
  6662. name: string;
  6663. /**
  6664. * The file extensions supported by this plugin.
  6665. */
  6666. extensions: string | ISceneLoaderPluginExtensions;
  6667. /**
  6668. * Import meshes into a scene.
  6669. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  6670. * @param scene The scene to import into
  6671. * @param data The data to import
  6672. * @param rootUrl The root url for scene and resources
  6673. * @param meshes The meshes array to import into
  6674. * @param particleSystems The particle systems array to import into
  6675. * @param skeletons The skeletons array to import into
  6676. * @param onError The callback when import fails
  6677. * @returns True if successful or false otherwise
  6678. */
  6679. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: ParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  6680. /**
  6681. * Load into a scene.
  6682. * @param scene The scene to load into
  6683. * @param data The data to import
  6684. * @param rootUrl The root url for scene and resources
  6685. * @param onError The callback when import fails
  6686. * @returns true if successful or false otherwise
  6687. */
  6688. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  6689. /**
  6690. * The callback that returns true if the data can be directly loaded.
  6691. */
  6692. canDirectLoad?: (data: string) => boolean;
  6693. /**
  6694. * The callback that allows custom handling of the root url based on the response url.
  6695. */
  6696. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  6697. /**
  6698. * Load into an asset container.
  6699. * @param scene The scene to load into
  6700. * @param data The data to import
  6701. * @param rootUrl The root url for scene and resources
  6702. * @param onError The callback when import fails
  6703. * @returns The loaded asset container
  6704. */
  6705. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  6706. }
  6707. interface ISceneLoaderPluginAsync {
  6708. /**
  6709. * The friendly name of this plugin.
  6710. */
  6711. name: string;
  6712. /**
  6713. * The file extensions supported by this plugin.
  6714. */
  6715. extensions: string | ISceneLoaderPluginExtensions;
  6716. /**
  6717. * Import meshes into a scene.
  6718. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  6719. * @param scene The scene to import into
  6720. * @param data The data to import
  6721. * @param rootUrl The root url for scene and resources
  6722. * @param onProgress The callback when the load progresses
  6723. * @returns The loaded meshes, particle systems, and skeletons
  6724. */
  6725. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<{
  6726. meshes: AbstractMesh[];
  6727. particleSystems: ParticleSystem[];
  6728. skeletons: Skeleton[];
  6729. }>;
  6730. /**
  6731. * Load into a scene.
  6732. * @param scene The scene to load into
  6733. * @param data The data to import
  6734. * @param rootUrl The root url for scene and resources
  6735. * @param onProgress The callback when the load progresses
  6736. * @returns Nothing
  6737. */
  6738. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<void>;
  6739. /**
  6740. * The callback that returns true if the data can be directly loaded.
  6741. */
  6742. canDirectLoad?: (data: string) => boolean;
  6743. /**
  6744. * The callback that allows custom handling of the root url based on the response url.
  6745. */
  6746. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  6747. /**
  6748. * Load into an asset container.
  6749. * @param scene The scene to load into
  6750. * @param data The data to import
  6751. * @param rootUrl The root url for scene and resources
  6752. * @param onProgress The callback when the load progresses
  6753. * @returns The loaded asset container
  6754. */
  6755. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<AssetContainer>;
  6756. }
  6757. class SceneLoader {
  6758. private static _ForceFullSceneLoadingForIncremental;
  6759. private static _ShowLoadingScreen;
  6760. private static _CleanBoneMatrixWeights;
  6761. static readonly NO_LOGGING: number;
  6762. static readonly MINIMAL_LOGGING: number;
  6763. static readonly SUMMARY_LOGGING: number;
  6764. static readonly DETAILED_LOGGING: number;
  6765. private static _loggingLevel;
  6766. static ForceFullSceneLoadingForIncremental: boolean;
  6767. static ShowLoadingScreen: boolean;
  6768. static loggingLevel: number;
  6769. static CleanBoneMatrixWeights: boolean;
  6770. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  6771. private static _registeredPlugins;
  6772. private static _getDefaultPlugin();
  6773. private static _getPluginForExtension(extension);
  6774. private static _getPluginForDirectLoad(data);
  6775. private static _getPluginForFilename(sceneFilename);
  6776. private static _getDirectLoad(sceneFilename);
  6777. private static _loadData(rootUrl, sceneFilename, scene, onSuccess, onProgress, onError, onDispose, pluginExtension);
  6778. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  6779. static IsPluginForExtensionAvailable(extension: string): boolean;
  6780. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  6781. /**
  6782. * Import meshes into a scene
  6783. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  6784. * @param rootUrl a string that defines the root url for scene and resources
  6785. * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene
  6786. * @param scene the instance of BABYLON.Scene to append to
  6787. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  6788. * @param onProgress a callback with a progress event for each file being loaded
  6789. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  6790. * @param pluginExtension the extension used to determine the plugin
  6791. * @returns The loaded plugin
  6792. */
  6793. static ImportMesh(meshNames: any, rootUrl: string, sceneFilename: string, scene: Scene, onSuccess?: Nullable<(meshes: AbstractMesh[], particleSystems: ParticleSystem[], skeletons: Skeleton[]) => void>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>, pluginExtension?: Nullable<string>): Nullable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  6794. /**
  6795. * Import meshes into a scene
  6796. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  6797. * @param rootUrl a string that defines the root url for scene and resources
  6798. * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene
  6799. * @param scene the instance of BABYLON.Scene to append to
  6800. * @param onProgress a callback with a progress event for each file being loaded
  6801. * @param pluginExtension the extension used to determine the plugin
  6802. * @returns The loaded list of imported meshes, particleSystems, and skeletons
  6803. */
  6804. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename: string, scene: Scene, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  6805. meshes: AbstractMesh[];
  6806. particleSystems: ParticleSystem[];
  6807. skeletons: Skeleton[];
  6808. }>;
  6809. /**
  6810. * Load a scene
  6811. * @param rootUrl a string that defines the root url for scene and resources
  6812. * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene
  6813. * @param engine is the instance of BABYLON.Engine to use to create the scene
  6814. * @param onSuccess a callback with the scene when import succeeds
  6815. * @param onProgress a callback with a progress event for each file being loaded
  6816. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  6817. * @param pluginExtension the extension used to determine the plugin
  6818. * @returns The loaded plugin
  6819. */
  6820. 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>;
  6821. /**
  6822. * Load a scene
  6823. * @param rootUrl a string that defines the root url for scene and resources
  6824. * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene
  6825. * @param engine is the instance of BABYLON.Engine to use to create the scene
  6826. * @param onProgress a callback with a progress event for each file being loaded
  6827. * @param pluginExtension the extension used to determine the plugin
  6828. * @returns The loaded scene
  6829. */
  6830. static LoadAsync(rootUrl: string, sceneFilename: any, engine: Engine, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  6831. /**
  6832. * Append a scene
  6833. * @param rootUrl a string that defines the root url for scene and resources
  6834. * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene
  6835. * @param scene is the instance of BABYLON.Scene to append to
  6836. * @param onSuccess a callback with the scene when import succeeds
  6837. * @param onProgress a callback with a progress event for each file being loaded
  6838. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  6839. * @param pluginExtension the extension used to determine the plugin
  6840. * @returns The loaded plugin
  6841. */
  6842. static Append(rootUrl: string, sceneFilename: any, scene: 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>;
  6843. /**
  6844. * Append a scene
  6845. * @param rootUrl a string that defines the root url for scene and resources
  6846. * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene
  6847. * @param scene is the instance of BABYLON.Scene to append to
  6848. * @param onProgress a callback with a progress event for each file being loaded
  6849. * @param pluginExtension the extension used to determine the plugin
  6850. * @returns The given scene
  6851. */
  6852. static AppendAsync(rootUrl: string, sceneFilename: any, scene: Scene, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  6853. /**
  6854. * Load a scene into an asset container
  6855. * @param rootUrl a string that defines the root url for scene and resources
  6856. * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene
  6857. * @param scene is the instance of BABYLON.Scene to append to
  6858. * @param onSuccess a callback with the scene when import succeeds
  6859. * @param onProgress a callback with a progress event for each file being loaded
  6860. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  6861. * @param pluginExtension the extension used to determine the plugin
  6862. * @returns The loaded plugin
  6863. */
  6864. static LoadAssetContainer(rootUrl: string, sceneFilename: any, scene: 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>;
  6865. /**
  6866. * Load a scene into an asset container
  6867. * @param rootUrl a string that defines the root url for scene and resources
  6868. * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene
  6869. * @param scene is the instance of BABYLON.Scene to append to
  6870. * @param onProgress a callback with a progress event for each file being loaded
  6871. * @param pluginExtension the extension used to determine the plugin
  6872. * @returns The loaded asset container
  6873. */
  6874. static LoadAssetContainerAsync(rootUrl: string, sceneFilename: any, scene: Scene, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  6875. }
  6876. }
  6877. declare module BABYLON {
  6878. /**
  6879. * A directional light is defined by a direction (what a surprise!).
  6880. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  6881. * 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.
  6882. * Documentation: https://doc.babylonjs.com/babylon101/lights
  6883. */
  6884. class DirectionalLight extends ShadowLight {
  6885. private _shadowFrustumSize;
  6886. /**
  6887. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  6888. */
  6889. /**
  6890. * Specifies a fix frustum size for the shadow generation.
  6891. */
  6892. shadowFrustumSize: number;
  6893. private _shadowOrthoScale;
  6894. /**
  6895. * Gets the shadow projection scale against the optimal computed one.
  6896. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  6897. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  6898. */
  6899. /**
  6900. * Sets the shadow projection scale against the optimal computed one.
  6901. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  6902. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  6903. */
  6904. shadowOrthoScale: number;
  6905. /**
  6906. * Automatically compute the projection matrix to best fit (including all the casters)
  6907. * on each frame.
  6908. */
  6909. autoUpdateExtends: boolean;
  6910. private _orthoLeft;
  6911. private _orthoRight;
  6912. private _orthoTop;
  6913. private _orthoBottom;
  6914. /**
  6915. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  6916. * The directional light is emitted from everywhere in the given direction.
  6917. * It can cast shawdows.
  6918. * Documentation : http://doc.babylonjs.com/tutorials/lights
  6919. * @param name The friendly name of the light
  6920. * @param direction The direction of the light
  6921. * @param scene The scene the light belongs to
  6922. */
  6923. constructor(name: string, direction: Vector3, scene: Scene);
  6924. /**
  6925. * Returns the string "DirectionalLight".
  6926. * @return The class name
  6927. */
  6928. getClassName(): string;
  6929. /**
  6930. * Returns the integer 1.
  6931. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  6932. */
  6933. getTypeID(): number;
  6934. /**
  6935. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  6936. * Returns the DirectionalLight Shadow projection matrix.
  6937. */
  6938. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  6939. /**
  6940. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  6941. * Returns the DirectionalLight Shadow projection matrix.
  6942. */
  6943. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix): void;
  6944. /**
  6945. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  6946. * Returns the DirectionalLight Shadow projection matrix.
  6947. */
  6948. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  6949. protected _buildUniformLayout(): void;
  6950. /**
  6951. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  6952. * @param effect The effect to update
  6953. * @param lightIndex The index of the light in the effect to update
  6954. * @returns The directional light
  6955. */
  6956. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  6957. /**
  6958. * Gets the minZ used for shadow according to both the scene and the light.
  6959. *
  6960. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  6961. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  6962. * @param activeCamera The camera we are returning the min for
  6963. * @returns the depth min z
  6964. */
  6965. getDepthMinZ(activeCamera: Camera): number;
  6966. /**
  6967. * Gets the maxZ used for shadow according to both the scene and the light.
  6968. *
  6969. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  6970. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  6971. * @param activeCamera The camera we are returning the max for
  6972. * @returns the depth max z
  6973. */
  6974. getDepthMaxZ(activeCamera: Camera): number;
  6975. }
  6976. }
  6977. declare module BABYLON {
  6978. /**
  6979. * The HemisphericLight simulates the ambient environment light,
  6980. * so the passed direction is the light reflection direction, not the incoming direction.
  6981. */
  6982. class HemisphericLight extends Light {
  6983. /**
  6984. * The groundColor is the light in the opposite direction to the one specified during creation.
  6985. * 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.
  6986. */
  6987. groundColor: Color3;
  6988. /**
  6989. * The light reflection direction, not the incoming direction.
  6990. */
  6991. direction: Vector3;
  6992. private _worldMatrix;
  6993. /**
  6994. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  6995. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  6996. * The HemisphericLight can't cast shadows.
  6997. * Documentation : http://doc.babylonjs.com/tutorials/lights
  6998. * @param name The friendly name of the light
  6999. * @param direction The direction of the light reflection
  7000. * @param scene The scene the light belongs to
  7001. */
  7002. constructor(name: string, direction: Vector3, scene: Scene);
  7003. protected _buildUniformLayout(): void;
  7004. /**
  7005. * Returns the string "HemisphericLight".
  7006. * @return The class name
  7007. */
  7008. getClassName(): string;
  7009. /**
  7010. * Sets the HemisphericLight direction towards the passed target (Vector3).
  7011. * Returns the updated direction.
  7012. * @param target The target the direction should point to
  7013. * @return The computed direction
  7014. */
  7015. setDirectionToTarget(target: Vector3): Vector3;
  7016. /**
  7017. * Returns the shadow generator associated to the light.
  7018. * @returns Always null for hemispheric lights because it does not support shadows.
  7019. */
  7020. getShadowGenerator(): Nullable<ShadowGenerator>;
  7021. /**
  7022. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  7023. * @param effect The effect to update
  7024. * @param lightIndex The index of the light in the effect to update
  7025. * @returns The hemispheric light
  7026. */
  7027. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  7028. /**
  7029. * @ignore internal use only.
  7030. */
  7031. _getWorldMatrix(): Matrix;
  7032. /**
  7033. * Returns the integer 3.
  7034. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  7035. */
  7036. getTypeID(): number;
  7037. }
  7038. }
  7039. declare module BABYLON {
  7040. /**
  7041. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  7042. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  7043. * 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.
  7044. */
  7045. abstract class Light extends Node {
  7046. private static _LIGHTMAP_DEFAULT;
  7047. private static _LIGHTMAP_SPECULAR;
  7048. private static _LIGHTMAP_SHADOWSONLY;
  7049. /**
  7050. * If every light affecting the material is in this lightmapMode,
  7051. * material.lightmapTexture adds or multiplies
  7052. * (depends on material.useLightmapAsShadowmap)
  7053. * after every other light calculations.
  7054. */
  7055. static readonly LIGHTMAP_DEFAULT: number;
  7056. /**
  7057. * material.lightmapTexture as only diffuse lighting from this light
  7058. * adds only specular lighting from this light
  7059. * adds dynamic shadows
  7060. */
  7061. static readonly LIGHTMAP_SPECULAR: number;
  7062. /**
  7063. * material.lightmapTexture as only lighting
  7064. * no light calculation from this light
  7065. * only adds dynamic shadows from this light
  7066. */
  7067. static readonly LIGHTMAP_SHADOWSONLY: number;
  7068. private static _INTENSITYMODE_AUTOMATIC;
  7069. private static _INTENSITYMODE_LUMINOUSPOWER;
  7070. private static _INTENSITYMODE_LUMINOUSINTENSITY;
  7071. private static _INTENSITYMODE_ILLUMINANCE;
  7072. private static _INTENSITYMODE_LUMINANCE;
  7073. /**
  7074. * Each light type uses the default quantity according to its type:
  7075. * point/spot lights use luminous intensity
  7076. * directional lights use illuminance
  7077. */
  7078. static readonly INTENSITYMODE_AUTOMATIC: number;
  7079. /**
  7080. * lumen (lm)
  7081. */
  7082. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  7083. /**
  7084. * candela (lm/sr)
  7085. */
  7086. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  7087. /**
  7088. * lux (lm/m^2)
  7089. */
  7090. static readonly INTENSITYMODE_ILLUMINANCE: number;
  7091. /**
  7092. * nit (cd/m^2)
  7093. */
  7094. static readonly INTENSITYMODE_LUMINANCE: number;
  7095. private static _LIGHTTYPEID_POINTLIGHT;
  7096. private static _LIGHTTYPEID_DIRECTIONALLIGHT;
  7097. private static _LIGHTTYPEID_SPOTLIGHT;
  7098. private static _LIGHTTYPEID_HEMISPHERICLIGHT;
  7099. /**
  7100. * Light type const id of the point light.
  7101. */
  7102. static readonly LIGHTTYPEID_POINTLIGHT: number;
  7103. /**
  7104. * Light type const id of the directional light.
  7105. */
  7106. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  7107. /**
  7108. * Light type const id of the spot light.
  7109. */
  7110. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  7111. /**
  7112. * Light type const id of the hemispheric light.
  7113. */
  7114. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  7115. /**
  7116. * Diffuse gives the basic color to an object.
  7117. */
  7118. diffuse: Color3;
  7119. /**
  7120. * Specular produces a highlight color on an object.
  7121. * Note: This is note affecting PBR materials.
  7122. */
  7123. specular: Color3;
  7124. /**
  7125. * Strength of the light.
  7126. * Note: By default it is define in the framework own unit.
  7127. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  7128. */
  7129. intensity: number;
  7130. /**
  7131. * Defines how far from the source the light is impacting in scene units.
  7132. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  7133. */
  7134. range: number;
  7135. /**
  7136. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  7137. * of light.
  7138. */
  7139. private _photometricScale;
  7140. private _intensityMode;
  7141. /**
  7142. * Gets the photometric scale used to interpret the intensity.
  7143. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  7144. */
  7145. /**
  7146. * Sets the photometric scale used to interpret the intensity.
  7147. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  7148. */
  7149. intensityMode: number;
  7150. private _radius;
  7151. /**
  7152. * Gets the light radius used by PBR Materials to simulate soft area lights.
  7153. */
  7154. /**
  7155. * sets the light radius used by PBR Materials to simulate soft area lights.
  7156. */
  7157. radius: number;
  7158. private _renderPriority;
  7159. /**
  7160. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  7161. * exceeding the number allowed of the materials.
  7162. */
  7163. renderPriority: number;
  7164. /**
  7165. * Defines wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  7166. * the current shadow generator.
  7167. */
  7168. shadowEnabled: boolean;
  7169. private _includedOnlyMeshes;
  7170. /**
  7171. * Gets the only meshes impacted by this light.
  7172. */
  7173. /**
  7174. * Sets the only meshes impacted by this light.
  7175. */
  7176. includedOnlyMeshes: AbstractMesh[];
  7177. private _excludedMeshes;
  7178. /**
  7179. * Gets the meshes not impacted by this light.
  7180. */
  7181. /**
  7182. * Sets the meshes not impacted by this light.
  7183. */
  7184. excludedMeshes: AbstractMesh[];
  7185. private _excludeWithLayerMask;
  7186. /**
  7187. * Gets the layer id use to find what meshes are not impacted by the light.
  7188. * Inactive if 0
  7189. */
  7190. /**
  7191. * Sets the layer id use to find what meshes are not impacted by the light.
  7192. * Inactive if 0
  7193. */
  7194. excludeWithLayerMask: number;
  7195. private _includeOnlyWithLayerMask;
  7196. /**
  7197. * Gets the layer id use to find what meshes are impacted by the light.
  7198. * Inactive if 0
  7199. */
  7200. /**
  7201. * Sets the layer id use to find what meshes are impacted by the light.
  7202. * Inactive if 0
  7203. */
  7204. includeOnlyWithLayerMask: number;
  7205. private _lightmapMode;
  7206. /**
  7207. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  7208. */
  7209. /**
  7210. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  7211. */
  7212. lightmapMode: number;
  7213. private _parentedWorldMatrix;
  7214. /**
  7215. * Shadow generator associted to the light.
  7216. * Internal use only.
  7217. */
  7218. _shadowGenerator: Nullable<IShadowGenerator>;
  7219. /**
  7220. * @ignore Internal use only.
  7221. */
  7222. _excludedMeshesIds: string[];
  7223. /**
  7224. * @ignore Internal use only.
  7225. */
  7226. _includedOnlyMeshesIds: string[];
  7227. /**
  7228. * The current light unifom buffer.
  7229. * @ignore Internal use only.
  7230. */
  7231. _uniformBuffer: UniformBuffer;
  7232. /**
  7233. * Creates a Light object in the scene.
  7234. * Documentation : http://doc.babylonjs.com/tutorials/lights
  7235. * @param name The firendly name of the light
  7236. * @param scene The scene the light belongs too
  7237. */
  7238. constructor(name: string, scene: Scene);
  7239. protected abstract _buildUniformLayout(): void;
  7240. /**
  7241. * Sets the passed Effect "effect" with the Light information.
  7242. * @param effect The effect to update
  7243. * @param lightIndex The index of the light in the effect to update
  7244. * @returns The light
  7245. */
  7246. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  7247. /**
  7248. * @ignore internal use only.
  7249. */
  7250. abstract _getWorldMatrix(): Matrix;
  7251. /**
  7252. * Returns the string "Light".
  7253. * @returns the class name
  7254. */
  7255. getClassName(): string;
  7256. /**
  7257. * Converts the light information to a readable string for debug purpose.
  7258. * @param fullDetails Supports for multiple levels of logging within scene loading
  7259. * @returns the human readable light info
  7260. */
  7261. toString(fullDetails?: boolean): string;
  7262. /**
  7263. * Set the enabled state of this node.
  7264. * @param value - the new enabled state
  7265. * @see isEnabled
  7266. */
  7267. setEnabled(value: boolean): void;
  7268. /**
  7269. * Returns the Light associated shadow generator if any.
  7270. * @return the associated shadow generator.
  7271. */
  7272. getShadowGenerator(): Nullable<IShadowGenerator>;
  7273. /**
  7274. * Returns a Vector3, the absolute light position in the World.
  7275. * @returns the world space position of the light
  7276. */
  7277. getAbsolutePosition(): Vector3;
  7278. /**
  7279. * Specifies if the light will affect the passed mesh.
  7280. * @param mesh The mesh to test against the light
  7281. * @return true the mesh is affected otherwise, false.
  7282. */
  7283. canAffectMesh(mesh: AbstractMesh): boolean;
  7284. /**
  7285. * Computes and Returns the light World matrix.
  7286. * @returns the world matrix
  7287. */
  7288. getWorldMatrix(): Matrix;
  7289. /**
  7290. * Sort function to order lights for rendering.
  7291. * @param a First Light object to compare to second.
  7292. * @param b Second Light object to compare first.
  7293. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  7294. */
  7295. static CompareLightsPriority(a: Light, b: Light): number;
  7296. /**
  7297. * Disposes the light.
  7298. */
  7299. dispose(): void;
  7300. /**
  7301. * Returns the light type ID (integer).
  7302. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  7303. */
  7304. getTypeID(): number;
  7305. /**
  7306. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  7307. * @returns the scaled intensity in intensity mode unit
  7308. */
  7309. getScaledIntensity(): number;
  7310. /**
  7311. * Returns a new Light object, named "name", from the current one.
  7312. * @param name The name of the cloned light
  7313. * @returns the new created light
  7314. */
  7315. clone(name: string): Nullable<Light>;
  7316. /**
  7317. * Serializes the current light into a Serialization object.
  7318. * @returns the serialized object.
  7319. */
  7320. serialize(): any;
  7321. /**
  7322. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  7323. * This new light is named "name" and added to the passed scene.
  7324. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  7325. * @param name The friendly name of the light
  7326. * @param scene The scene the new light will belong to
  7327. * @returns the constructor function
  7328. */
  7329. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  7330. /**
  7331. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  7332. * @param parsedLight The JSON representation of the light
  7333. * @param scene The scene to create the parsed light in
  7334. * @returns the created light after parsing
  7335. */
  7336. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  7337. private _hookArrayForExcluded(array);
  7338. private _hookArrayForIncludedOnly(array);
  7339. private _resyncMeshes();
  7340. /**
  7341. * Forces the meshes to update their light related information in their rendering used effects
  7342. * @ignore Internal Use Only
  7343. */
  7344. _markMeshesAsLightDirty(): void;
  7345. /**
  7346. * Recomputes the cached photometric scale if needed.
  7347. */
  7348. private _computePhotometricScale();
  7349. /**
  7350. * Returns the Photometric Scale according to the light type and intensity mode.
  7351. */
  7352. private _getPhotometricScale();
  7353. /**
  7354. * Reorder the light in the scene according to their defined priority.
  7355. * @ignore Internal Use Only
  7356. */
  7357. _reorderLightsInScene(): void;
  7358. }
  7359. }
  7360. declare module BABYLON {
  7361. /**
  7362. * A point light is a light defined by an unique point in world space.
  7363. * The light is emitted in every direction from this point.
  7364. * A good example of a point light is a standard light bulb.
  7365. * Documentation: https://doc.babylonjs.com/babylon101/lights
  7366. */
  7367. class PointLight extends ShadowLight {
  7368. private _shadowAngle;
  7369. /**
  7370. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  7371. * This specifies what angle the shadow will use to be created.
  7372. *
  7373. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  7374. */
  7375. /**
  7376. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  7377. * This specifies what angle the shadow will use to be created.
  7378. *
  7379. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  7380. */
  7381. shadowAngle: number;
  7382. /**
  7383. * Gets the direction if it has been set.
  7384. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  7385. */
  7386. /**
  7387. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  7388. */
  7389. direction: Vector3;
  7390. /**
  7391. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  7392. * A PointLight emits the light in every direction.
  7393. * It can cast shadows.
  7394. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  7395. * ```javascript
  7396. * var pointLight = new BABYLON.PointLight("pl", camera.position, scene);
  7397. * ```
  7398. * Documentation : http://doc.babylonjs.com/tutorials/lights
  7399. * @param name The light friendly name
  7400. * @param position The position of the point light in the scene
  7401. * @param scene The scene the lights belongs to
  7402. */
  7403. constructor(name: string, position: Vector3, scene: Scene);
  7404. /**
  7405. * Returns the string "PointLight"
  7406. * @returns the class name
  7407. */
  7408. getClassName(): string;
  7409. /**
  7410. * Returns the integer 0.
  7411. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  7412. */
  7413. getTypeID(): number;
  7414. /**
  7415. * Specifies wether or not the shadowmap should be a cube texture.
  7416. * @returns true if the shadowmap needs to be a cube texture.
  7417. */
  7418. needCube(): boolean;
  7419. /**
  7420. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  7421. * @param faceIndex The index of the face we are computed the direction to generate shadow
  7422. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  7423. */
  7424. getShadowDirection(faceIndex?: number): Vector3;
  7425. /**
  7426. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  7427. * - fov = PI / 2
  7428. * - aspect ratio : 1.0
  7429. * - z-near and far equal to the active camera minZ and maxZ.
  7430. * Returns the PointLight.
  7431. */
  7432. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  7433. protected _buildUniformLayout(): void;
  7434. /**
  7435. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  7436. * @param effect The effect to update
  7437. * @param lightIndex The index of the light in the effect to update
  7438. * @returns The point light
  7439. */
  7440. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  7441. }
  7442. }
  7443. declare module BABYLON {
  7444. /**
  7445. * Interface describing all the common properties and methods a shadow light needs to implement.
  7446. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  7447. * as well as binding the different shadow properties to the effects.
  7448. */
  7449. interface IShadowLight extends Light {
  7450. /**
  7451. * The light id in the scene (used in scene.findLighById for instance)
  7452. */
  7453. id: string;
  7454. /**
  7455. * The position the shdow will be casted from.
  7456. */
  7457. position: Vector3;
  7458. /**
  7459. * In 2d mode (needCube being false), the direction used to cast the shadow.
  7460. */
  7461. direction: Vector3;
  7462. /**
  7463. * The transformed position. Position of the light in world space taking parenting in account.
  7464. */
  7465. transformedPosition: Vector3;
  7466. /**
  7467. * The transformed direction. Direction of the light in world space taking parenting in account.
  7468. */
  7469. transformedDirection: Vector3;
  7470. /**
  7471. * The friendly name of the light in the scene.
  7472. */
  7473. name: string;
  7474. /**
  7475. * Defines the shadow projection clipping minimum z value.
  7476. */
  7477. shadowMinZ: number;
  7478. /**
  7479. * Defines the shadow projection clipping maximum z value.
  7480. */
  7481. shadowMaxZ: number;
  7482. /**
  7483. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  7484. * @returns true if the information has been computed, false if it does not need to (no parenting)
  7485. */
  7486. computeTransformedInformation(): boolean;
  7487. /**
  7488. * Gets the scene the light belongs to.
  7489. * @returns The scene
  7490. */
  7491. getScene(): Scene;
  7492. /**
  7493. * Callback defining a custom Projection Matrix Builder.
  7494. * This can be used to override the default projection matrix computation.
  7495. */
  7496. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  7497. /**
  7498. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  7499. * @param matrix The materix to updated with the projection information
  7500. * @param viewMatrix The transform matrix of the light
  7501. * @param renderList The list of mesh to render in the map
  7502. * @returns The current light
  7503. */
  7504. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  7505. /**
  7506. * Gets the current depth scale used in ESM.
  7507. * @returns The scale
  7508. */
  7509. getDepthScale(): number;
  7510. /**
  7511. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  7512. * @returns true if a cube texture needs to be use
  7513. */
  7514. needCube(): boolean;
  7515. /**
  7516. * Detects if the projection matrix requires to be recomputed this frame.
  7517. * @returns true if it requires to be recomputed otherwise, false.
  7518. */
  7519. needProjectionMatrixCompute(): boolean;
  7520. /**
  7521. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  7522. */
  7523. forceProjectionMatrixCompute(): void;
  7524. /**
  7525. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  7526. * @param faceIndex The index of the face we are computed the direction to generate shadow
  7527. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  7528. */
  7529. getShadowDirection(faceIndex?: number): Vector3;
  7530. /**
  7531. * Gets the minZ used for shadow according to both the scene and the light.
  7532. * @param activeCamera The camera we are returning the min for
  7533. * @returns the depth min z
  7534. */
  7535. getDepthMinZ(activeCamera: Camera): number;
  7536. /**
  7537. * Gets the maxZ used for shadow according to both the scene and the light.
  7538. * @param activeCamera The camera we are returning the max for
  7539. * @returns the depth max z
  7540. */
  7541. getDepthMaxZ(activeCamera: Camera): number;
  7542. }
  7543. /**
  7544. * Base implementation of @see IShadowLight
  7545. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  7546. */
  7547. abstract class ShadowLight extends Light implements IShadowLight {
  7548. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  7549. protected _position: Vector3;
  7550. protected _setPosition(value: Vector3): void;
  7551. /**
  7552. * Sets the position the shadow will be casted from. Also use as the light position for both
  7553. * point and spot lights.
  7554. */
  7555. /**
  7556. * Sets the position the shadow will be casted from. Also use as the light position for both
  7557. * point and spot lights.
  7558. */
  7559. position: Vector3;
  7560. protected _direction: Vector3;
  7561. protected _setDirection(value: Vector3): void;
  7562. /**
  7563. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  7564. * Also use as the light direction on spot and directional lights.
  7565. */
  7566. /**
  7567. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  7568. * Also use as the light direction on spot and directional lights.
  7569. */
  7570. direction: Vector3;
  7571. private _shadowMinZ;
  7572. /**
  7573. * Gets the shadow projection clipping minimum z value.
  7574. */
  7575. /**
  7576. * Sets the shadow projection clipping minimum z value.
  7577. */
  7578. shadowMinZ: number;
  7579. private _shadowMaxZ;
  7580. /**
  7581. * Sets the shadow projection clipping maximum z value.
  7582. */
  7583. /**
  7584. * Gets the shadow projection clipping maximum z value.
  7585. */
  7586. shadowMaxZ: number;
  7587. /**
  7588. * Callback defining a custom Projection Matrix Builder.
  7589. * This can be used to override the default projection matrix computation.
  7590. */
  7591. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  7592. /**
  7593. * The transformed position. Position of the light in world space taking parenting in account.
  7594. */
  7595. transformedPosition: Vector3;
  7596. /**
  7597. * The transformed direction. Direction of the light in world space taking parenting in account.
  7598. */
  7599. transformedDirection: Vector3;
  7600. private _worldMatrix;
  7601. private _needProjectionMatrixCompute;
  7602. /**
  7603. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  7604. * @returns true if the information has been computed, false if it does not need to (no parenting)
  7605. */
  7606. computeTransformedInformation(): boolean;
  7607. /**
  7608. * Return the depth scale used for the shadow map.
  7609. * @returns the depth scale.
  7610. */
  7611. getDepthScale(): number;
  7612. /**
  7613. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  7614. * @param faceIndex The index of the face we are computed the direction to generate shadow
  7615. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  7616. */
  7617. getShadowDirection(faceIndex?: number): Vector3;
  7618. /**
  7619. * Returns the ShadowLight absolute position in the World.
  7620. * @returns the position vector in world space
  7621. */
  7622. getAbsolutePosition(): Vector3;
  7623. /**
  7624. * Sets the ShadowLight direction toward the passed target.
  7625. * @param target The point tot target in local space
  7626. * @returns the updated ShadowLight direction
  7627. */
  7628. setDirectionToTarget(target: Vector3): Vector3;
  7629. /**
  7630. * Returns the light rotation in euler definition.
  7631. * @returns the x y z rotation in local space.
  7632. */
  7633. getRotation(): Vector3;
  7634. /**
  7635. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  7636. * @returns true if a cube texture needs to be use
  7637. */
  7638. needCube(): boolean;
  7639. /**
  7640. * Detects if the projection matrix requires to be recomputed this frame.
  7641. * @returns true if it requires to be recomputed otherwise, false.
  7642. */
  7643. needProjectionMatrixCompute(): boolean;
  7644. /**
  7645. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  7646. */
  7647. forceProjectionMatrixCompute(): void;
  7648. /**
  7649. * Get the world matrix of the sahdow lights.
  7650. * @ignore Internal Use Only
  7651. */
  7652. _getWorldMatrix(): Matrix;
  7653. /**
  7654. * Gets the minZ used for shadow according to both the scene and the light.
  7655. * @param activeCamera The camera we are returning the min for
  7656. * @returns the depth min z
  7657. */
  7658. getDepthMinZ(activeCamera: Camera): number;
  7659. /**
  7660. * Gets the maxZ used for shadow according to both the scene and the light.
  7661. * @param activeCamera The camera we are returning the max for
  7662. * @returns the depth max z
  7663. */
  7664. getDepthMaxZ(activeCamera: Camera): number;
  7665. /**
  7666. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  7667. * @param matrix The materix to updated with the projection information
  7668. * @param viewMatrix The transform matrix of the light
  7669. * @param renderList The list of mesh to render in the map
  7670. * @returns The current light
  7671. */
  7672. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  7673. }
  7674. }
  7675. declare module BABYLON {
  7676. /**
  7677. * A spot light is defined by a position, a direction, an angle, and an exponent.
  7678. * These values define a cone of light starting from the position, emitting toward the direction.
  7679. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  7680. * and the exponent defines the speed of the decay of the light with distance (reach).
  7681. * Documentation: https://doc.babylonjs.com/babylon101/lights
  7682. */
  7683. class SpotLight extends ShadowLight {
  7684. private _angle;
  7685. /**
  7686. * Gets the cone angle of the spot light in Radians.
  7687. */
  7688. /**
  7689. * Sets the cone angle of the spot light in Radians.
  7690. */
  7691. angle: number;
  7692. private _shadowAngleScale;
  7693. /**
  7694. * Allows scaling the angle of the light for shadow generation only.
  7695. */
  7696. /**
  7697. * Allows scaling the angle of the light for shadow generation only.
  7698. */
  7699. shadowAngleScale: number;
  7700. /**
  7701. * The light decay speed with the distance from the emission spot.
  7702. */
  7703. exponent: number;
  7704. private _projectionTextureMatrix;
  7705. /**
  7706. * Allows reading the projecton texture
  7707. */
  7708. readonly projectionTextureMatrix: Matrix;
  7709. protected _projectionTextureLightNear: number;
  7710. /**
  7711. * Gets the near clip of the Spotlight for texture projection.
  7712. */
  7713. /**
  7714. * Sets the near clip of the Spotlight for texture projection.
  7715. */
  7716. projectionTextureLightNear: number;
  7717. protected _projectionTextureLightFar: number;
  7718. /**
  7719. * Gets the far clip of the Spotlight for texture projection.
  7720. */
  7721. /**
  7722. * Sets the far clip of the Spotlight for texture projection.
  7723. */
  7724. projectionTextureLightFar: number;
  7725. protected _projectionTextureUpDirection: Vector3;
  7726. /**
  7727. * Gets the Up vector of the Spotlight for texture projection.
  7728. */
  7729. /**
  7730. * Sets the Up vector of the Spotlight for texture projection.
  7731. */
  7732. projectionTextureUpDirection: Vector3;
  7733. private _projectionTexture;
  7734. /**
  7735. * Gets the projection texture of the light.
  7736. */
  7737. /**
  7738. * Sets the projection texture of the light.
  7739. */
  7740. projectionTexture: Nullable<BaseTexture>;
  7741. private _projectionTextureViewLightDirty;
  7742. private _projectionTextureProjectionLightDirty;
  7743. private _projectionTextureDirty;
  7744. private _projectionTextureViewTargetVector;
  7745. private _projectionTextureViewLightMatrix;
  7746. private _projectionTextureProjectionLightMatrix;
  7747. private _projectionTextureScalingMatrix;
  7748. /**
  7749. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  7750. * It can cast shadows.
  7751. * Documentation : http://doc.babylonjs.com/tutorials/lights
  7752. * @param name The light friendly name
  7753. * @param position The position of the spot light in the scene
  7754. * @param direction The direction of the light in the scene
  7755. * @param angle The cone angle of the light in Radians
  7756. * @param exponent The light decay speed with the distance from the emission spot
  7757. * @param scene The scene the lights belongs to
  7758. */
  7759. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  7760. /**
  7761. * Returns the string "SpotLight".
  7762. * @returns the class name
  7763. */
  7764. getClassName(): string;
  7765. /**
  7766. * Returns the integer 2.
  7767. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  7768. */
  7769. getTypeID(): number;
  7770. /**
  7771. * Overrides the direction setter to recompute the projection texture view light Matrix.
  7772. */
  7773. protected _setDirection(value: Vector3): void;
  7774. /**
  7775. * Overrides the position setter to recompute the projection texture view light Matrix.
  7776. */
  7777. protected _setPosition(value: Vector3): void;
  7778. /**
  7779. * 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.
  7780. * Returns the SpotLight.
  7781. */
  7782. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  7783. protected _computeProjectionTextureViewLightMatrix(): void;
  7784. protected _computeProjectionTextureProjectionLightMatrix(): void;
  7785. /**
  7786. * Main function for light texture projection matrix computing.
  7787. */
  7788. protected _computeProjectionTextureMatrix(): void;
  7789. protected _buildUniformLayout(): void;
  7790. /**
  7791. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  7792. * @param effect The effect to update
  7793. * @param lightIndex The index of the light in the effect to update
  7794. * @returns The spot light
  7795. */
  7796. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  7797. /**
  7798. * Disposes the light and the associated resources.
  7799. */
  7800. dispose(): void;
  7801. }
  7802. }
  7803. declare module BABYLON {
  7804. /**
  7805. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  7806. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  7807. * 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;
  7808. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  7809. */
  7810. class ColorCurves {
  7811. private _dirty;
  7812. private _tempColor;
  7813. private _globalCurve;
  7814. private _highlightsCurve;
  7815. private _midtonesCurve;
  7816. private _shadowsCurve;
  7817. private _positiveCurve;
  7818. private _negativeCurve;
  7819. private _globalHue;
  7820. private _globalDensity;
  7821. private _globalSaturation;
  7822. private _globalExposure;
  7823. /**
  7824. * Gets the global Hue value.
  7825. * 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).
  7826. */
  7827. /**
  7828. * Sets the global Hue value.
  7829. * 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).
  7830. */
  7831. globalHue: number;
  7832. /**
  7833. * Gets the global Density value.
  7834. * 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.
  7835. * Values less than zero provide a filter of opposite hue.
  7836. */
  7837. /**
  7838. * Sets the global Density value.
  7839. * 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.
  7840. * Values less than zero provide a filter of opposite hue.
  7841. */
  7842. globalDensity: number;
  7843. /**
  7844. * Gets the global Saturation value.
  7845. * 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.
  7846. */
  7847. /**
  7848. * Sets the global Saturation value.
  7849. * 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.
  7850. */
  7851. globalSaturation: number;
  7852. private _highlightsHue;
  7853. private _highlightsDensity;
  7854. private _highlightsSaturation;
  7855. private _highlightsExposure;
  7856. /**
  7857. * Gets the highlights Hue value.
  7858. * 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).
  7859. */
  7860. /**
  7861. * Sets the highlights Hue value.
  7862. * 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).
  7863. */
  7864. highlightsHue: number;
  7865. /**
  7866. * Gets the highlights Density value.
  7867. * 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.
  7868. * Values less than zero provide a filter of opposite hue.
  7869. */
  7870. /**
  7871. * Sets the highlights Density value.
  7872. * 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.
  7873. * Values less than zero provide a filter of opposite hue.
  7874. */
  7875. highlightsDensity: number;
  7876. /**
  7877. * Gets the highlights Saturation value.
  7878. * 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.
  7879. */
  7880. /**
  7881. * Sets the highlights Saturation value.
  7882. * 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.
  7883. */
  7884. highlightsSaturation: number;
  7885. /**
  7886. * Gets the highlights Exposure value.
  7887. * 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.
  7888. */
  7889. /**
  7890. * Sets the highlights Exposure value.
  7891. * 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.
  7892. */
  7893. highlightsExposure: number;
  7894. private _midtonesHue;
  7895. private _midtonesDensity;
  7896. private _midtonesSaturation;
  7897. private _midtonesExposure;
  7898. /**
  7899. * Gets the midtones Hue value.
  7900. * 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).
  7901. */
  7902. /**
  7903. * Sets the midtones Hue value.
  7904. * 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).
  7905. */
  7906. midtonesHue: number;
  7907. /**
  7908. * Gets the midtones Density value.
  7909. * 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.
  7910. * Values less than zero provide a filter of opposite hue.
  7911. */
  7912. /**
  7913. * Sets the midtones Density value.
  7914. * 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.
  7915. * Values less than zero provide a filter of opposite hue.
  7916. */
  7917. midtonesDensity: number;
  7918. /**
  7919. * Gets the midtones Saturation value.
  7920. * 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.
  7921. */
  7922. /**
  7923. * Sets the midtones Saturation value.
  7924. * 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.
  7925. */
  7926. midtonesSaturation: number;
  7927. /**
  7928. * Gets the midtones Exposure value.
  7929. * 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.
  7930. */
  7931. /**
  7932. * Sets the midtones Exposure value.
  7933. * 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.
  7934. */
  7935. midtonesExposure: number;
  7936. private _shadowsHue;
  7937. private _shadowsDensity;
  7938. private _shadowsSaturation;
  7939. private _shadowsExposure;
  7940. /**
  7941. * Gets the shadows Hue value.
  7942. * 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).
  7943. */
  7944. /**
  7945. * Sets the shadows Hue value.
  7946. * 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).
  7947. */
  7948. shadowsHue: number;
  7949. /**
  7950. * Gets the shadows Density value.
  7951. * 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.
  7952. * Values less than zero provide a filter of opposite hue.
  7953. */
  7954. /**
  7955. * Sets the shadows Density value.
  7956. * 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.
  7957. * Values less than zero provide a filter of opposite hue.
  7958. */
  7959. shadowsDensity: number;
  7960. /**
  7961. * Gets the shadows Saturation value.
  7962. * 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.
  7963. */
  7964. /**
  7965. * Sets the shadows Saturation value.
  7966. * 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.
  7967. */
  7968. shadowsSaturation: number;
  7969. /**
  7970. * Gets the shadows Exposure value.
  7971. * 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.
  7972. */
  7973. /**
  7974. * Sets the shadows Exposure value.
  7975. * 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.
  7976. */
  7977. shadowsExposure: number;
  7978. getClassName(): string;
  7979. /**
  7980. * Binds the color curves to the shader.
  7981. * @param colorCurves The color curve to bind
  7982. * @param effect The effect to bind to
  7983. */
  7984. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  7985. /**
  7986. * Prepare the list of uniforms associated with the ColorCurves effects.
  7987. * @param uniformsList The list of uniforms used in the effect
  7988. */
  7989. static PrepareUniforms(uniformsList: string[]): void;
  7990. /**
  7991. * Returns color grading data based on a hue, density, saturation and exposure value.
  7992. * @param filterHue The hue of the color filter.
  7993. * @param filterDensity The density of the color filter.
  7994. * @param saturation The saturation.
  7995. * @param exposure The exposure.
  7996. * @param result The result data container.
  7997. */
  7998. private getColorGradingDataToRef(hue, density, saturation, exposure, result);
  7999. /**
  8000. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  8001. * @param value The input slider value in range [-100,100].
  8002. * @returns Adjusted value.
  8003. */
  8004. private static applyColorGradingSliderNonlinear(value);
  8005. /**
  8006. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  8007. * @param hue The hue (H) input.
  8008. * @param saturation The saturation (S) input.
  8009. * @param brightness The brightness (B) input.
  8010. * @result An RGBA color represented as Vector4.
  8011. */
  8012. private static fromHSBToRef(hue, saturation, brightness, result);
  8013. /**
  8014. * Returns a value clamped between min and max
  8015. * @param value The value to clamp
  8016. * @param min The minimum of value
  8017. * @param max The maximum of value
  8018. * @returns The clamped value.
  8019. */
  8020. private static clamp(value, min, max);
  8021. /**
  8022. * Clones the current color curve instance.
  8023. * @return The cloned curves
  8024. */
  8025. clone(): ColorCurves;
  8026. /**
  8027. * Serializes the current color curve instance to a json representation.
  8028. * @return a JSON representation
  8029. */
  8030. serialize(): any;
  8031. /**
  8032. * Parses the color curve from a json representation.
  8033. * @param source the JSON source to parse
  8034. * @return The parsed curves
  8035. */
  8036. static Parse(source: any): ColorCurves;
  8037. }
  8038. }
  8039. declare module BABYLON {
  8040. /**
  8041. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  8042. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  8043. */
  8044. class EffectFallbacks {
  8045. private _defines;
  8046. private _currentRank;
  8047. private _maxRank;
  8048. private _mesh;
  8049. /**
  8050. * Removes the fallback from the bound mesh.
  8051. */
  8052. unBindMesh(): void;
  8053. /**
  8054. * Adds a fallback on the specified property.
  8055. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  8056. * @param define The name of the define in the shader
  8057. */
  8058. addFallback(rank: number, define: string): void;
  8059. /**
  8060. * Sets the mesh to use CPU skinning when needing to fallback.
  8061. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  8062. * @param mesh The mesh to use the fallbacks.
  8063. */
  8064. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  8065. /**
  8066. * Checks to see if more fallbacks are still availible.
  8067. */
  8068. readonly isMoreFallbacks: boolean;
  8069. /**
  8070. * Removes the defines that shoould be removed when falling back.
  8071. * @param currentDefines defines the current define statements for the shader.
  8072. * @param effect defines the current effect we try to compile
  8073. * @returns The resulting defines with defines of the current rank removed.
  8074. */
  8075. reduce(currentDefines: string, effect: Effect): string;
  8076. }
  8077. /**
  8078. * Options to be used when creating an effect.
  8079. */
  8080. class EffectCreationOptions {
  8081. /**
  8082. * Atrributes that will be used in the shader.
  8083. */
  8084. attributes: string[];
  8085. /**
  8086. * Uniform varible names that will be set in the shader.
  8087. */
  8088. uniformsNames: string[];
  8089. /**
  8090. * Uniform buffer varible names that will be set in the shader.
  8091. */
  8092. uniformBuffersNames: string[];
  8093. /**
  8094. * Sampler texture variable names that will be set in the shader.
  8095. */
  8096. samplers: string[];
  8097. /**
  8098. * Define statements that will be set in the shader.
  8099. */
  8100. defines: any;
  8101. /**
  8102. * Possible fallbacks for this effect to improve performance when needed.
  8103. */
  8104. fallbacks: Nullable<EffectFallbacks>;
  8105. /**
  8106. * Callback that will be called when the shader is compiled.
  8107. */
  8108. onCompiled: Nullable<(effect: Effect) => void>;
  8109. /**
  8110. * Callback that will be called if an error occurs during shader compilation.
  8111. */
  8112. onError: Nullable<(effect: Effect, errors: string) => void>;
  8113. /**
  8114. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  8115. */
  8116. indexParameters: any;
  8117. /**
  8118. * Max number of lights that can be used in the shader.
  8119. */
  8120. maxSimultaneousLights: number;
  8121. /**
  8122. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  8123. */
  8124. transformFeedbackVaryings: Nullable<string[]>;
  8125. }
  8126. /**
  8127. * Effect containing vertex and fragment shader that can be executed on an object.
  8128. */
  8129. class Effect {
  8130. /**
  8131. * Name of the effect.
  8132. */
  8133. name: any;
  8134. /**
  8135. * String container all the define statements that should be set on the shader.
  8136. */
  8137. defines: string;
  8138. /**
  8139. * Callback that will be called when the shader is compiled.
  8140. */
  8141. onCompiled: Nullable<(effect: Effect) => void>;
  8142. /**
  8143. * Callback that will be called if an error occurs during shader compilation.
  8144. */
  8145. onError: Nullable<(effect: Effect, errors: string) => void>;
  8146. /**
  8147. * Callback that will be called when effect is bound.
  8148. */
  8149. onBind: Nullable<(effect: Effect) => void>;
  8150. /**
  8151. * Unique ID of the effect.
  8152. */
  8153. uniqueId: number;
  8154. /**
  8155. * Observable that will be called when the shader is compiled.
  8156. */
  8157. onCompileObservable: Observable<Effect>;
  8158. /**
  8159. * Observable that will be called if an error occurs during shader compilation.
  8160. */
  8161. onErrorObservable: Observable<Effect>;
  8162. /**
  8163. * Observable that will be called when effect is bound.
  8164. */
  8165. onBindObservable: Observable<Effect>;
  8166. private static _uniqueIdSeed;
  8167. private _engine;
  8168. private _uniformBuffersNames;
  8169. private _uniformsNames;
  8170. private _samplers;
  8171. private _isReady;
  8172. private _compilationError;
  8173. private _attributesNames;
  8174. private _attributes;
  8175. private _uniforms;
  8176. /**
  8177. * Key for the effect.
  8178. */
  8179. _key: string;
  8180. private _indexParameters;
  8181. private _fallbacks;
  8182. private _vertexSourceCode;
  8183. private _fragmentSourceCode;
  8184. private _vertexSourceCodeOverride;
  8185. private _fragmentSourceCodeOverride;
  8186. private _transformFeedbackVaryings;
  8187. /**
  8188. * Compiled shader to webGL program.
  8189. */
  8190. _program: WebGLProgram;
  8191. private _valueCache;
  8192. private static _baseCache;
  8193. /**
  8194. * Instantiates an effect.
  8195. * An effect can be used to create/manage/execute vertex and fragment shaders.
  8196. * @param baseName Name of the effect.
  8197. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  8198. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  8199. * @param samplers List of sampler variables that will be passed to the shader.
  8200. * @param engine Engine to be used to render the effect
  8201. * @param defines Define statements to be added to the shader.
  8202. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  8203. * @param onCompiled Callback that will be called when the shader is compiled.
  8204. * @param onError Callback that will be called if an error occurs during shader compilation.
  8205. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  8206. */
  8207. 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);
  8208. /**
  8209. * Unique key for this effect
  8210. */
  8211. readonly key: string;
  8212. /**
  8213. * If the effect has been compiled and prepared.
  8214. * @returns if the effect is compiled and prepared.
  8215. */
  8216. isReady(): boolean;
  8217. /**
  8218. * The engine the effect was initialized with.
  8219. * @returns the engine.
  8220. */
  8221. getEngine(): Engine;
  8222. /**
  8223. * The compiled webGL program for the effect
  8224. * @returns the webGL program.
  8225. */
  8226. getProgram(): WebGLProgram;
  8227. /**
  8228. * The set of names of attribute variables for the shader.
  8229. * @returns An array of attribute names.
  8230. */
  8231. getAttributesNames(): string[];
  8232. /**
  8233. * Returns the attribute at the given index.
  8234. * @param index The index of the attribute.
  8235. * @returns The location of the attribute.
  8236. */
  8237. getAttributeLocation(index: number): number;
  8238. /**
  8239. * Returns the attribute based on the name of the variable.
  8240. * @param name of the attribute to look up.
  8241. * @returns the attribute location.
  8242. */
  8243. getAttributeLocationByName(name: string): number;
  8244. /**
  8245. * The number of attributes.
  8246. * @returns the numnber of attributes.
  8247. */
  8248. getAttributesCount(): number;
  8249. /**
  8250. * Gets the index of a uniform variable.
  8251. * @param uniformName of the uniform to look up.
  8252. * @returns the index.
  8253. */
  8254. getUniformIndex(uniformName: string): number;
  8255. /**
  8256. * Returns the attribute based on the name of the variable.
  8257. * @param uniformName of the uniform to look up.
  8258. * @returns the location of the uniform.
  8259. */
  8260. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  8261. /**
  8262. * Returns an array of sampler variable names
  8263. * @returns The array of sampler variable neames.
  8264. */
  8265. getSamplers(): string[];
  8266. /**
  8267. * The error from the last compilation.
  8268. * @returns the error string.
  8269. */
  8270. getCompilationError(): string;
  8271. /**
  8272. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  8273. * @param func The callback to be used.
  8274. */
  8275. executeWhenCompiled(func: (effect: Effect) => void): void;
  8276. /** @ignore */
  8277. _loadVertexShaderAsync(vertex: any): Promise<any>;
  8278. /** @ignore */
  8279. _loadFragmentShaderAsync(fragment: any): Promise<any>;
  8280. private _dumpShadersSource(vertexCode, fragmentCode, defines);
  8281. private _processShaderConversion(sourceCode, isFragment);
  8282. private _processIncludesAsync(sourceCode);
  8283. private _processPrecision(source);
  8284. /**
  8285. * Recompiles the webGL program
  8286. * @param vertexSourceCode The source code for the vertex shader.
  8287. * @param fragmentSourceCode The source code for the fragment shader.
  8288. * @param onCompiled Callback called when completed.
  8289. * @param onError Callback called on error.
  8290. */
  8291. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void): void;
  8292. /**
  8293. * Gets the uniform locations of the the specified variable names
  8294. * @param names THe names of the variables to lookup.
  8295. * @returns Array of locations in the same order as variable names.
  8296. */
  8297. getSpecificUniformLocations(names: string[]): Nullable<WebGLUniformLocation>[];
  8298. /**
  8299. * Prepares the effect
  8300. */
  8301. _prepareEffect(): void;
  8302. /**
  8303. * Checks if the effect is supported. (Must be called after compilation)
  8304. */
  8305. readonly isSupported: boolean;
  8306. /**
  8307. * Binds a texture to the engine to be used as output of the shader.
  8308. * @param channel Name of the output variable.
  8309. * @param texture Texture to bind.
  8310. */
  8311. _bindTexture(channel: string, texture: InternalTexture): void;
  8312. /**
  8313. * Sets a texture on the engine to be used in the shader.
  8314. * @param channel Name of the sampler variable.
  8315. * @param texture Texture to set.
  8316. */
  8317. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  8318. /**
  8319. * Sets an array of textures on the engine to be used in the shader.
  8320. * @param channel Name of the variable.
  8321. * @param textures Textures to set.
  8322. */
  8323. setTextureArray(channel: string, textures: BaseTexture[]): void;
  8324. /**
  8325. * 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)
  8326. * @param channel Name of the sampler variable.
  8327. * @param postProcess Post process to get the input texture from.
  8328. */
  8329. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  8330. /** @ignore */
  8331. _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  8332. /** @ignore */
  8333. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  8334. /** @ignore */
  8335. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  8336. /** @ignore */
  8337. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  8338. /**
  8339. * Binds a buffer to a uniform.
  8340. * @param buffer Buffer to bind.
  8341. * @param name Name of the uniform variable to bind to.
  8342. */
  8343. bindUniformBuffer(buffer: WebGLBuffer, name: string): void;
  8344. /**
  8345. * Binds block to a uniform.
  8346. * @param blockName Name of the block to bind.
  8347. * @param index Index to bind.
  8348. */
  8349. bindUniformBlock(blockName: string, index: number): void;
  8350. /**
  8351. * Sets an interger value on a uniform variable.
  8352. * @param uniformName Name of the variable.
  8353. * @param value Value to be set.
  8354. * @returns this effect.
  8355. */
  8356. setInt(uniformName: string, value: number): Effect;
  8357. /**
  8358. * Sets an int array on a uniform variable.
  8359. * @param uniformName Name of the variable.
  8360. * @param array array to be set.
  8361. * @returns this effect.
  8362. */
  8363. setIntArray(uniformName: string, array: Int32Array): Effect;
  8364. /**
  8365. * 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)
  8366. * @param uniformName Name of the variable.
  8367. * @param array array to be set.
  8368. * @returns this effect.
  8369. */
  8370. setIntArray2(uniformName: string, array: Int32Array): Effect;
  8371. /**
  8372. * 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)
  8373. * @param uniformName Name of the variable.
  8374. * @param array array to be set.
  8375. * @returns this effect.
  8376. */
  8377. setIntArray3(uniformName: string, array: Int32Array): Effect;
  8378. /**
  8379. * 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)
  8380. * @param uniformName Name of the variable.
  8381. * @param array array to be set.
  8382. * @returns this effect.
  8383. */
  8384. setIntArray4(uniformName: string, array: Int32Array): Effect;
  8385. /**
  8386. * Sets an float array on a uniform variable.
  8387. * @param uniformName Name of the variable.
  8388. * @param array array to be set.
  8389. * @returns this effect.
  8390. */
  8391. setFloatArray(uniformName: string, array: Float32Array): Effect;
  8392. /**
  8393. * 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)
  8394. * @param uniformName Name of the variable.
  8395. * @param array array to be set.
  8396. * @returns this effect.
  8397. */
  8398. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  8399. /**
  8400. * 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)
  8401. * @param uniformName Name of the variable.
  8402. * @param array array to be set.
  8403. * @returns this effect.
  8404. */
  8405. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  8406. /**
  8407. * 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)
  8408. * @param uniformName Name of the variable.
  8409. * @param array array to be set.
  8410. * @returns this effect.
  8411. */
  8412. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  8413. /**
  8414. * Sets an array on a uniform variable.
  8415. * @param uniformName Name of the variable.
  8416. * @param array array to be set.
  8417. * @returns this effect.
  8418. */
  8419. setArray(uniformName: string, array: number[]): Effect;
  8420. /**
  8421. * 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)
  8422. * @param uniformName Name of the variable.
  8423. * @param array array to be set.
  8424. * @returns this effect.
  8425. */
  8426. setArray2(uniformName: string, array: number[]): Effect;
  8427. /**
  8428. * 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)
  8429. * @param uniformName Name of the variable.
  8430. * @param array array to be set.
  8431. * @returns this effect.
  8432. */
  8433. setArray3(uniformName: string, array: number[]): Effect;
  8434. /**
  8435. * 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)
  8436. * @param uniformName Name of the variable.
  8437. * @param array array to be set.
  8438. * @returns this effect.
  8439. */
  8440. setArray4(uniformName: string, array: number[]): Effect;
  8441. /**
  8442. * Sets matrices on a uniform variable.
  8443. * @param uniformName Name of the variable.
  8444. * @param matrices matrices to be set.
  8445. * @returns this effect.
  8446. */
  8447. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  8448. /**
  8449. * Sets matrix on a uniform variable.
  8450. * @param uniformName Name of the variable.
  8451. * @param matrix matrix to be set.
  8452. * @returns this effect.
  8453. */
  8454. setMatrix(uniformName: string, matrix: Matrix): Effect;
  8455. /**
  8456. * 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)
  8457. * @param uniformName Name of the variable.
  8458. * @param matrix matrix to be set.
  8459. * @returns this effect.
  8460. */
  8461. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  8462. /**
  8463. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  8464. * @param uniformName Name of the variable.
  8465. * @param matrix matrix to be set.
  8466. * @returns this effect.
  8467. */
  8468. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  8469. /**
  8470. * Sets a float on a uniform variable.
  8471. * @param uniformName Name of the variable.
  8472. * @param value value to be set.
  8473. * @returns this effect.
  8474. */
  8475. setFloat(uniformName: string, value: number): Effect;
  8476. /**
  8477. * Sets a boolean on a uniform variable.
  8478. * @param uniformName Name of the variable.
  8479. * @param bool value to be set.
  8480. * @returns this effect.
  8481. */
  8482. setBool(uniformName: string, bool: boolean): Effect;
  8483. /**
  8484. * Sets a Vector2 on a uniform variable.
  8485. * @param uniformName Name of the variable.
  8486. * @param vector2 vector2 to be set.
  8487. * @returns this effect.
  8488. */
  8489. setVector2(uniformName: string, vector2: Vector2): Effect;
  8490. /**
  8491. * Sets a float2 on a uniform variable.
  8492. * @param uniformName Name of the variable.
  8493. * @param x First float in float2.
  8494. * @param y Second float in float2.
  8495. * @returns this effect.
  8496. */
  8497. setFloat2(uniformName: string, x: number, y: number): Effect;
  8498. /**
  8499. * Sets a Vector3 on a uniform variable.
  8500. * @param uniformName Name of the variable.
  8501. * @param vector3 Value to be set.
  8502. * @returns this effect.
  8503. */
  8504. setVector3(uniformName: string, vector3: Vector3): Effect;
  8505. /**
  8506. * Sets a float3 on a uniform variable.
  8507. * @param uniformName Name of the variable.
  8508. * @param x First float in float3.
  8509. * @param y Second float in float3.
  8510. * @param z Third float in float3.
  8511. * @returns this effect.
  8512. */
  8513. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  8514. /**
  8515. * Sets a Vector4 on a uniform variable.
  8516. * @param uniformName Name of the variable.
  8517. * @param vector4 Value to be set.
  8518. * @returns this effect.
  8519. */
  8520. setVector4(uniformName: string, vector4: Vector4): Effect;
  8521. /**
  8522. * Sets a float4 on a uniform variable.
  8523. * @param uniformName Name of the variable.
  8524. * @param x First float in float4.
  8525. * @param y Second float in float4.
  8526. * @param z Third float in float4.
  8527. * @param w Fourth float in float4.
  8528. * @returns this effect.
  8529. */
  8530. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  8531. /**
  8532. * Sets a Color3 on a uniform variable.
  8533. * @param uniformName Name of the variable.
  8534. * @param color3 Value to be set.
  8535. * @returns this effect.
  8536. */
  8537. setColor3(uniformName: string, color3: Color3): Effect;
  8538. /**
  8539. * Sets a Color4 on a uniform variable.
  8540. * @param uniformName Name of the variable.
  8541. * @param color3 Value to be set.
  8542. * @param alpha Alpha value to be set.
  8543. * @returns this effect.
  8544. */
  8545. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  8546. /**
  8547. * Sets a Color4 on a uniform variable
  8548. * @param uniformName defines the name of the variable
  8549. * @param color4 defines the value to be set
  8550. * @returns this effect.
  8551. */
  8552. setDirectColor4(uniformName: string, color4: Color4): Effect;
  8553. /**
  8554. * Store of each shader (The can be looked up using effect.key)
  8555. */
  8556. static ShadersStore: {
  8557. [key: string]: string;
  8558. };
  8559. /**
  8560. * Store of each included file for a shader (The can be looked up using effect.key)
  8561. */
  8562. static IncludesShadersStore: {
  8563. [key: string]: string;
  8564. };
  8565. /**
  8566. * Resets the cache of effects.
  8567. */
  8568. static ResetCache(): void;
  8569. }
  8570. }
  8571. declare module BABYLON {
  8572. class FresnelParameters {
  8573. private _isEnabled;
  8574. isEnabled: boolean;
  8575. leftColor: Color3;
  8576. rightColor: Color3;
  8577. bias: number;
  8578. power: number;
  8579. clone(): FresnelParameters;
  8580. serialize(): any;
  8581. static Parse(parsedFresnelParameters: any): FresnelParameters;
  8582. }
  8583. }
  8584. declare module BABYLON {
  8585. /**
  8586. * Interface to follow in your material defines to integrate easily the
  8587. * Image proccessing functions.
  8588. */
  8589. interface IImageProcessingConfigurationDefines {
  8590. IMAGEPROCESSING: boolean;
  8591. VIGNETTE: boolean;
  8592. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8593. VIGNETTEBLENDMODEOPAQUE: boolean;
  8594. TONEMAPPING: boolean;
  8595. CONTRAST: boolean;
  8596. EXPOSURE: boolean;
  8597. COLORCURVES: boolean;
  8598. COLORGRADING: boolean;
  8599. COLORGRADING3D: boolean;
  8600. SAMPLER3DGREENDEPTH: boolean;
  8601. SAMPLER3DBGRMAP: boolean;
  8602. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8603. }
  8604. /**
  8605. * This groups together the common properties used for image processing either in direct forward pass
  8606. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8607. * or not.
  8608. */
  8609. class ImageProcessingConfiguration {
  8610. /**
  8611. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8612. */
  8613. colorCurves: Nullable<ColorCurves>;
  8614. private _colorCurvesEnabled;
  8615. /**
  8616. * Gets wether the color curves effect is enabled.
  8617. */
  8618. /**
  8619. * Sets wether the color curves effect is enabled.
  8620. */
  8621. colorCurvesEnabled: boolean;
  8622. /**
  8623. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8624. */
  8625. colorGradingTexture: Nullable<BaseTexture>;
  8626. private _colorGradingEnabled;
  8627. /**
  8628. * Gets wether the color grading effect is enabled.
  8629. */
  8630. /**
  8631. * Sets wether the color grading effect is enabled.
  8632. */
  8633. colorGradingEnabled: boolean;
  8634. private _colorGradingWithGreenDepth;
  8635. /**
  8636. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8637. */
  8638. /**
  8639. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8640. */
  8641. colorGradingWithGreenDepth: boolean;
  8642. private _colorGradingBGR;
  8643. /**
  8644. * Gets wether the color grading texture contains BGR values.
  8645. */
  8646. /**
  8647. * Sets wether the color grading texture contains BGR values.
  8648. */
  8649. colorGradingBGR: boolean;
  8650. _exposure: number;
  8651. /**
  8652. * Gets the Exposure used in the effect.
  8653. */
  8654. /**
  8655. * Sets the Exposure used in the effect.
  8656. */
  8657. exposure: number;
  8658. private _toneMappingEnabled;
  8659. /**
  8660. * Gets wether the tone mapping effect is enabled.
  8661. */
  8662. /**
  8663. * Sets wether the tone mapping effect is enabled.
  8664. */
  8665. toneMappingEnabled: boolean;
  8666. protected _contrast: number;
  8667. /**
  8668. * Gets the contrast used in the effect.
  8669. */
  8670. /**
  8671. * Sets the contrast used in the effect.
  8672. */
  8673. contrast: number;
  8674. /**
  8675. * Vignette stretch size.
  8676. */
  8677. vignetteStretch: number;
  8678. /**
  8679. * Vignette centre X Offset.
  8680. */
  8681. vignetteCentreX: number;
  8682. /**
  8683. * Vignette centre Y Offset.
  8684. */
  8685. vignetteCentreY: number;
  8686. /**
  8687. * Vignette weight or intensity of the vignette effect.
  8688. */
  8689. vignetteWeight: number;
  8690. /**
  8691. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8692. * if vignetteEnabled is set to true.
  8693. */
  8694. vignetteColor: Color4;
  8695. /**
  8696. * Camera field of view used by the Vignette effect.
  8697. */
  8698. vignetteCameraFov: number;
  8699. private _vignetteBlendMode;
  8700. /**
  8701. * Gets the vignette blend mode allowing different kind of effect.
  8702. */
  8703. /**
  8704. * Sets the vignette blend mode allowing different kind of effect.
  8705. */
  8706. vignetteBlendMode: number;
  8707. private _vignetteEnabled;
  8708. /**
  8709. * Gets wether the vignette effect is enabled.
  8710. */
  8711. /**
  8712. * Sets wether the vignette effect is enabled.
  8713. */
  8714. vignetteEnabled: boolean;
  8715. private _applyByPostProcess;
  8716. /**
  8717. * Gets wether the image processing is applied through a post process or not.
  8718. */
  8719. /**
  8720. * Sets wether the image processing is applied through a post process or not.
  8721. */
  8722. applyByPostProcess: boolean;
  8723. private _isEnabled;
  8724. /**
  8725. * Gets wether the image processing is enabled or not.
  8726. */
  8727. /**
  8728. * Sets wether the image processing is enabled or not.
  8729. */
  8730. isEnabled: boolean;
  8731. /**
  8732. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8733. * @type {BABYLON.Observable}
  8734. */
  8735. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8736. /**
  8737. * Method called each time the image processing information changes requires to recompile the effect.
  8738. */
  8739. protected _updateParameters(): void;
  8740. getClassName(): string;
  8741. /**
  8742. * Prepare the list of uniforms associated with the Image Processing effects.
  8743. * @param uniformsList The list of uniforms used in the effect
  8744. * @param defines the list of defines currently in use
  8745. */
  8746. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8747. /**
  8748. * Prepare the list of samplers associated with the Image Processing effects.
  8749. * @param uniformsList The list of uniforms used in the effect
  8750. * @param defines the list of defines currently in use
  8751. */
  8752. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8753. /**
  8754. * Prepare the list of defines associated to the shader.
  8755. * @param defines the list of defines to complete
  8756. */
  8757. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8758. /**
  8759. * Returns true if all the image processing information are ready.
  8760. */
  8761. isReady(): boolean;
  8762. /**
  8763. * Binds the image processing to the shader.
  8764. * @param effect The effect to bind to
  8765. */
  8766. bind(effect: Effect, aspectRatio?: number): void;
  8767. /**
  8768. * Clones the current image processing instance.
  8769. * @return The cloned image processing
  8770. */
  8771. clone(): ImageProcessingConfiguration;
  8772. /**
  8773. * Serializes the current image processing instance to a json representation.
  8774. * @return a JSON representation
  8775. */
  8776. serialize(): any;
  8777. /**
  8778. * Parses the image processing from a json representation.
  8779. * @param source the JSON source to parse
  8780. * @return The parsed image processing
  8781. */
  8782. static Parse(source: any): ImageProcessingConfiguration;
  8783. private static _VIGNETTEMODE_MULTIPLY;
  8784. private static _VIGNETTEMODE_OPAQUE;
  8785. /**
  8786. * Used to apply the vignette as a mix with the pixel color.
  8787. */
  8788. static readonly VIGNETTEMODE_MULTIPLY: number;
  8789. /**
  8790. * Used to apply the vignette as a replacement of the pixel color.
  8791. */
  8792. static readonly VIGNETTEMODE_OPAQUE: number;
  8793. }
  8794. }
  8795. declare module BABYLON {
  8796. /**
  8797. * Manages the defines for the Material.
  8798. */
  8799. class MaterialDefines {
  8800. private _keys;
  8801. private _isDirty;
  8802. _renderId: number;
  8803. _areLightsDirty: boolean;
  8804. _areAttributesDirty: boolean;
  8805. _areTexturesDirty: boolean;
  8806. _areFresnelDirty: boolean;
  8807. _areMiscDirty: boolean;
  8808. _areImageProcessingDirty: boolean;
  8809. _normals: boolean;
  8810. _uvs: boolean;
  8811. _needNormals: boolean;
  8812. _needUVs: boolean;
  8813. /**
  8814. * Specifies if the material needs to be re-calculated.
  8815. */
  8816. readonly isDirty: boolean;
  8817. /**
  8818. * Marks the material to indicate that it has been re-calculated.
  8819. */
  8820. markAsProcessed(): void;
  8821. /**
  8822. * Marks the material to indicate that it needs to be re-calculated.
  8823. */
  8824. markAsUnprocessed(): void;
  8825. /**
  8826. * Marks the material to indicate all of its defines need to be re-calculated.
  8827. */
  8828. markAllAsDirty(): void;
  8829. /**
  8830. * Marks the material to indicate that image processing needs to be re-calculated.
  8831. */
  8832. markAsImageProcessingDirty(): void;
  8833. /**
  8834. * Marks the material to indicate the lights need to be re-calculated.
  8835. */
  8836. markAsLightDirty(): void;
  8837. /**
  8838. * Marks the attribute state as changed.
  8839. */
  8840. markAsAttributesDirty(): void;
  8841. /**
  8842. * Marks the texture state as changed.
  8843. */
  8844. markAsTexturesDirty(): void;
  8845. /**
  8846. * Marks the fresnel state as changed.
  8847. */
  8848. markAsFresnelDirty(): void;
  8849. /**
  8850. * Marks the misc state as changed.
  8851. */
  8852. markAsMiscDirty(): void;
  8853. /**
  8854. * Rebuilds the material defines.
  8855. */
  8856. rebuild(): void;
  8857. /**
  8858. * Specifies if two material defines are equal.
  8859. * @param other - A material define instance to compare to.
  8860. * @returns - Boolean indicating if the material defines are equal (true) or not (false).
  8861. */
  8862. isEqual(other: MaterialDefines): boolean;
  8863. /**
  8864. * Clones this instance's defines to another instance.
  8865. * @param other - material defines to clone values to.
  8866. */
  8867. cloneTo(other: MaterialDefines): void;
  8868. /**
  8869. * Resets the material define values.
  8870. */
  8871. reset(): void;
  8872. /**
  8873. * Converts the material define values to a string.
  8874. * @returns - String of material define information.
  8875. */
  8876. toString(): string;
  8877. }
  8878. /**
  8879. * This offers the main features of a material in BJS.
  8880. */
  8881. class Material implements IAnimatable {
  8882. private static _TriangleFillMode;
  8883. private static _WireFrameFillMode;
  8884. private static _PointFillMode;
  8885. private static _PointListDrawMode;
  8886. private static _LineListDrawMode;
  8887. private static _LineLoopDrawMode;
  8888. private static _LineStripDrawMode;
  8889. private static _TriangleStripDrawMode;
  8890. private static _TriangleFanDrawMode;
  8891. /**
  8892. * Returns the triangle fill mode.
  8893. */
  8894. static readonly TriangleFillMode: number;
  8895. /**
  8896. * Returns the wireframe mode.
  8897. */
  8898. static readonly WireFrameFillMode: number;
  8899. /**
  8900. * Returns the point fill mode.
  8901. */
  8902. static readonly PointFillMode: number;
  8903. /**
  8904. * Returns the point list draw mode.
  8905. */
  8906. static readonly PointListDrawMode: number;
  8907. /**
  8908. * Returns the line list draw mode.
  8909. */
  8910. static readonly LineListDrawMode: number;
  8911. /**
  8912. * Returns the line loop draw mode.
  8913. */
  8914. static readonly LineLoopDrawMode: number;
  8915. /**
  8916. * Returns the line strip draw mode.
  8917. */
  8918. static readonly LineStripDrawMode: number;
  8919. /**
  8920. * Returns the triangle strip draw mode.
  8921. */
  8922. static readonly TriangleStripDrawMode: number;
  8923. /**
  8924. * Returns the triangle fan draw mode.
  8925. */
  8926. static readonly TriangleFanDrawMode: number;
  8927. /**
  8928. * Stores the clock-wise side orientation.
  8929. */
  8930. private static _ClockWiseSideOrientation;
  8931. /**
  8932. * Stores the counter clock-wise side orientation.
  8933. */
  8934. private static _CounterClockWiseSideOrientation;
  8935. /**
  8936. * Returns the clock-wise side orientation.
  8937. */
  8938. static readonly ClockWiseSideOrientation: number;
  8939. /**
  8940. * Returns the counter clock-wise side orientation.
  8941. */
  8942. static readonly CounterClockWiseSideOrientation: number;
  8943. /**
  8944. * The dirty texture flag value.
  8945. */
  8946. private static _TextureDirtyFlag;
  8947. /**
  8948. * The dirty light flag value.
  8949. */
  8950. private static _LightDirtyFlag;
  8951. /**
  8952. * The dirty fresnel flag value.
  8953. */
  8954. private static _FresnelDirtyFlag;
  8955. /**
  8956. * The dirty attribute flag value.
  8957. */
  8958. private static _AttributesDirtyFlag;
  8959. /**
  8960. * The dirty misc flag value.
  8961. */
  8962. private static _MiscDirtyFlag;
  8963. /**
  8964. * Returns the dirty texture flag value.
  8965. */
  8966. static readonly TextureDirtyFlag: number;
  8967. /**
  8968. * Returns the dirty light flag value.
  8969. */
  8970. static readonly LightDirtyFlag: number;
  8971. /**
  8972. * Returns the dirty fresnel flag value.
  8973. */
  8974. static readonly FresnelDirtyFlag: number;
  8975. /**
  8976. * Returns the dirty attributes flag value.
  8977. */
  8978. static readonly AttributesDirtyFlag: number;
  8979. /**
  8980. * Returns the dirty misc flag value.
  8981. */
  8982. static readonly MiscDirtyFlag: number;
  8983. /**
  8984. * The ID of the material.
  8985. */
  8986. id: string;
  8987. /**
  8988. * The name of the material.
  8989. */
  8990. name: string;
  8991. /**
  8992. * Specifies if the ready state should be checked on each call.
  8993. */
  8994. checkReadyOnEveryCall: boolean;
  8995. /**
  8996. * Specifies if the ready state should be checked once.
  8997. */
  8998. checkReadyOnlyOnce: boolean;
  8999. /**
  9000. * The state of the material.
  9001. */
  9002. state: string;
  9003. /**
  9004. * The alpha value of the material.
  9005. */
  9006. protected _alpha: number;
  9007. /**
  9008. * Gets the alpha value of the material.
  9009. */
  9010. /**
  9011. * Sets the alpha value of the material.
  9012. */
  9013. alpha: number;
  9014. /**
  9015. * Specifies if back face culling is enabled.
  9016. */
  9017. protected _backFaceCulling: boolean;
  9018. /**
  9019. * Gets the back-face culling state.
  9020. */
  9021. /**
  9022. * Sets the back-face culling state.
  9023. */
  9024. backFaceCulling: boolean;
  9025. /**
  9026. * Stores the value for side orientation.
  9027. */
  9028. sideOrientation: number;
  9029. /**
  9030. * Callback triggered when the material is compiled.
  9031. */
  9032. onCompiled: (effect: Effect) => void;
  9033. /**
  9034. * Callback triggered when an error occurs.
  9035. */
  9036. onError: (effect: Effect, errors: string) => void;
  9037. /**
  9038. * Callback triggered to get the render target textures.
  9039. */
  9040. getRenderTargetTextures: () => SmartArray<RenderTargetTexture>;
  9041. /**
  9042. * Specifies if the material should be serialized.
  9043. */
  9044. doNotSerialize: boolean;
  9045. /**
  9046. * Specifies if the effect should be stored on sub meshes.
  9047. */
  9048. storeEffectOnSubMeshes: boolean;
  9049. /**
  9050. * Stores the animations for the material.
  9051. */
  9052. animations: Array<Animation>;
  9053. /**
  9054. * An event triggered when the material is disposed.
  9055. * @type {BABYLON.Observable}
  9056. */
  9057. onDisposeObservable: Observable<Material>;
  9058. /**
  9059. * An observer which watches for dispose events.
  9060. * @type {BABYLON.Observer}
  9061. */
  9062. private _onDisposeObserver;
  9063. /**
  9064. * Called during a dispose event.
  9065. */
  9066. onDispose: () => void;
  9067. /**
  9068. * An event triggered when the material is bound.
  9069. * @type {BABYLON.Observable}
  9070. */
  9071. onBindObservable: Observable<AbstractMesh>;
  9072. /**
  9073. * An observer which watches for bind events.
  9074. * @type {BABYLON.Observer}
  9075. */
  9076. private _onBindObserver;
  9077. /**
  9078. * Called during a bind event.
  9079. */
  9080. onBind: (Mesh: AbstractMesh) => void;
  9081. /**
  9082. * An event triggered when the material is unbound.
  9083. * @type {BABYLON.Observable}
  9084. */
  9085. onUnBindObservable: Observable<Material>;
  9086. /**
  9087. * Stores the value of the alpha mode.
  9088. */
  9089. private _alphaMode;
  9090. /**
  9091. * Gets the value of the alpha mode.
  9092. */
  9093. /**
  9094. * Sets the value of the alpha mode.
  9095. */
  9096. alphaMode: number;
  9097. /**
  9098. * Stores the state of the need depth pre-pass value.
  9099. */
  9100. private _needDepthPrePass;
  9101. /**
  9102. * Gets the depth pre-pass value.
  9103. */
  9104. /**
  9105. * Sets the need depth pre-pass value.
  9106. */
  9107. needDepthPrePass: boolean;
  9108. /**
  9109. * Specifies if depth writing should be disabled.
  9110. */
  9111. disableDepthWrite: boolean;
  9112. /**
  9113. * Specifies if depth writing should be forced.
  9114. */
  9115. forceDepthWrite: boolean;
  9116. /**
  9117. * Specifies if there should be a separate pass for culling.
  9118. */
  9119. separateCullingPass: boolean;
  9120. /**
  9121. * Stores the state specifing if fog should be enabled.
  9122. */
  9123. private _fogEnabled;
  9124. /**
  9125. * Gets the value of the fog enabled state.
  9126. */
  9127. /**
  9128. * Sets the state for enabling fog.
  9129. */
  9130. fogEnabled: boolean;
  9131. /**
  9132. * Stores the size of points.
  9133. */
  9134. pointSize: number;
  9135. /**
  9136. * Stores the z offset value.
  9137. */
  9138. zOffset: number;
  9139. /**
  9140. * Gets a value specifying if wireframe mode is enabled.
  9141. */
  9142. /**
  9143. * Sets the state of wireframe mode.
  9144. */
  9145. wireframe: boolean;
  9146. /**
  9147. * Gets the value specifying if point clouds are enabled.
  9148. */
  9149. /**
  9150. * Sets the state of point cloud mode.
  9151. */
  9152. pointsCloud: boolean;
  9153. /**
  9154. * Gets the material fill mode.
  9155. */
  9156. /**
  9157. * Sets the material fill mode.
  9158. */
  9159. fillMode: number;
  9160. /**
  9161. * Stores the effects for the material.
  9162. */
  9163. _effect: Nullable<Effect>;
  9164. /**
  9165. * Specifies if the material was previously ready.
  9166. */
  9167. _wasPreviouslyReady: boolean;
  9168. /**
  9169. * Specifies if uniform buffers should be used.
  9170. */
  9171. private _useUBO;
  9172. /**
  9173. * Stores a reference to the scene.
  9174. */
  9175. private _scene;
  9176. /**
  9177. * Stores the fill mode state.
  9178. */
  9179. private _fillMode;
  9180. /**
  9181. * Specifies if the depth write state should be cached.
  9182. */
  9183. private _cachedDepthWriteState;
  9184. /**
  9185. * Stores the uniform buffer.
  9186. */
  9187. protected _uniformBuffer: UniformBuffer;
  9188. /**
  9189. * Creates a material instance.
  9190. * @param name - The name of the material.
  9191. * @param scene - The BJS scene to reference.
  9192. * @param doNotAdd - Specifies if the material should be added to the scene.
  9193. */
  9194. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  9195. /**
  9196. * @param {boolean} fullDetails - support for multiple levels of logging within scene loading
  9197. * subclasses should override adding information pertainent to themselves.
  9198. * @returns - String with material information.
  9199. */
  9200. toString(fullDetails?: boolean): string;
  9201. /**
  9202. * Gets the class name of the material.
  9203. * @returns - String with the class name of the material.
  9204. */
  9205. getClassName(): string;
  9206. /**
  9207. * Specifies if updates for the material been locked.
  9208. */
  9209. readonly isFrozen: boolean;
  9210. /**
  9211. * Locks updates for the material.
  9212. */
  9213. freeze(): void;
  9214. /**
  9215. * Unlocks updates for the material.
  9216. */
  9217. unfreeze(): void;
  9218. /**
  9219. * Specifies if the material is ready to be used.
  9220. * @param mesh - BJS mesh.
  9221. * @param useInstances - Specifies if instances should be used.
  9222. * @returns - Boolean indicating if the material is ready to be used.
  9223. */
  9224. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  9225. /**
  9226. * Specifies that the submesh is ready to be used.
  9227. * @param mesh - BJS mesh.
  9228. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  9229. * @param useInstances - Specifies that instances should be used.
  9230. * @returns - boolean indicating that the submesh is ready or not.
  9231. */
  9232. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  9233. /**
  9234. * Returns the material effect.
  9235. * @returns - Nullable material effect.
  9236. */
  9237. getEffect(): Nullable<Effect>;
  9238. /**
  9239. * Returns the BJS scene.
  9240. * @returns - BJS Scene.
  9241. */
  9242. getScene(): Scene;
  9243. /**
  9244. * Specifies if the material will require alpha blending
  9245. * @returns - Boolean specifying if alpha blending is needed.
  9246. */
  9247. needAlphaBlending(): boolean;
  9248. /**
  9249. * Specifies if the mesh will require alpha blending.
  9250. * @param mesh - BJS mesh.
  9251. * @returns - Boolean specifying if alpha blending is needed for the mesh.
  9252. */
  9253. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  9254. /**
  9255. * Specifies if this material should be rendered in alpha test mode.
  9256. * @returns - Boolean specifying if an alpha test is needed.
  9257. */
  9258. needAlphaTesting(): boolean;
  9259. /**
  9260. * Gets the texture used for the alpha test.
  9261. * @returns - Nullable alpha test texture.
  9262. */
  9263. getAlphaTestTexture(): Nullable<BaseTexture>;
  9264. /**
  9265. * Marks the material to indicate that it needs to be re-calculated.
  9266. */
  9267. markDirty(): void;
  9268. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  9269. /**
  9270. * Binds the material to the mesh.
  9271. * @param world - World transformation matrix.
  9272. * @param mesh - Mesh to bind the material to.
  9273. */
  9274. bind(world: Matrix, mesh?: Mesh): void;
  9275. /**
  9276. * Binds the submesh to the material.
  9277. * @param world - World transformation matrix.
  9278. * @param mesh - Mesh containing the submesh.
  9279. * @param subMesh - Submesh to bind the material to.
  9280. */
  9281. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  9282. /**
  9283. * Binds the world matrix to the material.
  9284. * @param world - World transformation matrix.
  9285. */
  9286. bindOnlyWorldMatrix(world: Matrix): void;
  9287. /**
  9288. * Binds the scene's uniform buffer to the effect.
  9289. * @param effect - Effect to bind to the scene uniform buffer.
  9290. * @param sceneUbo - Scene uniform buffer.
  9291. */
  9292. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  9293. /**
  9294. * Binds the view matrix to the effect.
  9295. * @param effect - Effect to bind the view matrix to.
  9296. */
  9297. bindView(effect: Effect): void;
  9298. /**
  9299. * Binds the view projection matrix to the effect.
  9300. * @param effect - Effect to bind the view projection matrix to.
  9301. */
  9302. bindViewProjection(effect: Effect): void;
  9303. /**
  9304. * Specifies if material alpha testing should be turned on for the mesh.
  9305. * @param mesh - BJS mesh.
  9306. */
  9307. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  9308. /**
  9309. * Processes to execute after binding the material to a mesh.
  9310. * @param mesh - BJS mesh.
  9311. */
  9312. protected _afterBind(mesh?: Mesh): void;
  9313. /**
  9314. * Unbinds the material from the mesh.
  9315. */
  9316. unbind(): void;
  9317. /**
  9318. * Gets the active textures from the material.
  9319. * @returns - Array of textures.
  9320. */
  9321. getActiveTextures(): BaseTexture[];
  9322. /**
  9323. * Specifies if the material uses a texture.
  9324. * @param texture - Texture to check against the material.
  9325. * @returns - Boolean specifying if the material uses the texture.
  9326. */
  9327. hasTexture(texture: BaseTexture): boolean;
  9328. /**
  9329. * Makes a duplicate of the material, and gives it a new name.
  9330. * @param name - Name to call the duplicated material.
  9331. * @returns - Nullable cloned material
  9332. */
  9333. clone(name: string): Nullable<Material>;
  9334. /**
  9335. * Gets the meshes bound to the material.
  9336. * @returns - Array of meshes bound to the material.
  9337. */
  9338. getBindedMeshes(): AbstractMesh[];
  9339. /**
  9340. * Force shader compilation
  9341. * @param mesh - BJS mesh.
  9342. * @param onCompiled - function to execute once the material is compiled.
  9343. * @param options - options to pass to this function.
  9344. */
  9345. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  9346. clipPlane: boolean;
  9347. }>): void;
  9348. /**
  9349. * Force shader compilation.
  9350. * @param mesh The mesh that will use this material
  9351. * @param options Additional options for compiling the shaders
  9352. * @returns A promise that resolves when the compilation completes
  9353. */
  9354. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  9355. clipPlane: boolean;
  9356. }>): Promise<void>;
  9357. /**
  9358. * Marks a define in the material to indicate that it needs to be re-computed.
  9359. * @param flag - Material define flag.
  9360. */
  9361. markAsDirty(flag: number): void;
  9362. /**
  9363. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated.
  9364. * @param func - function which checks material defines against the submeshes.
  9365. */
  9366. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  9367. /**
  9368. * Indicates that image processing needs to be re-calculated for all submeshes.
  9369. */
  9370. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  9371. /**
  9372. * Indicates that textures need to be re-calculated for all submeshes.
  9373. */
  9374. protected _markAllSubMeshesAsTexturesDirty(): void;
  9375. /**
  9376. * Indicates that fresnel needs to be re-calculated for all submeshes.
  9377. */
  9378. protected _markAllSubMeshesAsFresnelDirty(): void;
  9379. /**
  9380. * Indicates that fresnel and misc need to be re-calculated for all submeshes.
  9381. */
  9382. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  9383. /**
  9384. * Indicates that lights need to be re-calculated for all submeshes.
  9385. */
  9386. protected _markAllSubMeshesAsLightsDirty(): void;
  9387. /**
  9388. * Indicates that attributes need to be re-calculated for all submeshes.
  9389. */
  9390. protected _markAllSubMeshesAsAttributesDirty(): void;
  9391. /**
  9392. * Indicates that misc needs to be re-calculated for all submeshes.
  9393. */
  9394. protected _markAllSubMeshesAsMiscDirty(): void;
  9395. /**
  9396. * Indicates that textures and misc need to be re-calculated for all submeshes.
  9397. */
  9398. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  9399. /**
  9400. * Disposes the material.
  9401. * @param forceDisposeEffect - Specifies if effects should be force disposed.
  9402. * @param forceDisposeTextures - Specifies if textures should be force disposed.
  9403. */
  9404. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  9405. /**
  9406. * Serializes this material.
  9407. * @returns - serialized material object.
  9408. */
  9409. serialize(): any;
  9410. /**
  9411. * Creates a MultiMaterial from parse MultiMaterial data.
  9412. * @param parsedMultiMaterial - Parsed MultiMaterial data.
  9413. * @param scene - BJS scene.
  9414. * @returns - MultiMaterial.
  9415. */
  9416. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  9417. /**
  9418. * Creates a material from parsed material data.
  9419. * @param parsedMaterial - Parsed material data.
  9420. * @param scene - BJS scene.
  9421. * @param rootUrl - Root URL containing the material information.
  9422. * @returns - Parsed material.
  9423. */
  9424. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): any;
  9425. }
  9426. }
  9427. declare module BABYLON {
  9428. /**
  9429. * "Static Class" containing the most commonly used helper while dealing with material for
  9430. * rendering purpose.
  9431. *
  9432. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  9433. *
  9434. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  9435. */
  9436. class MaterialHelper {
  9437. /**
  9438. * Bind the current view position to an effect.
  9439. * @param effect The effect to be bound
  9440. * @param scene The scene the eyes position is used from
  9441. */
  9442. static BindEyePosition(effect: Effect, scene: Scene): void;
  9443. /**
  9444. * Helps preparing the defines values about the UVs in used in the effect.
  9445. * UVs are shared as much as we can accross chanels in the shaders.
  9446. * @param texture The texture we are preparing the UVs for
  9447. * @param defines The defines to update
  9448. * @param key The chanel key "diffuse", "specular"... used in the shader
  9449. */
  9450. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  9451. /**
  9452. * Binds a texture matrix value to its corrsponding uniform
  9453. * @param texture The texture to bind the matrix for
  9454. * @param uniformBuffer The uniform buffer receivin the data
  9455. * @param key The chanel key "diffuse", "specular"... used in the shader
  9456. */
  9457. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  9458. /**
  9459. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  9460. * @param mesh defines the current mesh
  9461. * @param scene defines the current scene
  9462. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  9463. * @param pointsCloud defines if point cloud rendering has to be turned on
  9464. * @param fogEnabled defines if fog has to be turned on
  9465. * @param alphaTest defines if alpha testing has to be turned on
  9466. * @param defines defines the current list of defines
  9467. */
  9468. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  9469. /**
  9470. * Helper used to prepare the list of defines associated with frame values for shader compilation
  9471. * @param scene defines the current scene
  9472. * @param engine defines the current engine
  9473. * @param defines specifies the list of active defines
  9474. * @param useInstances defines if instances have to be turned on
  9475. * @param useClipPlane defines if clip plane have to be turned on
  9476. */
  9477. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  9478. /**
  9479. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  9480. * @param mesh The mesh containing the geometry data we will draw
  9481. * @param defines The defines to update
  9482. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  9483. * @param useBones Precise whether bones should be used or not (override mesh info)
  9484. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  9485. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  9486. * @returns false if defines are considered not dirty and have not been checked
  9487. */
  9488. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  9489. /**
  9490. * Prepares the defines related to the light information passed in parameter
  9491. * @param scene The scene we are intending to draw
  9492. * @param mesh The mesh the effect is compiling for
  9493. * @param defines The defines to update
  9494. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9495. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  9496. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  9497. * @returns true if normals will be required for the rest of the effect
  9498. */
  9499. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  9500. /**
  9501. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  9502. * that won t be acctive due to defines being turned off.
  9503. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  9504. * @param samplersList The samplers list
  9505. * @param defines The defines helping in the list generation
  9506. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  9507. */
  9508. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  9509. /**
  9510. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9511. * @param defines The defines to update while falling back
  9512. * @param fallbacks The authorized effect fallbacks
  9513. * @param maxSimultaneousLights The maximum number of lights allowed
  9514. * @param rank the current rank of the Effect
  9515. * @returns The newly affected rank
  9516. */
  9517. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9518. /**
  9519. * Prepares the list of attributes required for morph targets according to the effect defines.
  9520. * @param attribs The current list of supported attribs
  9521. * @param mesh The mesh to prepare the morph targets attributes for
  9522. * @param defines The current Defines of the effect
  9523. */
  9524. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9525. /**
  9526. * Prepares the list of attributes required for bones according to the effect defines.
  9527. * @param attribs The current list of supported attribs
  9528. * @param mesh The mesh to prepare the bones attributes for
  9529. * @param defines The current Defines of the effect
  9530. * @param fallbacks The current efffect fallback strategy
  9531. */
  9532. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9533. /**
  9534. * Prepares the list of attributes required for instances according to the effect defines.
  9535. * @param attribs The current list of supported attribs
  9536. * @param defines The current Defines of the effect
  9537. */
  9538. static PrepareAttributesForInstances(attribs: string[], defines: any): void;
  9539. /**
  9540. * Binds the light shadow information to the effect for the given mesh.
  9541. * @param light The light containing the generator
  9542. * @param scene The scene the lights belongs to
  9543. * @param mesh The mesh we are binding the information to render
  9544. * @param lightIndex The light index in the effect used to render the mesh
  9545. * @param effect The effect we are binding the data to
  9546. */
  9547. static BindLightShadow(light: Light, scene: Scene, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  9548. /**
  9549. * Binds the light information to the effect.
  9550. * @param light The light containing the generator
  9551. * @param effect The effect we are binding the data to
  9552. * @param lightIndex The light index in the effect used to render
  9553. */
  9554. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9555. /**
  9556. * Binds the lights information from the scene to the effect for the given mesh.
  9557. * @param scene The scene the lights belongs to
  9558. * @param mesh The mesh we are binding the information to render
  9559. * @param effect The effect we are binding the data to
  9560. * @param defines The generated defines for the effect
  9561. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9562. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9563. */
  9564. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  9565. /**
  9566. * Binds the fog information from the scene to the effect for the given mesh.
  9567. * @param scene The scene the lights belongs to
  9568. * @param mesh The mesh we are binding the information to render
  9569. * @param effect The effect we are binding the data to
  9570. */
  9571. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect): void;
  9572. /**
  9573. * Binds the bones information from the mesh to the effect.
  9574. * @param mesh The mesh we are binding the information to render
  9575. * @param effect The effect we are binding the data to
  9576. */
  9577. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9578. /**
  9579. * Binds the morph targets information from the mesh to the effect.
  9580. * @param abstractMesh The mesh we are binding the information to render
  9581. * @param effect The effect we are binding the data to
  9582. */
  9583. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9584. /**
  9585. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9586. * @param defines The generated defines used in the effect
  9587. * @param effect The effect we are binding the data to
  9588. * @param scene The scene we are willing to render with logarithmic scale for
  9589. */
  9590. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9591. /**
  9592. * Binds the clip plane information from the scene to the effect.
  9593. * @param scene The scene the clip plane information are extracted from
  9594. * @param effect The effect we are binding the data to
  9595. */
  9596. static BindClipPlane(effect: Effect, scene: Scene): void;
  9597. }
  9598. }
  9599. declare module BABYLON {
  9600. class MultiMaterial extends Material {
  9601. private _subMaterials;
  9602. subMaterials: Nullable<Material>[];
  9603. constructor(name: string, scene: Scene);
  9604. private _hookArray(array);
  9605. getSubMaterial(index: number): Nullable<Material>;
  9606. getActiveTextures(): BaseTexture[];
  9607. getClassName(): string;
  9608. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  9609. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  9610. serialize(): any;
  9611. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  9612. }
  9613. }
  9614. declare module BABYLON {
  9615. class PushMaterial extends Material {
  9616. protected _activeEffect: Effect;
  9617. protected _normalMatrix: Matrix;
  9618. constructor(name: string, scene: Scene);
  9619. getEffect(): Effect;
  9620. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  9621. /**
  9622. * Binds the given world matrix to the active effect
  9623. *
  9624. * @param world the matrix to bind
  9625. */
  9626. bindOnlyWorldMatrix(world: Matrix): void;
  9627. /**
  9628. * Binds the given normal matrix to the active effect
  9629. *
  9630. * @param normalMatrix the matrix to bind
  9631. */
  9632. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  9633. bind(world: Matrix, mesh?: Mesh): void;
  9634. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  9635. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  9636. }
  9637. }
  9638. declare module BABYLON {
  9639. class ShaderMaterial extends Material {
  9640. private _shaderPath;
  9641. private _options;
  9642. private _textures;
  9643. private _textureArrays;
  9644. private _floats;
  9645. private _ints;
  9646. private _floatsArrays;
  9647. private _colors3;
  9648. private _colors3Arrays;
  9649. private _colors4;
  9650. private _vectors2;
  9651. private _vectors3;
  9652. private _vectors4;
  9653. private _matrices;
  9654. private _matrices3x3;
  9655. private _matrices2x2;
  9656. private _vectors2Arrays;
  9657. private _vectors3Arrays;
  9658. private _cachedWorldViewMatrix;
  9659. private _renderId;
  9660. constructor(name: string, scene: Scene, shaderPath: any, options: any);
  9661. getClassName(): string;
  9662. needAlphaBlending(): boolean;
  9663. needAlphaTesting(): boolean;
  9664. private _checkUniform(uniformName);
  9665. setTexture(name: string, texture: Texture): ShaderMaterial;
  9666. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  9667. setFloat(name: string, value: number): ShaderMaterial;
  9668. setInt(name: string, value: number): ShaderMaterial;
  9669. setFloats(name: string, value: number[]): ShaderMaterial;
  9670. setColor3(name: string, value: Color3): ShaderMaterial;
  9671. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  9672. setColor4(name: string, value: Color4): ShaderMaterial;
  9673. setVector2(name: string, value: Vector2): ShaderMaterial;
  9674. setVector3(name: string, value: Vector3): ShaderMaterial;
  9675. setVector4(name: string, value: Vector4): ShaderMaterial;
  9676. setMatrix(name: string, value: Matrix): ShaderMaterial;
  9677. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  9678. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  9679. setArray2(name: string, value: number[]): ShaderMaterial;
  9680. setArray3(name: string, value: number[]): ShaderMaterial;
  9681. private _checkCache(scene, mesh?, useInstances?);
  9682. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  9683. bindOnlyWorldMatrix(world: Matrix): void;
  9684. bind(world: Matrix, mesh?: Mesh): void;
  9685. getActiveTextures(): BaseTexture[];
  9686. hasTexture(texture: BaseTexture): boolean;
  9687. clone(name: string): ShaderMaterial;
  9688. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  9689. serialize(): any;
  9690. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  9691. }
  9692. }
  9693. declare module BABYLON {
  9694. /** @ignore */
  9695. class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  9696. MAINUV1: boolean;
  9697. MAINUV2: boolean;
  9698. DIFFUSE: boolean;
  9699. DIFFUSEDIRECTUV: number;
  9700. AMBIENT: boolean;
  9701. AMBIENTDIRECTUV: number;
  9702. OPACITY: boolean;
  9703. OPACITYDIRECTUV: number;
  9704. OPACITYRGB: boolean;
  9705. REFLECTION: boolean;
  9706. EMISSIVE: boolean;
  9707. EMISSIVEDIRECTUV: number;
  9708. SPECULAR: boolean;
  9709. SPECULARDIRECTUV: number;
  9710. BUMP: boolean;
  9711. BUMPDIRECTUV: number;
  9712. PARALLAX: boolean;
  9713. PARALLAXOCCLUSION: boolean;
  9714. SPECULAROVERALPHA: boolean;
  9715. CLIPPLANE: boolean;
  9716. ALPHATEST: boolean;
  9717. DEPTHPREPASS: boolean;
  9718. ALPHAFROMDIFFUSE: boolean;
  9719. POINTSIZE: boolean;
  9720. FOG: boolean;
  9721. SPECULARTERM: boolean;
  9722. DIFFUSEFRESNEL: boolean;
  9723. OPACITYFRESNEL: boolean;
  9724. REFLECTIONFRESNEL: boolean;
  9725. REFRACTIONFRESNEL: boolean;
  9726. EMISSIVEFRESNEL: boolean;
  9727. FRESNEL: boolean;
  9728. NORMAL: boolean;
  9729. UV1: boolean;
  9730. UV2: boolean;
  9731. VERTEXCOLOR: boolean;
  9732. VERTEXALPHA: boolean;
  9733. NUM_BONE_INFLUENCERS: number;
  9734. BonesPerMesh: number;
  9735. INSTANCES: boolean;
  9736. GLOSSINESS: boolean;
  9737. ROUGHNESS: boolean;
  9738. EMISSIVEASILLUMINATION: boolean;
  9739. LINKEMISSIVEWITHDIFFUSE: boolean;
  9740. REFLECTIONFRESNELFROMSPECULAR: boolean;
  9741. LIGHTMAP: boolean;
  9742. LIGHTMAPDIRECTUV: number;
  9743. OBJECTSPACE_NORMALMAP: boolean;
  9744. USELIGHTMAPASSHADOWMAP: boolean;
  9745. REFLECTIONMAP_3D: boolean;
  9746. REFLECTIONMAP_SPHERICAL: boolean;
  9747. REFLECTIONMAP_PLANAR: boolean;
  9748. REFLECTIONMAP_CUBIC: boolean;
  9749. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  9750. REFLECTIONMAP_PROJECTION: boolean;
  9751. REFLECTIONMAP_SKYBOX: boolean;
  9752. REFLECTIONMAP_EXPLICIT: boolean;
  9753. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  9754. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  9755. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  9756. INVERTCUBICMAP: boolean;
  9757. LOGARITHMICDEPTH: boolean;
  9758. REFRACTION: boolean;
  9759. REFRACTIONMAP_3D: boolean;
  9760. REFLECTIONOVERALPHA: boolean;
  9761. TWOSIDEDLIGHTING: boolean;
  9762. SHADOWFLOAT: boolean;
  9763. MORPHTARGETS: boolean;
  9764. MORPHTARGETS_NORMAL: boolean;
  9765. MORPHTARGETS_TANGENT: boolean;
  9766. NUM_MORPH_INFLUENCERS: number;
  9767. NONUNIFORMSCALING: boolean;
  9768. PREMULTIPLYALPHA: boolean;
  9769. IMAGEPROCESSING: boolean;
  9770. VIGNETTE: boolean;
  9771. VIGNETTEBLENDMODEMULTIPLY: boolean;
  9772. VIGNETTEBLENDMODEOPAQUE: boolean;
  9773. TONEMAPPING: boolean;
  9774. CONTRAST: boolean;
  9775. COLORCURVES: boolean;
  9776. COLORGRADING: boolean;
  9777. COLORGRADING3D: boolean;
  9778. SAMPLER3DGREENDEPTH: boolean;
  9779. SAMPLER3DBGRMAP: boolean;
  9780. IMAGEPROCESSINGPOSTPROCESS: boolean;
  9781. EXPOSURE: boolean;
  9782. constructor();
  9783. setReflectionMode(modeToEnable: string): void;
  9784. }
  9785. class StandardMaterial extends PushMaterial {
  9786. private _diffuseTexture;
  9787. diffuseTexture: Nullable<BaseTexture>;
  9788. private _ambientTexture;
  9789. ambientTexture: Nullable<BaseTexture>;
  9790. private _opacityTexture;
  9791. opacityTexture: Nullable<BaseTexture>;
  9792. private _reflectionTexture;
  9793. reflectionTexture: Nullable<BaseTexture>;
  9794. private _emissiveTexture;
  9795. emissiveTexture: Nullable<BaseTexture>;
  9796. private _specularTexture;
  9797. specularTexture: Nullable<BaseTexture>;
  9798. private _bumpTexture;
  9799. bumpTexture: Nullable<BaseTexture>;
  9800. private _lightmapTexture;
  9801. lightmapTexture: Nullable<BaseTexture>;
  9802. private _refractionTexture;
  9803. refractionTexture: Nullable<BaseTexture>;
  9804. ambientColor: Color3;
  9805. diffuseColor: Color3;
  9806. specularColor: Color3;
  9807. emissiveColor: Color3;
  9808. specularPower: number;
  9809. private _useAlphaFromDiffuseTexture;
  9810. useAlphaFromDiffuseTexture: boolean;
  9811. private _useEmissiveAsIllumination;
  9812. useEmissiveAsIllumination: boolean;
  9813. private _linkEmissiveWithDiffuse;
  9814. linkEmissiveWithDiffuse: boolean;
  9815. private _useSpecularOverAlpha;
  9816. useSpecularOverAlpha: boolean;
  9817. private _useReflectionOverAlpha;
  9818. useReflectionOverAlpha: boolean;
  9819. private _disableLighting;
  9820. disableLighting: boolean;
  9821. private _useObjectSpaceNormalMap;
  9822. /**
  9823. * Allows using an object space normal map (instead of tangent space).
  9824. */
  9825. useObjectSpaceNormalMap: boolean;
  9826. private _useParallax;
  9827. useParallax: boolean;
  9828. private _useParallaxOcclusion;
  9829. useParallaxOcclusion: boolean;
  9830. parallaxScaleBias: number;
  9831. private _roughness;
  9832. roughness: number;
  9833. indexOfRefraction: number;
  9834. invertRefractionY: boolean;
  9835. private _useLightmapAsShadowmap;
  9836. useLightmapAsShadowmap: boolean;
  9837. private _diffuseFresnelParameters;
  9838. diffuseFresnelParameters: FresnelParameters;
  9839. private _opacityFresnelParameters;
  9840. opacityFresnelParameters: FresnelParameters;
  9841. private _reflectionFresnelParameters;
  9842. reflectionFresnelParameters: FresnelParameters;
  9843. private _refractionFresnelParameters;
  9844. refractionFresnelParameters: FresnelParameters;
  9845. private _emissiveFresnelParameters;
  9846. emissiveFresnelParameters: FresnelParameters;
  9847. private _useReflectionFresnelFromSpecular;
  9848. useReflectionFresnelFromSpecular: boolean;
  9849. private _useGlossinessFromSpecularMapAlpha;
  9850. useGlossinessFromSpecularMapAlpha: boolean;
  9851. private _maxSimultaneousLights;
  9852. maxSimultaneousLights: number;
  9853. /**
  9854. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  9855. */
  9856. private _invertNormalMapX;
  9857. invertNormalMapX: boolean;
  9858. /**
  9859. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  9860. */
  9861. private _invertNormalMapY;
  9862. invertNormalMapY: boolean;
  9863. /**
  9864. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  9865. */
  9866. private _twoSidedLighting;
  9867. twoSidedLighting: boolean;
  9868. /**
  9869. * Default configuration related to image processing available in the standard Material.
  9870. */
  9871. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  9872. /**
  9873. * Gets the image processing configuration used either in this material.
  9874. */
  9875. /**
  9876. * Sets the Default image processing configuration used either in the this material.
  9877. *
  9878. * If sets to null, the scene one is in use.
  9879. */
  9880. imageProcessingConfiguration: ImageProcessingConfiguration;
  9881. /**
  9882. * Keep track of the image processing observer to allow dispose and replace.
  9883. */
  9884. private _imageProcessingObserver;
  9885. /**
  9886. * Attaches a new image processing configuration to the Standard Material.
  9887. * @param configuration
  9888. */
  9889. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  9890. /**
  9891. * Gets wether the color curves effect is enabled.
  9892. */
  9893. /**
  9894. * Sets wether the color curves effect is enabled.
  9895. */
  9896. cameraColorCurvesEnabled: boolean;
  9897. /**
  9898. * Gets wether the color grading effect is enabled.
  9899. */
  9900. /**
  9901. * Gets wether the color grading effect is enabled.
  9902. */
  9903. cameraColorGradingEnabled: boolean;
  9904. /**
  9905. * Gets wether tonemapping is enabled or not.
  9906. */
  9907. /**
  9908. * Sets wether tonemapping is enabled or not
  9909. */
  9910. cameraToneMappingEnabled: boolean;
  9911. /**
  9912. * The camera exposure used on this material.
  9913. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  9914. * This corresponds to a photographic exposure.
  9915. */
  9916. /**
  9917. * The camera exposure used on this material.
  9918. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  9919. * This corresponds to a photographic exposure.
  9920. */
  9921. cameraExposure: number;
  9922. /**
  9923. * Gets The camera contrast used on this material.
  9924. */
  9925. /**
  9926. * Sets The camera contrast used on this material.
  9927. */
  9928. cameraContrast: number;
  9929. /**
  9930. * Gets the Color Grading 2D Lookup Texture.
  9931. */
  9932. /**
  9933. * Sets the Color Grading 2D Lookup Texture.
  9934. */
  9935. cameraColorGradingTexture: Nullable<BaseTexture>;
  9936. /**
  9937. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  9938. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  9939. * 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;
  9940. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  9941. */
  9942. /**
  9943. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  9944. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  9945. * 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;
  9946. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  9947. */
  9948. cameraColorCurves: Nullable<ColorCurves>;
  9949. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  9950. protected _renderTargets: SmartArray<RenderTargetTexture>;
  9951. protected _worldViewProjectionMatrix: Matrix;
  9952. protected _globalAmbientColor: Color3;
  9953. protected _useLogarithmicDepth: boolean;
  9954. constructor(name: string, scene: Scene);
  9955. getClassName(): string;
  9956. useLogarithmicDepth: boolean;
  9957. needAlphaBlending(): boolean;
  9958. needAlphaTesting(): boolean;
  9959. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  9960. getAlphaTestTexture(): Nullable<BaseTexture>;
  9961. /**
  9962. * Child classes can use it to update shaders
  9963. */
  9964. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  9965. buildUniformLayout(): void;
  9966. unbind(): void;
  9967. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  9968. getAnimatables(): IAnimatable[];
  9969. getActiveTextures(): BaseTexture[];
  9970. hasTexture(texture: BaseTexture): boolean;
  9971. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  9972. clone(name: string): StandardMaterial;
  9973. serialize(): any;
  9974. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  9975. static _DiffuseTextureEnabled: boolean;
  9976. static DiffuseTextureEnabled: boolean;
  9977. static _AmbientTextureEnabled: boolean;
  9978. static AmbientTextureEnabled: boolean;
  9979. static _OpacityTextureEnabled: boolean;
  9980. static OpacityTextureEnabled: boolean;
  9981. static _ReflectionTextureEnabled: boolean;
  9982. static ReflectionTextureEnabled: boolean;
  9983. static _EmissiveTextureEnabled: boolean;
  9984. static EmissiveTextureEnabled: boolean;
  9985. static _SpecularTextureEnabled: boolean;
  9986. static SpecularTextureEnabled: boolean;
  9987. static _BumpTextureEnabled: boolean;
  9988. static BumpTextureEnabled: boolean;
  9989. static _LightmapTextureEnabled: boolean;
  9990. static LightmapTextureEnabled: boolean;
  9991. static _RefractionTextureEnabled: boolean;
  9992. static RefractionTextureEnabled: boolean;
  9993. static _ColorGradingTextureEnabled: boolean;
  9994. static ColorGradingTextureEnabled: boolean;
  9995. static _FresnelEnabled: boolean;
  9996. static FresnelEnabled: boolean;
  9997. }
  9998. }
  9999. declare module BABYLON {
  10000. class UniformBuffer {
  10001. private _engine;
  10002. private _buffer;
  10003. private _data;
  10004. private _bufferData;
  10005. private _dynamic?;
  10006. private _uniformLocations;
  10007. private _uniformSizes;
  10008. private _uniformLocationPointer;
  10009. private _needSync;
  10010. private _noUBO;
  10011. private _currentEffect;
  10012. private static _MAX_UNIFORM_SIZE;
  10013. private static _tempBuffer;
  10014. /**
  10015. * Wrapper for updateUniform.
  10016. * @method updateMatrix3x3
  10017. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  10018. * @param {Float32Array} matrix
  10019. */
  10020. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  10021. /**
  10022. * Wrapper for updateUniform.
  10023. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  10024. * @param {Float32Array} matrix
  10025. */
  10026. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  10027. /**
  10028. * Wrapper for updateUniform.
  10029. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  10030. * @param {number} x
  10031. */
  10032. updateFloat: (name: string, x: number) => void;
  10033. /**
  10034. * Wrapper for updateUniform.
  10035. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  10036. * @param {number} x
  10037. * @param {number} y
  10038. * @param {string} [suffix] Suffix to add to the uniform name.
  10039. */
  10040. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  10041. /**
  10042. * Wrapper for updateUniform.
  10043. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  10044. * @param {number} x
  10045. * @param {number} y
  10046. * @param {number} z
  10047. * @param {string} [suffix] Suffix to add to the uniform name.
  10048. */
  10049. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  10050. /**
  10051. * Wrapper for updateUniform.
  10052. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  10053. * @param {number} x
  10054. * @param {number} y
  10055. * @param {number} z
  10056. * @param {number} w
  10057. * @param {string} [suffix] Suffix to add to the uniform name.
  10058. */
  10059. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  10060. /**
  10061. * Wrapper for updateUniform.
  10062. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  10063. * @param {Matrix} A 4x4 matrix.
  10064. */
  10065. updateMatrix: (name: string, mat: Matrix) => void;
  10066. /**
  10067. * Wrapper for updateUniform.
  10068. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  10069. * @param {Vector3} vector
  10070. */
  10071. updateVector3: (name: string, vector: Vector3) => void;
  10072. /**
  10073. * Wrapper for updateUniform.
  10074. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  10075. * @param {Vector4} vector
  10076. */
  10077. updateVector4: (name: string, vector: Vector4) => void;
  10078. /**
  10079. * Wrapper for updateUniform.
  10080. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  10081. * @param {Color3} color
  10082. * @param {string} [suffix] Suffix to add to the uniform name.
  10083. */
  10084. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  10085. /**
  10086. * Wrapper for updateUniform.
  10087. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  10088. * @param {Color3} color
  10089. * @param {number} alpha
  10090. * @param {string} [suffix] Suffix to add to the uniform name.
  10091. */
  10092. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  10093. /**
  10094. * Uniform buffer objects.
  10095. *
  10096. * Handles blocks of uniform on the GPU.
  10097. *
  10098. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  10099. *
  10100. * For more information, please refer to :
  10101. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  10102. */
  10103. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  10104. /**
  10105. * Indicates if the buffer is using the WebGL2 UBO implementation,
  10106. * or just falling back on setUniformXXX calls.
  10107. */
  10108. readonly useUbo: boolean;
  10109. /**
  10110. * Indicates if the WebGL underlying uniform buffer is in sync
  10111. * with the javascript cache data.
  10112. */
  10113. readonly isSync: boolean;
  10114. /**
  10115. * Indicates if the WebGL underlying uniform buffer is dynamic.
  10116. * Also, a dynamic UniformBuffer will disable cache verification and always
  10117. * update the underlying WebGL uniform buffer to the GPU.
  10118. */
  10119. isDynamic(): boolean;
  10120. /**
  10121. * The data cache on JS side.
  10122. */
  10123. getData(): Float32Array;
  10124. /**
  10125. * The underlying WebGL Uniform buffer.
  10126. */
  10127. getBuffer(): Nullable<WebGLBuffer>;
  10128. /**
  10129. * std140 layout specifies how to align data within an UBO structure.
  10130. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  10131. * for specs.
  10132. */
  10133. private _fillAlignment(size);
  10134. /**
  10135. * Adds an uniform in the buffer.
  10136. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  10137. * for the layout to be correct !
  10138. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  10139. * @param {number|number[]} size Data size, or data directly.
  10140. */
  10141. addUniform(name: string, size: number | number[]): void;
  10142. /**
  10143. * Wrapper for addUniform.
  10144. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  10145. * @param {Matrix} mat A 4x4 matrix.
  10146. */
  10147. addMatrix(name: string, mat: Matrix): void;
  10148. /**
  10149. * Wrapper for addUniform.
  10150. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  10151. * @param {number} x
  10152. * @param {number} y
  10153. */
  10154. addFloat2(name: string, x: number, y: number): void;
  10155. /**
  10156. * Wrapper for addUniform.
  10157. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  10158. * @param {number} x
  10159. * @param {number} y
  10160. * @param {number} z
  10161. */
  10162. addFloat3(name: string, x: number, y: number, z: number): void;
  10163. /**
  10164. * Wrapper for addUniform.
  10165. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  10166. * @param {Color3} color
  10167. */
  10168. addColor3(name: string, color: Color3): void;
  10169. /**
  10170. * Wrapper for addUniform.
  10171. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  10172. * @param {Color3} color
  10173. * @param {number} alpha
  10174. */
  10175. addColor4(name: string, color: Color3, alpha: number): void;
  10176. /**
  10177. * Wrapper for addUniform.
  10178. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  10179. * @param {Vector3} vector
  10180. */
  10181. addVector3(name: string, vector: Vector3): void;
  10182. /**
  10183. * Wrapper for addUniform.
  10184. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  10185. */
  10186. addMatrix3x3(name: string): void;
  10187. /**
  10188. * Wrapper for addUniform.
  10189. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  10190. */
  10191. addMatrix2x2(name: string): void;
  10192. /**
  10193. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  10194. */
  10195. create(): void;
  10196. _rebuild(): void;
  10197. /**
  10198. * Updates the WebGL Uniform Buffer on the GPU.
  10199. * If the `dynamic` flag is set to true, no cache comparison is done.
  10200. * Otherwise, the buffer will be updated only if the cache differs.
  10201. */
  10202. update(): void;
  10203. /**
  10204. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  10205. * @param {string} uniformName Name of the uniform, as used in the uniform block in the shader.
  10206. * @param {number[]|Float32Array} data Flattened data
  10207. * @param {number} size Size of the data.
  10208. */
  10209. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  10210. private _updateMatrix3x3ForUniform(name, matrix);
  10211. private _updateMatrix3x3ForEffect(name, matrix);
  10212. private _updateMatrix2x2ForEffect(name, matrix);
  10213. private _updateMatrix2x2ForUniform(name, matrix);
  10214. private _updateFloatForEffect(name, x);
  10215. private _updateFloatForUniform(name, x);
  10216. private _updateFloat2ForEffect(name, x, y, suffix?);
  10217. private _updateFloat2ForUniform(name, x, y, suffix?);
  10218. private _updateFloat3ForEffect(name, x, y, z, suffix?);
  10219. private _updateFloat3ForUniform(name, x, y, z, suffix?);
  10220. private _updateFloat4ForEffect(name, x, y, z, w, suffix?);
  10221. private _updateFloat4ForUniform(name, x, y, z, w, suffix?);
  10222. private _updateMatrixForEffect(name, mat);
  10223. private _updateMatrixForUniform(name, mat);
  10224. private _updateVector3ForEffect(name, vector);
  10225. private _updateVector3ForUniform(name, vector);
  10226. private _updateVector4ForEffect(name, vector);
  10227. private _updateVector4ForUniform(name, vector);
  10228. private _updateColor3ForEffect(name, color, suffix?);
  10229. private _updateColor3ForUniform(name, color, suffix?);
  10230. private _updateColor4ForEffect(name, color, alpha, suffix?);
  10231. private _updateColor4ForUniform(name, color, alpha, suffix?);
  10232. /**
  10233. * Sets a sampler uniform on the effect.
  10234. * @param {string} name Name of the sampler.
  10235. * @param {Texture} texture
  10236. */
  10237. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  10238. /**
  10239. * Directly updates the value of the uniform in the cache AND on the GPU.
  10240. * @param {string} uniformName Name of the uniform, as used in the uniform block in the shader.
  10241. * @param {number[]|Float32Array} data Flattened data
  10242. */
  10243. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  10244. /**
  10245. * Binds this uniform buffer to an effect.
  10246. * @param {Effect} effect
  10247. * @param {string} name Name of the uniform block in the shader.
  10248. */
  10249. bindToEffect(effect: Effect, name: string): void;
  10250. /**
  10251. * Disposes the uniform buffer.
  10252. */
  10253. dispose(): void;
  10254. }
  10255. }
  10256. declare module BABYLON {
  10257. class Scalar {
  10258. /**
  10259. * Two pi constants convenient for computation.
  10260. */
  10261. static TwoPi: number;
  10262. /**
  10263. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  10264. */
  10265. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  10266. /**
  10267. * Returns a string : the upper case translation of the number i to hexadecimal.
  10268. */
  10269. static ToHex(i: number): string;
  10270. /**
  10271. * Returns -1 if value is negative and +1 is value is positive.
  10272. * Returns the value itself if it's equal to zero.
  10273. */
  10274. static Sign(value: number): number;
  10275. /**
  10276. * Returns the value itself if it's between min and max.
  10277. * Returns min if the value is lower than min.
  10278. * Returns max if the value is greater than max.
  10279. */
  10280. static Clamp(value: number, min?: number, max?: number): number;
  10281. /**
  10282. * Returns the log2 of value.
  10283. */
  10284. static Log2(value: number): number;
  10285. /**
  10286. * Loops the value, so that it is never larger than length and never smaller than 0.
  10287. *
  10288. * This is similar to the modulo operator but it works with floating point numbers.
  10289. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  10290. * With t = 5 and length = 2.5, the result would be 0.0.
  10291. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  10292. */
  10293. static Repeat(value: number, length: number): number;
  10294. /**
  10295. * Normalize the value between 0.0 and 1.0 using min and max values
  10296. */
  10297. static Normalize(value: number, min: number, max: number): number;
  10298. /**
  10299. * Denormalize the value from 0.0 and 1.0 using min and max values
  10300. */
  10301. static Denormalize(normalized: number, min: number, max: number): number;
  10302. /**
  10303. * Calculates the shortest difference between two given angles given in degrees.
  10304. */
  10305. static DeltaAngle(current: number, target: number): number;
  10306. /**
  10307. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  10308. *
  10309. * The returned value will move back and forth between 0 and length
  10310. */
  10311. static PingPong(tx: number, length: number): number;
  10312. /**
  10313. * Interpolates between min and max with smoothing at the limits.
  10314. *
  10315. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  10316. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  10317. */
  10318. static SmoothStep(from: number, to: number, tx: number): number;
  10319. /**
  10320. * Moves a value current towards target.
  10321. *
  10322. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  10323. * Negative values of maxDelta pushes the value away from target.
  10324. */
  10325. static MoveTowards(current: number, target: number, maxDelta: number): number;
  10326. /**
  10327. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  10328. *
  10329. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  10330. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  10331. */
  10332. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  10333. /**
  10334. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  10335. */
  10336. static Lerp(start: number, end: number, amount: number): number;
  10337. /**
  10338. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  10339. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  10340. */
  10341. static LerpAngle(start: number, end: number, amount: number): number;
  10342. /**
  10343. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  10344. */
  10345. static InverseLerp(a: number, b: number, value: number): number;
  10346. /**
  10347. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  10348. */
  10349. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  10350. /**
  10351. * Returns a random float number between and min and max values
  10352. */
  10353. static RandomRange(min: number, max: number): number;
  10354. /**
  10355. * This function returns percentage of a number in a given range.
  10356. *
  10357. * RangeToPercent(40,20,60) will return 0.5 (50%)
  10358. * RangeToPercent(34,0,100) will return 0.34 (34%)
  10359. */
  10360. static RangeToPercent(number: number, min: number, max: number): number;
  10361. /**
  10362. * This function returns number that corresponds to the percentage in a given range.
  10363. *
  10364. * PercentToRange(0.34,0,100) will return 34.
  10365. */
  10366. static PercentToRange(percent: number, min: number, max: number): number;
  10367. /**
  10368. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  10369. * @param angle The angle to normalize in radian.
  10370. * @return The converted angle.
  10371. */
  10372. static NormalizeRadians(angle: number): number;
  10373. }
  10374. }
  10375. declare module BABYLON {
  10376. const ToGammaSpace: number;
  10377. const ToLinearSpace = 2.2;
  10378. const Epsilon = 0.001;
  10379. /**
  10380. * Class used to hold a RBG color
  10381. */
  10382. class Color3 {
  10383. /**
  10384. * Defines the red component (between 0 and 1, default is 0)
  10385. */
  10386. r: number;
  10387. /**
  10388. * Defines the green component (between 0 and 1, default is 0)
  10389. */
  10390. g: number;
  10391. /**
  10392. * Defines the blue component (between 0 and 1, default is 0)
  10393. */
  10394. b: number;
  10395. /**
  10396. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  10397. * @param r defines the red component (between 0 and 1, default is 0)
  10398. * @param g defines the green component (between 0 and 1, default is 0)
  10399. * @param b defines the blue component (between 0 and 1, default is 0)
  10400. */
  10401. constructor(
  10402. /**
  10403. * Defines the red component (between 0 and 1, default is 0)
  10404. */
  10405. r?: number,
  10406. /**
  10407. * Defines the green component (between 0 and 1, default is 0)
  10408. */
  10409. g?: number,
  10410. /**
  10411. * Defines the blue component (between 0 and 1, default is 0)
  10412. */
  10413. b?: number);
  10414. /**
  10415. * Creates a string with the Color3 current values
  10416. * @returns the string representation of the Color3 object
  10417. */
  10418. toString(): string;
  10419. /**
  10420. * Returns the string "Color3"
  10421. * @returns "Color3"
  10422. */
  10423. getClassName(): string;
  10424. /**
  10425. * Compute the Color3 hash code
  10426. * @returns an unique number that can be used to hash Color3 objects
  10427. */
  10428. getHashCode(): number;
  10429. /**
  10430. * Stores in the passed array from the passed starting index the red, green, blue values as successive elements
  10431. * @param array defines the array where to store the r,g,b components
  10432. * @param index defines an optional index in the target array to define where to start storing values
  10433. * @returns the current Color3 object
  10434. */
  10435. toArray(array: FloatArray, index?: number): Color3;
  10436. /**
  10437. * Returns a new {BABYLON.Color4} object from the current Color3 and the passed alpha
  10438. * @param alpha defines the alpha component on the new {BABYLON.Color4} object (default is 1)
  10439. * @returns a new {BABYLON.Color4} object
  10440. */
  10441. toColor4(alpha?: number): Color4;
  10442. /**
  10443. * Returns a new array populated with 3 numeric elements : red, green and blue values
  10444. * @returns the new array
  10445. */
  10446. asArray(): number[];
  10447. /**
  10448. * Returns the luminance value
  10449. * @returns a float value
  10450. */
  10451. toLuminance(): number;
  10452. /**
  10453. * Multiply each Color3 rgb values by the passed Color3 rgb values in a new Color3 object
  10454. * @param otherColor defines the second operand
  10455. * @returns the new Color3 object
  10456. */
  10457. multiply(otherColor: Color3): Color3;
  10458. /**
  10459. * Multiply the rgb values of the Color3 and the passed Color3 and stores the result in the object "result"
  10460. * @param otherColor defines the second operand
  10461. * @param result defines the Color3 object where to store the result
  10462. * @returns the current Color3
  10463. */
  10464. multiplyToRef(otherColor: Color3, result: Color3): Color3;
  10465. /**
  10466. * Determines equality between Color3 objects
  10467. * @param otherColor defines the second operand
  10468. * @returns true if the rgb values are equal to the passed ones
  10469. */
  10470. equals(otherColor: Color3): boolean;
  10471. /**
  10472. * Determines equality between the current Color3 object and a set of r,b,g values
  10473. * @param r defines the red component to check
  10474. * @param g defines the green component to check
  10475. * @param b defines the blue component to check
  10476. * @returns true if the rgb values are equal to the passed ones
  10477. */
  10478. equalsFloats(r: number, g: number, b: number): boolean;
  10479. /**
  10480. * Multiplies in place each rgb value by scale
  10481. * @param scale defines the scaling factor
  10482. * @returns the updated Color3.
  10483. */
  10484. scale(scale: number): Color3;
  10485. /**
  10486. * Multiplies the rgb values by scale and stores the result into "result"
  10487. * @param scale defines the scaling factor
  10488. * @param result defines the Color3 object where to store the result
  10489. * @returns the unmodified current Color3.
  10490. */
  10491. scaleToRef(scale: number, result: Color3): Color3;
  10492. /**
  10493. * Clamps the rgb values by the min and max values and stores the result into "result"
  10494. * @param min defines minimum clamping value (default is 0)
  10495. * @param max defines maximum clamping value (default is 1)
  10496. * @param result defines color to store the result into
  10497. * @returns the original Color3
  10498. */
  10499. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  10500. /**
  10501. * Creates a new Color3 set with the added values of the current Color3 and of the passed one
  10502. * @param otherColor defines the second operand
  10503. * @returns the new Color3
  10504. */
  10505. add(otherColor: Color3): Color3;
  10506. /**
  10507. * Stores the result of the addition of the current Color3 and passed one rgb values into "result"
  10508. * @param otherColor defines the second operand
  10509. * @param result defines Color3 object to store the result into
  10510. * @returns the unmodified current Color3
  10511. */
  10512. addToRef(otherColor: Color3, result: Color3): Color3;
  10513. /**
  10514. * Returns a new Color3 set with the subtracted values of the passed one from the current Color3
  10515. * @param otherColor defines the second operand
  10516. * @returns the new Color3
  10517. */
  10518. subtract(otherColor: Color3): Color3;
  10519. /**
  10520. * Stores the result of the subtraction of passed one from the current Color3 rgb values into "result"
  10521. * @param otherColor defines the second operand
  10522. * @param result defines Color3 object to store the result into
  10523. * @returns the unmodified current Color3
  10524. */
  10525. subtractToRef(otherColor: Color3, result: Color3): Color3;
  10526. /**
  10527. * Copy the current object
  10528. * @returns a new Color3 copied the current one
  10529. */
  10530. clone(): Color3;
  10531. /**
  10532. * Copies the rgb values from the source in the current Color3
  10533. * @param source defines the source Color3 object
  10534. * @returns the updated Color3 object
  10535. */
  10536. copyFrom(source: Color3): Color3;
  10537. /**
  10538. * Updates the Color3 rgb values from the passed floats
  10539. * @param r defines the red component to read from
  10540. * @param g defines the green component to read from
  10541. * @param b defines the blue component to read from
  10542. * @returns the current Color3 object
  10543. */
  10544. copyFromFloats(r: number, g: number, b: number): Color3;
  10545. /**
  10546. * Updates the Color3 rgb values from the passed floats
  10547. * @param r defines the red component to read from
  10548. * @param g defines the green component to read from
  10549. * @param b defines the blue component to read from
  10550. * @returns the current Color3 object
  10551. */
  10552. set(r: number, g: number, b: number): Color3;
  10553. /**
  10554. * Compute the Color3 hexadecimal code as a string
  10555. * @returns a string containing the hexadecimal representation of the Color3 object
  10556. */
  10557. toHexString(): string;
  10558. /**
  10559. * Computes a new Color3 converted from the current one to linear space
  10560. * @returns a new Color3 object
  10561. */
  10562. toLinearSpace(): Color3;
  10563. /**
  10564. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  10565. * @param convertedColor defines the Color3 object where to store the linear space version
  10566. * @returns the unmodified Color3
  10567. */
  10568. toLinearSpaceToRef(convertedColor: Color3): Color3;
  10569. /**
  10570. * Computes a new Color3 converted from the current one to gamma space
  10571. * @returns a new Color3 object
  10572. */
  10573. toGammaSpace(): Color3;
  10574. /**
  10575. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  10576. * @param convertedColor defines the Color3 object where to store the gamma space version
  10577. * @returns the unmodified Color3
  10578. */
  10579. toGammaSpaceToRef(convertedColor: Color3): Color3;
  10580. /**
  10581. * Creates a new Color3 from the string containing valid hexadecimal values
  10582. * @param hex defines a string containing valid hexadecimal values
  10583. * @returns a new Color3 object
  10584. */
  10585. static FromHexString(hex: string): Color3;
  10586. /**
  10587. * Creates a new Vector3 from the starting index of the passed array
  10588. * @param array defines the source array
  10589. * @param offset defines an offset in the source array
  10590. * @returns a new Color3 object
  10591. */
  10592. static FromArray(array: ArrayLike<number>, offset?: number): Color3;
  10593. /**
  10594. * Creates a new Color3 from integer values (< 256)
  10595. * @param r defines the red component to read from (value between 0 and 255)
  10596. * @param g defines the green component to read from (value between 0 and 255)
  10597. * @param b defines the blue component to read from (value between 0 and 255)
  10598. * @returns a new Color3 object
  10599. */
  10600. static FromInts(r: number, g: number, b: number): Color3;
  10601. /**
  10602. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  10603. * @param start defines the start Color3 value
  10604. * @param end defines the end Color3 value
  10605. * @param amount defines the gradient value between start and end
  10606. * @returns a new Color3 object
  10607. */
  10608. static Lerp(start: Color3, end: Color3, amount: number): Color3;
  10609. /**
  10610. * Returns a Color3 value containing a red color
  10611. * @returns a new Color3 object
  10612. */
  10613. static Red(): Color3;
  10614. /**
  10615. * Returns a Color3 value containing a green color
  10616. * @returns a new Color3 object
  10617. */
  10618. static Green(): Color3;
  10619. /**
  10620. * Returns a Color3 value containing a blue color
  10621. * @returns a new Color3 object
  10622. */
  10623. static Blue(): Color3;
  10624. /**
  10625. * Returns a Color3 value containing a black color
  10626. * @returns a new Color3 object
  10627. */
  10628. static Black(): Color3;
  10629. /**
  10630. * Returns a Color3 value containing a white color
  10631. * @returns a new Color3 object
  10632. */
  10633. static White(): Color3;
  10634. /**
  10635. * Returns a Color3 value containing a purple color
  10636. * @returns a new Color3 object
  10637. */
  10638. static Purple(): Color3;
  10639. /**
  10640. * Returns a Color3 value containing a magenta color
  10641. * @returns a new Color3 object
  10642. */
  10643. static Magenta(): Color3;
  10644. /**
  10645. * Returns a Color3 value containing a yellow color
  10646. * @returns a new Color3 object
  10647. */
  10648. static Yellow(): Color3;
  10649. /**
  10650. * Returns a Color3 value containing a gray color
  10651. * @returns a new Color3 object
  10652. */
  10653. static Gray(): Color3;
  10654. /**
  10655. * Returns a Color3 value containing a teal color
  10656. * @returns a new Color3 object
  10657. */
  10658. static Teal(): Color3;
  10659. /**
  10660. * Returns a Color3 value containing a random color
  10661. * @returns a new Color3 object
  10662. */
  10663. static Random(): Color3;
  10664. }
  10665. /**
  10666. * Class used to hold a RBGA color
  10667. */
  10668. class Color4 {
  10669. /**
  10670. * Defines the red component (between 0 and 1, default is 0)
  10671. */
  10672. r: number;
  10673. /**
  10674. * Defines the green component (between 0 and 1, default is 0)
  10675. */
  10676. g: number;
  10677. /**
  10678. * Defines the blue component (between 0 and 1, default is 0)
  10679. */
  10680. b: number;
  10681. /**
  10682. * Defines the alpha component (between 0 and 1, default is 1)
  10683. */
  10684. a: number;
  10685. /**
  10686. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  10687. * @param r defines the red component (between 0 and 1, default is 0)
  10688. * @param g defines the green component (between 0 and 1, default is 0)
  10689. * @param b defines the blue component (between 0 and 1, default is 0)
  10690. * @param a defines the alpha component (between 0 and 1, default is 1)
  10691. */
  10692. constructor(
  10693. /**
  10694. * Defines the red component (between 0 and 1, default is 0)
  10695. */
  10696. r?: number,
  10697. /**
  10698. * Defines the green component (between 0 and 1, default is 0)
  10699. */
  10700. g?: number,
  10701. /**
  10702. * Defines the blue component (between 0 and 1, default is 0)
  10703. */
  10704. b?: number,
  10705. /**
  10706. * Defines the alpha component (between 0 and 1, default is 1)
  10707. */
  10708. a?: number);
  10709. /**
  10710. * Adds in place the passed Color4 values to the current Color4 object
  10711. * @param right defines the second operand
  10712. * @returns the current updated Color4 object
  10713. */
  10714. addInPlace(right: Color4): Color4;
  10715. /**
  10716. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  10717. * @returns the new array
  10718. */
  10719. asArray(): number[];
  10720. /**
  10721. * Stores from the starting index in the passed array the Color4 successive values
  10722. * @param array defines the array where to store the r,g,b components
  10723. * @param index defines an optional index in the target array to define where to start storing values
  10724. * @returns the current Color4 object
  10725. */
  10726. toArray(array: number[], index?: number): Color4;
  10727. /**
  10728. * Creates a new Color4 set with the added values of the current Color4 and of the passed one
  10729. * @param right defines the second operand
  10730. * @returns a new Color4 object
  10731. */
  10732. add(right: Color4): Color4;
  10733. /**
  10734. * Creates a new Color4 set with the subtracted values of the passed one from the current Color4
  10735. * @param right defines the second operand
  10736. * @returns a new Color4 object
  10737. */
  10738. subtract(right: Color4): Color4;
  10739. /**
  10740. * Subtracts the passed ones from the current Color4 values and stores the results in "result"
  10741. * @param right defines the second operand
  10742. * @param result defines the Color4 object where to store the result
  10743. * @returns the current Color4 object
  10744. */
  10745. subtractToRef(right: Color4, result: Color4): Color4;
  10746. /**
  10747. * Creates a new Color4 with the current Color4 values multiplied by scale
  10748. * @param scale defines the scaling factor to apply
  10749. * @returns a new Color4 object
  10750. */
  10751. scale(scale: number): Color4;
  10752. /**
  10753. * Multiplies the current Color4 values by scale and stores the result in "result"
  10754. * @param scale defines the scaling factor to apply
  10755. * @param result defines the Color4 object where to store the result
  10756. * @returns the current Color4.
  10757. */
  10758. scaleToRef(scale: number, result: Color4): Color4;
  10759. /**
  10760. * Clamps the rgb values by the min and max values and stores the result into "result"
  10761. * @param min defines minimum clamping value (default is 0)
  10762. * @param max defines maximum clamping value (default is 1)
  10763. * @param result defines color to store the result into.
  10764. * @returns the cuurent Color4
  10765. */
  10766. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  10767. /**
  10768. * Multipy an Color4 value by another and return a new Color4 object
  10769. * @param color defines the Color4 value to multiply by
  10770. * @returns a new Color4 object
  10771. */
  10772. multiply(color: Color4): Color4;
  10773. /**
  10774. * Multipy a Color4 value by another and push the result in a reference value
  10775. * @param color defines the Color4 value to multiply by
  10776. * @param result defines the Color4 to fill the result in
  10777. * @returns the result Color4
  10778. */
  10779. multiplyToRef(color: Color4, result: Color4): Color4;
  10780. /**
  10781. * Creates a string with the Color4 current values
  10782. * @returns the string representation of the Color4 object
  10783. */
  10784. toString(): string;
  10785. /**
  10786. * Returns the string "Color4"
  10787. * @returns "Color4"
  10788. */
  10789. getClassName(): string;
  10790. /**
  10791. * Compute the Color4 hash code
  10792. * @returns an unique number that can be used to hash Color4 objects
  10793. */
  10794. getHashCode(): number;
  10795. /**
  10796. * Creates a new Color4 copied from the current one
  10797. * @returns a new Color4 object
  10798. */
  10799. clone(): Color4;
  10800. /**
  10801. * Copies the passed Color4 values into the current one
  10802. * @param source defines the source Color4 object
  10803. * @returns the current updated Color4 object
  10804. */
  10805. copyFrom(source: Color4): Color4;
  10806. /**
  10807. * Copies the passed float values into the current one
  10808. * @param r defines the red component to read from
  10809. * @param g defines the green component to read from
  10810. * @param b defines the blue component to read from
  10811. * @param a defines the alpha component to read from
  10812. * @returns the current updated Color4 object
  10813. */
  10814. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  10815. /**
  10816. * Copies the passed float values into the current one
  10817. * @param r defines the red component to read from
  10818. * @param g defines the green component to read from
  10819. * @param b defines the blue component to read from
  10820. * @param a defines the alpha component to read from
  10821. * @returns the current updated Color4 object
  10822. */
  10823. set(r: number, g: number, b: number, a: number): Color4;
  10824. /**
  10825. * Compute the Color4 hexadecimal code as a string
  10826. * @returns a string containing the hexadecimal representation of the Color4 object
  10827. */
  10828. toHexString(): string;
  10829. /**
  10830. * Computes a new Color4 converted from the current one to linear space
  10831. * @returns a new Color4 object
  10832. */
  10833. toLinearSpace(): Color4;
  10834. /**
  10835. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  10836. * @param convertedColor defines the Color4 object where to store the linear space version
  10837. * @returns the unmodified Color4
  10838. */
  10839. toLinearSpaceToRef(convertedColor: Color4): Color4;
  10840. /**
  10841. * Computes a new Color4 converted from the current one to gamma space
  10842. * @returns a new Color4 object
  10843. */
  10844. toGammaSpace(): Color4;
  10845. /**
  10846. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  10847. * @param convertedColor defines the Color4 object where to store the gamma space version
  10848. * @returns the unmodified Color4
  10849. */
  10850. toGammaSpaceToRef(convertedColor: Color4): Color4;
  10851. /**
  10852. * Creates a new Color4 from the string containing valid hexadecimal values
  10853. * @param hex defines a string containing valid hexadecimal values
  10854. * @returns a new Color4 object
  10855. */
  10856. static FromHexString(hex: string): Color4;
  10857. /**
  10858. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  10859. * @param left defines the start value
  10860. * @param right defines the end value
  10861. * @param amount defines the gradient factor
  10862. * @returns a new Color4 object
  10863. */
  10864. static Lerp(left: Color4, right: Color4, amount: number): Color4;
  10865. /**
  10866. * Set the passed "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  10867. * @param left defines the start value
  10868. * @param right defines the end value
  10869. * @param amount defines the gradient factor
  10870. * @param result defines the Color4 object where to store data
  10871. */
  10872. static LerpToRef(left: Color4, right: Color4, amount: number, result: Color4): void;
  10873. /**
  10874. * Creates a new Color4 from the starting index element of the passed array
  10875. * @param array defines the source array to read from
  10876. * @param offset defines the offset in the source array
  10877. * @returns a new Color4 object
  10878. */
  10879. static FromArray(array: ArrayLike<number>, offset?: number): Color4;
  10880. /**
  10881. * Creates a new Color3 from integer values (< 256)
  10882. * @param r defines the red component to read from (value between 0 and 255)
  10883. * @param g defines the green component to read from (value between 0 and 255)
  10884. * @param b defines the blue component to read from (value between 0 and 255)
  10885. * @param a defines the alpha component to read from (value between 0 and 255)
  10886. * @returns a new Color3 object
  10887. */
  10888. static FromInts(r: number, g: number, b: number, a: number): Color4;
  10889. /**
  10890. * Check the content of a given array and convert it to an array containing RGBA data
  10891. * If the original array was already containing count * 4 values then it is returned directly
  10892. * @param colors defines the array to check
  10893. * @param count defines the number of RGBA data to expect
  10894. * @returns an array containing count * 4 values (RGBA)
  10895. */
  10896. static CheckColors4(colors: number[], count: number): number[];
  10897. }
  10898. class Vector2 {
  10899. x: number;
  10900. y: number;
  10901. /**
  10902. * Creates a new Vector2 from the passed x and y coordinates.
  10903. */
  10904. constructor(x: number, y: number);
  10905. /**
  10906. * Returns a string with the Vector2 coordinates.
  10907. */
  10908. toString(): string;
  10909. /**
  10910. * Returns the string "Vector2"
  10911. */
  10912. getClassName(): string;
  10913. /**
  10914. * Returns the Vector2 hash code as a number.
  10915. */
  10916. getHashCode(): number;
  10917. /**
  10918. * Sets the Vector2 coordinates in the passed array or Float32Array from the passed index.
  10919. * Returns the Vector2.
  10920. */
  10921. toArray(array: FloatArray, index?: number): Vector2;
  10922. /**
  10923. * Returns a new array with 2 elements : the Vector2 coordinates.
  10924. */
  10925. asArray(): number[];
  10926. /**
  10927. * Sets the Vector2 coordinates with the passed Vector2 coordinates.
  10928. * Returns the updated Vector2.
  10929. */
  10930. copyFrom(source: Vector2): Vector2;
  10931. /**
  10932. * Sets the Vector2 coordinates with the passed floats.
  10933. * Returns the updated Vector2.
  10934. */
  10935. copyFromFloats(x: number, y: number): Vector2;
  10936. /**
  10937. * Sets the Vector2 coordinates with the passed floats.
  10938. * Returns the updated Vector2.
  10939. */
  10940. set(x: number, y: number): Vector2;
  10941. /**
  10942. * Returns a new Vector2 set with the addition of the current Vector2 and the passed one coordinates.
  10943. */
  10944. add(otherVector: Vector2): Vector2;
  10945. /**
  10946. * Sets the "result" coordinates with the addition of the current Vector2 and the passed one coordinates.
  10947. * Returns the Vector2.
  10948. */
  10949. addToRef(otherVector: Vector2, result: Vector2): Vector2;
  10950. /**
  10951. * Set the Vector2 coordinates by adding the passed Vector2 coordinates.
  10952. * Returns the updated Vector2.
  10953. */
  10954. addInPlace(otherVector: Vector2): Vector2;
  10955. /**
  10956. * Returns a new Vector2 by adding the current Vector2 coordinates to the passed Vector3 x, y coordinates.
  10957. */
  10958. addVector3(otherVector: Vector3): Vector2;
  10959. /**
  10960. * Returns a new Vector2 set with the subtracted coordinates of the passed one from the current Vector2.
  10961. */
  10962. subtract(otherVector: Vector2): Vector2;
  10963. /**
  10964. * Sets the "result" coordinates with the subtraction of the passed one from the current Vector2 coordinates.
  10965. * Returns the Vector2.
  10966. */
  10967. subtractToRef(otherVector: Vector2, result: Vector2): Vector2;
  10968. /**
  10969. * Sets the current Vector2 coordinates by subtracting from it the passed one coordinates.
  10970. * Returns the updated Vector2.
  10971. */
  10972. subtractInPlace(otherVector: Vector2): Vector2;
  10973. /**
  10974. * Multiplies in place the current Vector2 coordinates by the passed ones.
  10975. * Returns the updated Vector2.
  10976. */
  10977. multiplyInPlace(otherVector: Vector2): Vector2;
  10978. /**
  10979. * Returns a new Vector2 set with the multiplication of the current Vector2 and the passed one coordinates.
  10980. */
  10981. multiply(otherVector: Vector2): Vector2;
  10982. /**
  10983. * Sets "result" coordinates with the multiplication of the current Vector2 and the passed one coordinates.
  10984. * Returns the Vector2.
  10985. */
  10986. multiplyToRef(otherVector: Vector2, result: Vector2): Vector2;
  10987. /**
  10988. * Returns a new Vector2 set with the Vector2 coordinates multiplied by the passed floats.
  10989. */
  10990. multiplyByFloats(x: number, y: number): Vector2;
  10991. /**
  10992. * Returns a new Vector2 set with the Vector2 coordinates divided by the passed one coordinates.
  10993. */
  10994. divide(otherVector: Vector2): Vector2;
  10995. /**
  10996. * Sets the "result" coordinates with the Vector2 divided by the passed one coordinates.
  10997. * Returns the Vector2.
  10998. */
  10999. divideToRef(otherVector: Vector2, result: Vector2): Vector2;
  11000. /**
  11001. * Divides the current Vector3 coordinates by the passed ones.
  11002. * Returns the updated Vector3.
  11003. */
  11004. divideInPlace(otherVector: Vector2): Vector2;
  11005. /**
  11006. * Returns a new Vector2 with current Vector2 negated coordinates.
  11007. */
  11008. negate(): Vector2;
  11009. /**
  11010. * Multiply the Vector2 coordinates by scale.
  11011. * Returns the updated Vector2.
  11012. */
  11013. scaleInPlace(scale: number): Vector2;
  11014. /**
  11015. * Returns a new Vector2 scaled by "scale" from the current Vector2.
  11016. */
  11017. scale(scale: number): Vector2;
  11018. /**
  11019. * Boolean : True if the passed vector coordinates strictly equal the current Vector2 ones.
  11020. */
  11021. equals(otherVector: Vector2): boolean;
  11022. /**
  11023. * Boolean : True if the passed vector coordinates are close to the current ones by a distance of epsilon.
  11024. */
  11025. equalsWithEpsilon(otherVector: Vector2, epsilon?: number): boolean;
  11026. /**
  11027. * Returns the vector length (float).
  11028. */
  11029. length(): number;
  11030. /**
  11031. * Returns the vector squared length (float);
  11032. */
  11033. lengthSquared(): number;
  11034. /**
  11035. * Normalize the vector.
  11036. * Returns the updated Vector2.
  11037. */
  11038. normalize(): Vector2;
  11039. /**
  11040. * Returns a new Vector2 copied from the Vector2.
  11041. */
  11042. clone(): Vector2;
  11043. /**
  11044. * Returns a new Vector2(0, 0)
  11045. */
  11046. static Zero(): Vector2;
  11047. /**
  11048. * Returns a new Vector2(1, 1)
  11049. */
  11050. static One(): Vector2;
  11051. /**
  11052. * Returns a new Vector2 set from the passed index element of the passed array.
  11053. */
  11054. static FromArray(array: ArrayLike<number>, offset?: number): Vector2;
  11055. /**
  11056. * Sets "result" from the passed index element of the passed array.
  11057. */
  11058. static FromArrayToRef(array: ArrayLike<number>, offset: number, result: Vector2): void;
  11059. /**
  11060. * Retuns a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the passed four Vector2.
  11061. */
  11062. static CatmullRom(value1: Vector2, value2: Vector2, value3: Vector2, value4: Vector2, amount: number): Vector2;
  11063. /**
  11064. * 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".
  11065. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  11066. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate.
  11067. */
  11068. static Clamp(value: Vector2, min: Vector2, max: Vector2): Vector2;
  11069. /**
  11070. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2".
  11071. */
  11072. static Hermite(value1: Vector2, tangent1: Vector2, value2: Vector2, tangent2: Vector2, amount: number): Vector2;
  11073. /**
  11074. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  11075. */
  11076. static Lerp(start: Vector2, end: Vector2, amount: number): Vector2;
  11077. /**
  11078. * Returns the dot product (float) of the vector "left" and the vector "right".
  11079. */
  11080. static Dot(left: Vector2, right: Vector2): number;
  11081. /**
  11082. * Returns a new Vector2 equal to the normalized passed vector.
  11083. */
  11084. static Normalize(vector: Vector2): Vector2;
  11085. /**
  11086. * Returns a new Vecto2 set with the minimal coordinate values from the "left" and "right" vectors.
  11087. */
  11088. static Minimize(left: Vector2, right: Vector2): Vector2;
  11089. /**
  11090. * Returns a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors.
  11091. */
  11092. static Maximize(left: Vector2, right: Vector2): Vector2;
  11093. /**
  11094. * Returns a new Vecto2 set with the transformed coordinates of the passed vector by the passed transformation matrix.
  11095. */
  11096. static Transform(vector: Vector2, transformation: Matrix): Vector2;
  11097. /**
  11098. * Transforms the passed vector coordinates by the passed transformation matrix and stores the result in the vector "result" coordinates.
  11099. */
  11100. static TransformToRef(vector: Vector2, transformation: Matrix, result: Vector2): void;
  11101. /**
  11102. * Boolean : True if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  11103. */
  11104. static PointInTriangle(p: Vector2, p0: Vector2, p1: Vector2, p2: Vector2): boolean;
  11105. /**
  11106. * Returns the distance (float) between the vectors "value1" and "value2".
  11107. */
  11108. static Distance(value1: Vector2, value2: Vector2): number;
  11109. /**
  11110. * Returns the squared distance (float) between the vectors "value1" and "value2".
  11111. */
  11112. static DistanceSquared(value1: Vector2, value2: Vector2): number;
  11113. /**
  11114. * Returns a new Vecto2 located at the center of the vectors "value1" and "value2".
  11115. */
  11116. static Center(value1: Vector2, value2: Vector2): Vector2;
  11117. /**
  11118. * Returns the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  11119. */
  11120. static DistanceOfPointFromSegment(p: Vector2, segA: Vector2, segB: Vector2): number;
  11121. }
  11122. /**
  11123. * Classed used to store (x,y,z) vector representation
  11124. * A Vector3 is the main object used in 3D geometry
  11125. * It can represent etiher the coordinates of a point the space, either a direction
  11126. * Reminder: Babylon.js uses a left handed forward facing system
  11127. */
  11128. class Vector3 {
  11129. /**
  11130. * Defines the first coordinates (on X axis)
  11131. */
  11132. x: number;
  11133. /**
  11134. * Defines the second coordinates (on Y axis)
  11135. */
  11136. y: number;
  11137. /**
  11138. * Defines the third coordinates (on Z axis)
  11139. */
  11140. z: number;
  11141. /**
  11142. * Creates a new Vector3 object from the passed x, y, z (floats) coordinates.
  11143. * @param x defines the first coordinates (on X axis)
  11144. * @param y defines the second coordinates (on Y axis)
  11145. * @param z defines the third coordinates (on Z axis)
  11146. */
  11147. constructor(
  11148. /**
  11149. * Defines the first coordinates (on X axis)
  11150. */
  11151. x: number,
  11152. /**
  11153. * Defines the second coordinates (on Y axis)
  11154. */
  11155. y: number,
  11156. /**
  11157. * Defines the third coordinates (on Z axis)
  11158. */
  11159. z: number);
  11160. /**
  11161. * Creates a string representation of the Vector3
  11162. * @returns a string with the Vector3 coordinates.
  11163. */
  11164. toString(): string;
  11165. /**
  11166. * Gets the class name
  11167. * @returns the string "Vector3"
  11168. */
  11169. getClassName(): string;
  11170. /**
  11171. * Creates the Vector3 hash code
  11172. * @returns a number which tends to be unique between Vector3 instances
  11173. */
  11174. getHashCode(): number;
  11175. /**
  11176. * Creates an array containing three elements : the coordinates of the Vector3
  11177. * @returns a new array of numbers
  11178. */
  11179. asArray(): number[];
  11180. /**
  11181. * Populates the passed array or Float32Array from the passed index with the successive coordinates of the Vector3
  11182. * @param array defines the destination array
  11183. * @param index defines the offset in the destination array
  11184. * @returns the current Vector3
  11185. */
  11186. toArray(array: FloatArray, index?: number): Vector3;
  11187. /**
  11188. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  11189. * @returns a new Quaternion object, computed from the Vector3 coordinates
  11190. */
  11191. toQuaternion(): Quaternion;
  11192. /**
  11193. * Adds the passed vector to the current Vector3
  11194. * @param otherVector defines the second operand
  11195. * @returns the current updated Vector3
  11196. */
  11197. addInPlace(otherVector: Vector3): Vector3;
  11198. /**
  11199. * Gets a new Vector3, result of the addition the current Vector3 and the passed vector
  11200. * @param otherVector defines the second operand
  11201. * @returns the resulting Vector3
  11202. */
  11203. add(otherVector: Vector3): Vector3;
  11204. /**
  11205. * Adds the current Vector3 to the passed one and stores the result in the vector "result"
  11206. * @param otherVector defines the second operand
  11207. * @param result defines the Vector3 object where to store the result
  11208. * @returns the current Vector3
  11209. */
  11210. addToRef(otherVector: Vector3, result: Vector3): Vector3;
  11211. /**
  11212. * Subtract the passed vector from the current Vector3
  11213. * @param otherVector defines the second operand
  11214. * @returns the current updated Vector3
  11215. */
  11216. subtractInPlace(otherVector: Vector3): Vector3;
  11217. /**
  11218. * Returns a new Vector3, result of the subtraction of the passed vector from the current Vector3
  11219. * @param otherVector defines the second operand
  11220. * @returns the resulting Vector3
  11221. */
  11222. subtract(otherVector: Vector3): Vector3;
  11223. /**
  11224. * Subtracts the passed vector from the current Vector3 and stores the result in the vector "result".
  11225. * @param otherVector defines the second operand
  11226. * @param result defines the Vector3 object where to store the result
  11227. * @returns the current Vector3
  11228. */
  11229. subtractToRef(otherVector: Vector3, result: Vector3): Vector3;
  11230. /**
  11231. * Returns a new Vector3 set with the subtraction of the passed floats from the current Vector3 coordinates
  11232. * @param x defines the x coordinate of the operand
  11233. * @param y defines the y coordinate of the operand
  11234. * @param z defines the z coordinate of the operand
  11235. * @returns the resulting Vector3
  11236. */
  11237. subtractFromFloats(x: number, y: number, z: number): Vector3;
  11238. /**
  11239. * Subtracts the passed floats from the current Vector3 coordinates and set the passed vector "result" with this result
  11240. * @param x defines the x coordinate of the operand
  11241. * @param y defines the y coordinate of the operand
  11242. * @param z defines the z coordinate of the operand
  11243. * @param result defines the Vector3 object where to store the result
  11244. * @returns the current Vector3
  11245. */
  11246. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  11247. /**
  11248. * Gets a new Vector3 set with the current Vector3 negated coordinates
  11249. * @returns a new Vector3
  11250. */
  11251. negate(): Vector3;
  11252. /**
  11253. * Multiplies the Vector3 coordinates by the float "scale"
  11254. * @param scale defines the multiplier factor
  11255. * @returns the current updated Vector3
  11256. */
  11257. scaleInPlace(scale: number): Vector3;
  11258. /**
  11259. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  11260. * @param scale defines the multiplier factor
  11261. * @returns a new Vector3
  11262. */
  11263. scale(scale: number): Vector3;
  11264. /**
  11265. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the passed vector "result" coordinates
  11266. * @param scale defines the multiplier factor
  11267. * @param result defines the Vector3 object where to store the result
  11268. * @returns the current Vector3
  11269. */
  11270. scaleToRef(scale: number, result: Vector3): Vector3;
  11271. /**
  11272. * Returns true if the current Vector3 and the passed vector coordinates are strictly equal
  11273. * @param otherVector defines the second operand
  11274. * @returns true if both vectors are equals
  11275. */
  11276. equals(otherVector: Vector3): boolean;
  11277. /**
  11278. * Returns true if the current Vector3 and the passed vector coordinates are distant less than epsilon
  11279. * @param otherVector defines the second operand
  11280. * @param epsilon defines the minimal distance to define values as equals
  11281. * @returns true if both vectors are distant less than epsilon
  11282. */
  11283. equalsWithEpsilon(otherVector: Vector3, epsilon?: number): boolean;
  11284. /**
  11285. * Returns true if the current Vector3 coordinates equals the passed floats
  11286. * @param x defines the x coordinate of the operand
  11287. * @param y defines the y coordinate of the operand
  11288. * @param z defines the z coordinate of the operand
  11289. * @returns true if both vectors are equals
  11290. */
  11291. equalsToFloats(x: number, y: number, z: number): boolean;
  11292. /**
  11293. * Multiplies the current Vector3 coordinates by the passed ones
  11294. * @param otherVector defines the second operand
  11295. * @returns the current updated Vector3
  11296. */
  11297. multiplyInPlace(otherVector: Vector3): Vector3;
  11298. /**
  11299. * Returns a new Vector3, result of the multiplication of the current Vector3 by the passed vector
  11300. * @param otherVector defines the second operand
  11301. * @returns the new Vector3
  11302. */
  11303. multiply(otherVector: Vector3): Vector3;
  11304. /**
  11305. * Multiplies the current Vector3 by the passed one and stores the result in the passed vector "result"
  11306. * @param otherVector defines the second operand
  11307. * @param result defines the Vector3 object where to store the result
  11308. * @returns the current Vector3
  11309. */
  11310. multiplyToRef(otherVector: Vector3, result: Vector3): Vector3;
  11311. /**
  11312. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the passed floats
  11313. * @param x defines the x coordinate of the operand
  11314. * @param y defines the y coordinate of the operand
  11315. * @param z defines the z coordinate of the operand
  11316. * @returns the new Vector3
  11317. */
  11318. multiplyByFloats(x: number, y: number, z: number): Vector3;
  11319. /**
  11320. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the passed ones
  11321. * @param otherVector defines the second operand
  11322. * @returns the new Vector3
  11323. */
  11324. divide(otherVector: Vector3): Vector3;
  11325. /**
  11326. * Divides the current Vector3 coordinates by the passed ones and stores the result in the passed vector "result"
  11327. * @param otherVector defines the second operand
  11328. * @param result defines the Vector3 object where to store the result
  11329. * @returns the current Vector3
  11330. */
  11331. divideToRef(otherVector: Vector3, result: Vector3): Vector3;
  11332. /**
  11333. * Divides the current Vector3 coordinates by the passed ones.
  11334. * @param otherVector defines the second operand
  11335. * @returns the current updated Vector3
  11336. */
  11337. divideInPlace(otherVector: Vector3): Vector3;
  11338. /**
  11339. * Updates the current Vector3 with the minimal coordinate values between its and the passed vector ones
  11340. * @param other defines the second operand
  11341. * @returns the current updated Vector3
  11342. */
  11343. minimizeInPlace(other: Vector3): Vector3;
  11344. /**
  11345. * Updates the current Vector3 with the maximal coordinate values between its and the passed vector ones.
  11346. * @param other defines the second operand
  11347. * @returns the current updated Vector3
  11348. */
  11349. maximizeInPlace(other: Vector3): Vector3;
  11350. /**
  11351. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  11352. */
  11353. readonly isNonUniform: boolean;
  11354. /**
  11355. * Gets the length of the Vector3
  11356. * @returns the length of the Vecto3
  11357. */
  11358. length(): number;
  11359. /**
  11360. * Gets the squared length of the Vector3
  11361. * @returns squared length of the Vector3
  11362. */
  11363. lengthSquared(): number;
  11364. /**
  11365. * Normalize the current Vector3.
  11366. * Please note that this is an in place operation.
  11367. * @returns the current updated Vector3
  11368. */
  11369. normalize(): Vector3;
  11370. /**
  11371. * Normalize the current Vector3 to a new vector
  11372. * @returns the new Vector3
  11373. */
  11374. normalizeToNew(): Vector3;
  11375. /**
  11376. * Normalize the current Vector3 to the reference
  11377. * @param reference define the Vector3 to update
  11378. * @returns the updated Vector3
  11379. */
  11380. normalizeToRef(reference: Vector3): Vector3;
  11381. /**
  11382. * Creates a new Vector3 copied from the current Vector3
  11383. * @returns the new Vector3
  11384. */
  11385. clone(): Vector3;
  11386. /**
  11387. * Copies the passed vector coordinates to the current Vector3 ones
  11388. * @param source defines the source Vector3
  11389. * @returns the current updated Vector3
  11390. */
  11391. copyFrom(source: Vector3): Vector3;
  11392. /**
  11393. * Copies the passed floats to the current Vector3 coordinates
  11394. * @param x defines the x coordinate of the operand
  11395. * @param y defines the y coordinate of the operand
  11396. * @param z defines the z coordinate of the operand
  11397. * @returns the current updated Vector3
  11398. */
  11399. copyFromFloats(x: number, y: number, z: number): Vector3;
  11400. /**
  11401. * Copies the passed floats to the current Vector3 coordinates
  11402. * @param x defines the x coordinate of the operand
  11403. * @param y defines the y coordinate of the operand
  11404. * @param z defines the z coordinate of the operand
  11405. * @returns the current updated Vector3
  11406. */
  11407. set(x: number, y: number, z: number): Vector3;
  11408. /**
  11409. * Get the clip factor between two vectors
  11410. * @param vector0 defines the first operand
  11411. * @param vector1 defines the second operand
  11412. * @param axis defines the axis to use
  11413. * @param size defines the size along the axis
  11414. * @returns the clip factor
  11415. */
  11416. static GetClipFactor(vector0: Vector3, vector1: Vector3, axis: Vector3, size: number): number;
  11417. /**
  11418. * Get angle between two vectors
  11419. * @param vector0 angle between vector0 and vector1
  11420. * @param vector1 angle between vector0 and vector1
  11421. * @param normal direction of the normal
  11422. * @return the angle between vector0 and vector1
  11423. */
  11424. static GetAngleBetweenVectors(vector0: Vector3, vector1: Vector3, normal: Vector3): number;
  11425. /**
  11426. * Returns a new Vector3 set from the index "offset" of the passed array
  11427. * @param array defines the source array
  11428. * @param offset defines the offset in the source array
  11429. * @returns the new Vector3
  11430. */
  11431. static FromArray(array: ArrayLike<number>, offset?: number): Vector3;
  11432. /**
  11433. * Returns a new Vector3 set from the index "offset" of the passed Float32Array
  11434. * This function is deprecated. Use FromArray instead
  11435. * @param array defines the source array
  11436. * @param offset defines the offset in the source array
  11437. * @returns the new Vector3
  11438. */
  11439. static FromFloatArray(array: Float32Array, offset?: number): Vector3;
  11440. /**
  11441. * Sets the passed vector "result" with the element values from the index "offset" of the passed array
  11442. * @param array defines the source array
  11443. * @param offset defines the offset in the source array
  11444. * @param result defines the Vector3 where to store the result
  11445. */
  11446. static FromArrayToRef(array: ArrayLike<number>, offset: number, result: Vector3): void;
  11447. /**
  11448. * Sets the passed vector "result" with the element values from the index "offset" of the passed Float32Array
  11449. * This function is deprecated. Use FromArrayToRef instead.
  11450. * @param array defines the source array
  11451. * @param offset defines the offset in the source array
  11452. * @param result defines the Vector3 where to store the result
  11453. */
  11454. static FromFloatArrayToRef(array: Float32Array, offset: number, result: Vector3): void;
  11455. /**
  11456. * Sets the passed vector "result" with the passed floats.
  11457. * @param x defines the x coordinate of the source
  11458. * @param y defines the y coordinate of the source
  11459. * @param z defines the z coordinate of the source
  11460. * @param result defines the Vector3 where to store the result
  11461. */
  11462. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  11463. /**
  11464. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  11465. * @returns a new empty Vector3
  11466. */
  11467. static Zero(): Vector3;
  11468. /**
  11469. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  11470. * @returns a new unit Vector3
  11471. */
  11472. static One(): Vector3;
  11473. /**
  11474. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  11475. * @returns a new up Vector3
  11476. */
  11477. static Up(): Vector3;
  11478. /**
  11479. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  11480. * @returns a new forward Vector3
  11481. */
  11482. static Forward(): Vector3;
  11483. /**
  11484. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  11485. * @returns a new right Vector3
  11486. */
  11487. static Right(): Vector3;
  11488. /**
  11489. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  11490. * @returns a new left Vector3
  11491. */
  11492. static Left(): Vector3;
  11493. /**
  11494. * Returns a new Vector3 set with the result of the transformation by the passed matrix of the passed vector.
  11495. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  11496. * @param vector defines the Vector3 to transform
  11497. * @param transformation defines the transformation matrix
  11498. * @returns the transformed Vector3
  11499. */
  11500. static TransformCoordinates(vector: Vector3, transformation: Matrix): Vector3;
  11501. /**
  11502. * Sets the passed vector "result" coordinates with the result of the transformation by the passed matrix of the passed vector
  11503. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  11504. * @param vector defines the Vector3 to transform
  11505. * @param transformation defines the transformation matrix
  11506. * @param result defines the Vector3 where to store the result
  11507. */
  11508. static TransformCoordinatesToRef(vector: Vector3, transformation: Matrix, result: Vector3): void;
  11509. /**
  11510. * Sets the passed vector "result" coordinates with the result of the transformation by the passed matrix of the passed floats (x, y, z)
  11511. * This method computes tranformed coordinates only, not transformed direction vectors
  11512. * @param x define the x coordinate of the source vector
  11513. * @param y define the y coordinate of the source vector
  11514. * @param z define the z coordinate of the source vector
  11515. * @param transformation defines the transformation matrix
  11516. * @param result defines the Vector3 where to store the result
  11517. */
  11518. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: Matrix, result: Vector3): void;
  11519. /**
  11520. * Returns a new Vector3 set with the result of the normal transformation by the passed matrix of the passed vector
  11521. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  11522. * @param vector defines the Vector3 to transform
  11523. * @param transformation defines the transformation matrix
  11524. * @returns the new Vector3
  11525. */
  11526. static TransformNormal(vector: Vector3, transformation: Matrix): Vector3;
  11527. /**
  11528. * Sets the passed vector "result" with the result of the normal transformation by the passed matrix of the passed vector
  11529. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  11530. * @param vector defines the Vector3 to transform
  11531. * @param transformation defines the transformation matrix
  11532. * @param result defines the Vector3 where to store the result
  11533. */
  11534. static TransformNormalToRef(vector: Vector3, transformation: Matrix, result: Vector3): void;
  11535. /**
  11536. * Sets the passed vector "result" with the result of the normal transformation by the passed matrix of the passed floats (x, y, z)
  11537. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  11538. * @param x define the x coordinate of the source vector
  11539. * @param y define the y coordinate of the source vector
  11540. * @param z define the z coordinate of the source vector
  11541. * @param transformation defines the transformation matrix
  11542. * @param result defines the Vector3 where to store the result
  11543. */
  11544. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: Matrix, result: Vector3): void;
  11545. /**
  11546. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  11547. * @param value1 defines the first control point
  11548. * @param value2 defines the second control point
  11549. * @param value3 defines the third control point
  11550. * @param value4 defines the fourth control point
  11551. * @param amount defines the amount on the spline to use
  11552. * @returns the new Vector3
  11553. */
  11554. static CatmullRom(value1: Vector3, value2: Vector3, value3: Vector3, value4: Vector3, amount: number): Vector3;
  11555. /**
  11556. * 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"
  11557. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  11558. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  11559. * @param value defines the current value
  11560. * @param min defines the lower range value
  11561. * @param max defines the upper range value
  11562. * @returns the new Vector3
  11563. */
  11564. static Clamp(value: Vector3, min: Vector3, max: Vector3): Vector3;
  11565. /**
  11566. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  11567. * @param value1 defines the first control point
  11568. * @param tangent1 defines the first tangent vector
  11569. * @param value2 defines the second control point
  11570. * @param tangent2 defines the second tangent vector
  11571. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  11572. * @returns the new Vector3
  11573. */
  11574. static Hermite(value1: Vector3, tangent1: Vector3, value2: Vector3, tangent2: Vector3, amount: number): Vector3;
  11575. /**
  11576. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  11577. * @param start defines the start value
  11578. * @param end defines the end value
  11579. * @param amount max defines amount between both (between 0 and 1)
  11580. * @returns the new Vector3
  11581. */
  11582. static Lerp(start: Vector3, end: Vector3, amount: number): Vector3;
  11583. /**
  11584. * Sets the passed vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  11585. * @param start defines the start value
  11586. * @param end defines the end value
  11587. * @param amount max defines amount between both (between 0 and 1)
  11588. * @param result defines the Vector3 where to store the result
  11589. */
  11590. static LerpToRef(start: Vector3, end: Vector3, amount: number, result: Vector3): void;
  11591. /**
  11592. * Returns the dot product (float) between the vectors "left" and "right"
  11593. * @param left defines the left operand
  11594. * @param right defines the right operand
  11595. * @returns the dot product
  11596. */
  11597. static Dot(left: Vector3, right: Vector3): number;
  11598. /**
  11599. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  11600. * The cross product is then orthogonal to both "left" and "right"
  11601. * @param left defines the left operand
  11602. * @param right defines the right operand
  11603. * @returns the cross product
  11604. */
  11605. static Cross(left: Vector3, right: Vector3): Vector3;
  11606. /**
  11607. * Sets the passed vector "result" with the cross product of "left" and "right"
  11608. * The cross product is then orthogonal to both "left" and "right"
  11609. * @param left defines the left operand
  11610. * @param right defines the right operand
  11611. * @param result defines the Vector3 where to store the result
  11612. */
  11613. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  11614. /**
  11615. * Returns a new Vector3 as the normalization of the passed vector
  11616. * @param vector defines the Vector3 to normalize
  11617. * @returns the new Vector3
  11618. */
  11619. static Normalize(vector: Vector3): Vector3;
  11620. /**
  11621. * Sets the passed vector "result" with the normalization of the passed first vector
  11622. * @param vector defines the Vector3 to normalize
  11623. * @param result defines the Vector3 where to store the result
  11624. */
  11625. static NormalizeToRef(vector: Vector3, result: Vector3): void;
  11626. private static _viewportMatrixCache;
  11627. /**
  11628. * Project a Vector3 onto screen space
  11629. * @param vector defines the Vector3 to project
  11630. * @param world defines the world matrix to use
  11631. * @param transform defines the transform (view x projection) matrix to use
  11632. * @param viewport defines the screen viewport to use
  11633. * @returns the new Vector3
  11634. */
  11635. static Project(vector: Vector3, world: Matrix, transform: Matrix, viewport: Viewport): Vector3;
  11636. /**
  11637. * Unproject from screen space to object space
  11638. * @param source defines the screen space Vector3 to use
  11639. * @param viewportWidth defines the current width of the viewport
  11640. * @param viewportHeight defines the current height of the viewport
  11641. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  11642. * @param transform defines the transform (view x projection) matrix to use
  11643. * @returns the new Vector3
  11644. */
  11645. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: Matrix, transform: Matrix): Vector3;
  11646. /**
  11647. * Unproject from screen space to object space
  11648. * @param source defines the screen space Vector3 to use
  11649. * @param viewportWidth defines the current width of the viewport
  11650. * @param viewportHeight defines the current height of the viewport
  11651. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  11652. * @param view defines the view matrix to use
  11653. * @param projection defines the projection matrix to use
  11654. * @returns the new Vector3
  11655. */
  11656. static Unproject(source: Vector3, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix): Vector3;
  11657. /**
  11658. * Unproject from screen space to object space
  11659. * @param source defines the screen space Vector3 to use
  11660. * @param viewportWidth defines the current width of the viewport
  11661. * @param viewportHeight defines the current height of the viewport
  11662. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  11663. * @param view defines the view matrix to use
  11664. * @param projection defines the projection matrix to use
  11665. * @param result defines the Vector3 where to store the result
  11666. */
  11667. static UnprojectToRef(source: Vector3, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix, result: Vector3): void;
  11668. /**
  11669. * Unproject from screen space to object space
  11670. * @param sourceX defines the screen space x coordinate to use
  11671. * @param sourceY defines the screen space y coordinate to use
  11672. * @param sourceZ defines the screen space z coordinate to use
  11673. * @param viewportWidth defines the current width of the viewport
  11674. * @param viewportHeight defines the current height of the viewport
  11675. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  11676. * @param view defines the view matrix to use
  11677. * @param projection defines the projection matrix to use
  11678. * @param result defines the Vector3 where to store the result
  11679. */
  11680. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix, result: Vector3): void;
  11681. /**
  11682. * Gets the minimal coordinate values between two Vector3
  11683. * @param left defines the first operand
  11684. * @param right defines the second operand
  11685. * @returns the new Vector3
  11686. */
  11687. static Minimize(left: Vector3, right: Vector3): Vector3;
  11688. /**
  11689. * Gets the maximal coordinate values between two Vector3
  11690. * @param left defines the first operand
  11691. * @param right defines the second operand
  11692. * @returns the new Vector3
  11693. */
  11694. static Maximize(left: Vector3, right: Vector3): Vector3;
  11695. /**
  11696. * Returns the distance between the vectors "value1" and "value2"
  11697. * @param value1 defines the first operand
  11698. * @param value2 defines the second operand
  11699. * @returns the distance
  11700. */
  11701. static Distance(value1: Vector3, value2: Vector3): number;
  11702. /**
  11703. * Returns the squared distance between the vectors "value1" and "value2"
  11704. * @param value1 defines the first operand
  11705. * @param value2 defines the second operand
  11706. * @returns the squared distance
  11707. */
  11708. static DistanceSquared(value1: Vector3, value2: Vector3): number;
  11709. /**
  11710. * Returns a new Vector3 located at the center between "value1" and "value2"
  11711. * @param value1 defines the first operand
  11712. * @param value2 defines the second operand
  11713. * @returns the new Vector3
  11714. */
  11715. static Center(value1: Vector3, value2: Vector3): Vector3;
  11716. /**
  11717. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  11718. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  11719. * to something in order to rotate it from its local system to the given target system
  11720. * Note: axis1, axis2 and axis3 are normalized during this operation
  11721. * @param axis1 defines the first axis
  11722. * @param axis2 defines the second axis
  11723. * @param axis3 defines the third axis
  11724. * @returns a new Vector3
  11725. */
  11726. static RotationFromAxis(axis1: Vector3, axis2: Vector3, axis3: Vector3): Vector3;
  11727. /**
  11728. * The same than RotationFromAxis but updates the passed ref Vector3 parameter instead of returning a new Vector3
  11729. * @param axis1 defines the first axis
  11730. * @param axis2 defines the second axis
  11731. * @param axis3 defines the third axis
  11732. * @param ref defines the Vector3 where to store the result
  11733. */
  11734. static RotationFromAxisToRef(axis1: Vector3, axis2: Vector3, axis3: Vector3, ref: Vector3): void;
  11735. }
  11736. class Vector4 {
  11737. x: number;
  11738. y: number;
  11739. z: number;
  11740. w: number;
  11741. /**
  11742. * Creates a Vector4 object from the passed floats.
  11743. */
  11744. constructor(x: number, y: number, z: number, w: number);
  11745. /**
  11746. * Returns the string with the Vector4 coordinates.
  11747. */
  11748. toString(): string;
  11749. /**
  11750. * Returns the string "Vector4".
  11751. */
  11752. getClassName(): string;
  11753. /**
  11754. * Returns the Vector4 hash code.
  11755. */
  11756. getHashCode(): number;
  11757. /**
  11758. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  11759. */
  11760. asArray(): number[];
  11761. /**
  11762. * Populates the passed array from the passed index with the Vector4 coordinates.
  11763. * Returns the Vector4.
  11764. */
  11765. toArray(array: FloatArray, index?: number): Vector4;
  11766. /**
  11767. * Adds the passed vector to the current Vector4.
  11768. * Returns the updated Vector4.
  11769. */
  11770. addInPlace(otherVector: Vector4): Vector4;
  11771. /**
  11772. * Returns a new Vector4 as the result of the addition of the current Vector4 and the passed one.
  11773. */
  11774. add(otherVector: Vector4): Vector4;
  11775. /**
  11776. * Updates the passed vector "result" with the result of the addition of the current Vector4 and the passed one.
  11777. * Returns the current Vector4.
  11778. */
  11779. addToRef(otherVector: Vector4, result: Vector4): Vector4;
  11780. /**
  11781. * Subtract in place the passed vector from the current Vector4.
  11782. * Returns the updated Vector4.
  11783. */
  11784. subtractInPlace(otherVector: Vector4): Vector4;
  11785. /**
  11786. * Returns a new Vector4 with the result of the subtraction of the passed vector from the current Vector4.
  11787. */
  11788. subtract(otherVector: Vector4): Vector4;
  11789. /**
  11790. * Sets the passed vector "result" with the result of the subtraction of the passed vector from the current Vector4.
  11791. * Returns the current Vector4.
  11792. */
  11793. subtractToRef(otherVector: Vector4, result: Vector4): Vector4;
  11794. /**
  11795. * Returns a new Vector4 set with the result of the subtraction of the passed floats from the current Vector4 coordinates.
  11796. */
  11797. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  11798. /**
  11799. * Sets the passed vector "result" set with the result of the subtraction of the passed floats from the current Vector4 coordinates.
  11800. * Returns the current Vector4.
  11801. */
  11802. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  11803. /**
  11804. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  11805. */
  11806. negate(): Vector4;
  11807. /**
  11808. * Multiplies the current Vector4 coordinates by scale (float).
  11809. * Returns the updated Vector4.
  11810. */
  11811. scaleInPlace(scale: number): Vector4;
  11812. /**
  11813. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  11814. */
  11815. scale(scale: number): Vector4;
  11816. /**
  11817. * Sets the passed vector "result" with the current Vector4 coordinates multiplied by scale (float).
  11818. * Returns the current Vector4.
  11819. */
  11820. scaleToRef(scale: number, result: Vector4): Vector4;
  11821. /**
  11822. * Boolean : True if the current Vector4 coordinates are stricly equal to the passed ones.
  11823. */
  11824. equals(otherVector: Vector4): boolean;
  11825. /**
  11826. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the passed vector ones.
  11827. */
  11828. equalsWithEpsilon(otherVector: Vector4, epsilon?: number): boolean;
  11829. /**
  11830. * Boolean : True if the passed floats are strictly equal to the current Vector4 coordinates.
  11831. */
  11832. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  11833. /**
  11834. * Multiplies in place the current Vector4 by the passed one.
  11835. * Returns the updated Vector4.
  11836. */
  11837. multiplyInPlace(otherVector: Vector4): Vector4;
  11838. /**
  11839. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the passed one.
  11840. */
  11841. multiply(otherVector: Vector4): Vector4;
  11842. /**
  11843. * Updates the passed vector "result" with the multiplication result of the current Vector4 and the passed one.
  11844. * Returns the current Vector4.
  11845. */
  11846. multiplyToRef(otherVector: Vector4, result: Vector4): Vector4;
  11847. /**
  11848. * Returns a new Vector4 set with the multiplication result of the passed floats and the current Vector4 coordinates.
  11849. */
  11850. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  11851. /**
  11852. * Returns a new Vector4 set with the division result of the current Vector4 by the passed one.
  11853. */
  11854. divide(otherVector: Vector4): Vector4;
  11855. /**
  11856. * Updates the passed vector "result" with the division result of the current Vector4 by the passed one.
  11857. * Returns the current Vector4.
  11858. */
  11859. divideToRef(otherVector: Vector4, result: Vector4): Vector4;
  11860. /**
  11861. * Divides the current Vector3 coordinates by the passed ones.
  11862. * @returns the updated Vector3.
  11863. */
  11864. divideInPlace(otherVector: Vector4): Vector4;
  11865. /**
  11866. * Updates the Vector4 coordinates with the minimum values between its own and the passed vector ones
  11867. * @param other defines the second operand
  11868. * @returns the current updated Vector4
  11869. */
  11870. minimizeInPlace(other: Vector4): Vector4;
  11871. /**
  11872. * Updates the Vector4 coordinates with the maximum values between its own and the passed vector ones
  11873. * @param other defines the second operand
  11874. * @returns the current updated Vector4
  11875. */
  11876. maximizeInPlace(other: Vector4): Vector4;
  11877. /**
  11878. * Returns the Vector4 length (float).
  11879. */
  11880. length(): number;
  11881. /**
  11882. * Returns the Vector4 squared length (float).
  11883. */
  11884. lengthSquared(): number;
  11885. /**
  11886. * Normalizes in place the Vector4.
  11887. * Returns the updated Vector4.
  11888. */
  11889. normalize(): Vector4;
  11890. /**
  11891. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  11892. */
  11893. toVector3(): Vector3;
  11894. /**
  11895. * Returns a new Vector4 copied from the current one.
  11896. */
  11897. clone(): Vector4;
  11898. /**
  11899. * Updates the current Vector4 with the passed one coordinates.
  11900. * Returns the updated Vector4.
  11901. */
  11902. copyFrom(source: Vector4): Vector4;
  11903. /**
  11904. * Updates the current Vector4 coordinates with the passed floats.
  11905. * Returns the updated Vector4.
  11906. */
  11907. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  11908. /**
  11909. * Updates the current Vector4 coordinates with the passed floats.
  11910. * Returns the updated Vector4.
  11911. */
  11912. set(x: number, y: number, z: number, w: number): Vector4;
  11913. /**
  11914. * Returns a new Vector4 set from the starting index of the passed array.
  11915. */
  11916. static FromArray(array: ArrayLike<number>, offset?: number): Vector4;
  11917. /**
  11918. * Updates the passed vector "result" from the starting index of the passed array.
  11919. */
  11920. static FromArrayToRef(array: ArrayLike<number>, offset: number, result: Vector4): void;
  11921. /**
  11922. * Updates the passed vector "result" from the starting index of the passed Float32Array.
  11923. */
  11924. static FromFloatArrayToRef(array: Float32Array, offset: number, result: Vector4): void;
  11925. /**
  11926. * Updates the passed vector "result" coordinates from the passed floats.
  11927. */
  11928. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  11929. /**
  11930. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  11931. */
  11932. static Zero(): Vector4;
  11933. /**
  11934. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  11935. */
  11936. static One(): Vector4;
  11937. /**
  11938. * Returns a new normalized Vector4 from the passed one.
  11939. */
  11940. static Normalize(vector: Vector4): Vector4;
  11941. /**
  11942. * Updates the passed vector "result" from the normalization of the passed one.
  11943. */
  11944. static NormalizeToRef(vector: Vector4, result: Vector4): void;
  11945. static Minimize(left: Vector4, right: Vector4): Vector4;
  11946. static Maximize(left: Vector4, right: Vector4): Vector4;
  11947. /**
  11948. * Returns the distance (float) between the vectors "value1" and "value2".
  11949. */
  11950. static Distance(value1: Vector4, value2: Vector4): number;
  11951. /**
  11952. * Returns the squared distance (float) between the vectors "value1" and "value2".
  11953. */
  11954. static DistanceSquared(value1: Vector4, value2: Vector4): number;
  11955. /**
  11956. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  11957. */
  11958. static Center(value1: Vector4, value2: Vector4): Vector4;
  11959. /**
  11960. * Returns a new Vector4 set with the result of the normal transformation by the passed matrix of the passed vector.
  11961. * This methods computes transformed normalized direction vectors only.
  11962. */
  11963. static TransformNormal(vector: Vector4, transformation: Matrix): Vector4;
  11964. /**
  11965. * Sets the passed vector "result" with the result of the normal transformation by the passed matrix of the passed vector.
  11966. * This methods computes transformed normalized direction vectors only.
  11967. */
  11968. static TransformNormalToRef(vector: Vector4, transformation: Matrix, result: Vector4): void;
  11969. /**
  11970. * Sets the passed vector "result" with the result of the normal transformation by the passed matrix of the passed floats (x, y, z, w).
  11971. * This methods computes transformed normalized direction vectors only.
  11972. */
  11973. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: Matrix, result: Vector4): void;
  11974. }
  11975. interface ISize {
  11976. width: number;
  11977. height: number;
  11978. }
  11979. class Size implements ISize {
  11980. width: number;
  11981. height: number;
  11982. /**
  11983. * Creates a Size object from the passed width and height (floats).
  11984. */
  11985. constructor(width: number, height: number);
  11986. toString(): string;
  11987. /**
  11988. * Returns the string "Size"
  11989. */
  11990. getClassName(): string;
  11991. /**
  11992. * Returns the Size hash code.
  11993. */
  11994. getHashCode(): number;
  11995. /**
  11996. * Updates the current size from the passed one.
  11997. * Returns the updated Size.
  11998. */
  11999. copyFrom(src: Size): void;
  12000. /**
  12001. * Updates in place the current Size from the passed floats.
  12002. * Returns the updated Size.
  12003. */
  12004. copyFromFloats(width: number, height: number): Size;
  12005. /**
  12006. * Updates in place the current Size from the passed floats.
  12007. * Returns the updated Size.
  12008. */
  12009. set(width: number, height: number): Size;
  12010. /**
  12011. * Returns a new Size set with the multiplication result of the current Size and the passed floats.
  12012. */
  12013. multiplyByFloats(w: number, h: number): Size;
  12014. /**
  12015. * Returns a new Size copied from the passed one.
  12016. */
  12017. clone(): Size;
  12018. /**
  12019. * Boolean : True if the current Size and the passed one width and height are strictly equal.
  12020. */
  12021. equals(other: Size): boolean;
  12022. /**
  12023. * Returns the surface of the Size : width * height (float).
  12024. */
  12025. readonly surface: number;
  12026. /**
  12027. * Returns a new Size set to (0.0, 0.0)
  12028. */
  12029. static Zero(): Size;
  12030. /**
  12031. * Returns a new Size set as the addition result of the current Size and the passed one.
  12032. */
  12033. add(otherSize: Size): Size;
  12034. /**
  12035. * Returns a new Size set as the subtraction result of the passed one from the current Size.
  12036. */
  12037. subtract(otherSize: Size): Size;
  12038. /**
  12039. * Returns a new Size set at the linear interpolation "amount" between "start" and "end".
  12040. */
  12041. static Lerp(start: Size, end: Size, amount: number): Size;
  12042. }
  12043. class Quaternion {
  12044. x: number;
  12045. y: number;
  12046. z: number;
  12047. w: number;
  12048. /**
  12049. * Creates a new Quaternion from the passed floats.
  12050. */
  12051. constructor(x?: number, y?: number, z?: number, w?: number);
  12052. /**
  12053. * Returns a string with the Quaternion coordinates.
  12054. */
  12055. toString(): string;
  12056. /**
  12057. * Returns the string "Quaternion".
  12058. */
  12059. getClassName(): string;
  12060. /**
  12061. * Returns the Quaternion hash code.
  12062. */
  12063. getHashCode(): number;
  12064. /**
  12065. * Returns a new array populated with 4 elements : the Quaternion coordinates.
  12066. */
  12067. asArray(): number[];
  12068. /**
  12069. * Boolean : True if the current Quaterion and the passed one coordinates are strictly equal.
  12070. */
  12071. equals(otherQuaternion: Quaternion): boolean;
  12072. /**
  12073. * Returns a new Quaternion copied from the current one.
  12074. */
  12075. clone(): Quaternion;
  12076. /**
  12077. * Updates the current Quaternion from the passed one coordinates.
  12078. * Returns the updated Quaterion.
  12079. */
  12080. copyFrom(other: Quaternion): Quaternion;
  12081. /**
  12082. * Updates the current Quaternion from the passed float coordinates.
  12083. * Returns the updated Quaterion.
  12084. */
  12085. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  12086. /**
  12087. * Updates the current Quaternion from the passed float coordinates.
  12088. * Returns the updated Quaterion.
  12089. */
  12090. set(x: number, y: number, z: number, w: number): Quaternion;
  12091. /**
  12092. * Returns a new Quaternion as the addition result of the passed one and the current Quaternion.
  12093. */
  12094. add(other: Quaternion): Quaternion;
  12095. /**
  12096. * Returns a new Quaternion as the subtraction result of the passed one from the current Quaternion.
  12097. */
  12098. subtract(other: Quaternion): Quaternion;
  12099. /**
  12100. * Returns a new Quaternion set by multiplying the current Quaterion coordinates by the float "scale".
  12101. */
  12102. scale(value: number): Quaternion;
  12103. /**
  12104. * Returns a new Quaternion set as the quaternion mulplication result of the current one with the passed one "q1".
  12105. */
  12106. multiply(q1: Quaternion): Quaternion;
  12107. /**
  12108. * Sets the passed "result" as the quaternion mulplication result of the current one with the passed one "q1".
  12109. * Returns the current Quaternion.
  12110. */
  12111. multiplyToRef(q1: Quaternion, result: Quaternion): Quaternion;
  12112. /**
  12113. * Updates the current Quaternion with the quaternion mulplication result of itself with the passed one "q1".
  12114. * Returns the updated Quaternion.
  12115. */
  12116. multiplyInPlace(q1: Quaternion): Quaternion;
  12117. /**
  12118. * Sets the passed "ref" with the conjugation of the current Quaternion.
  12119. * Returns the current Quaternion.
  12120. */
  12121. conjugateToRef(ref: Quaternion): Quaternion;
  12122. /**
  12123. * Conjugates in place the current Quaternion.
  12124. * Returns the updated Quaternion.
  12125. */
  12126. conjugateInPlace(): Quaternion;
  12127. /**
  12128. * Returns a new Quaternion as the conjugate of the current Quaternion.
  12129. */
  12130. conjugate(): Quaternion;
  12131. /**
  12132. * Returns the Quaternion length (float).
  12133. */
  12134. length(): number;
  12135. /**
  12136. * Normalize in place the current Quaternion.
  12137. * Returns the updated Quaternion.
  12138. */
  12139. normalize(): Quaternion;
  12140. /**
  12141. * Returns a new Vector3 set with the Euler angles translated from the current Quaternion.
  12142. */
  12143. toEulerAngles(order?: string): Vector3;
  12144. /**
  12145. * Sets the passed vector3 "result" with the Euler angles translated from the current Quaternion.
  12146. * Returns the current Quaternion.
  12147. */
  12148. toEulerAnglesToRef(result: Vector3, order?: string): Quaternion;
  12149. /**
  12150. * Updates the passed rotation matrix with the current Quaternion values.
  12151. * Returns the current Quaternion.
  12152. */
  12153. toRotationMatrix(result: Matrix): Quaternion;
  12154. /**
  12155. * Updates the current Quaternion from the passed rotation matrix values.
  12156. * Returns the updated Quaternion.
  12157. */
  12158. fromRotationMatrix(matrix: Matrix): Quaternion;
  12159. /**
  12160. * Returns a new Quaternion set from the passed rotation matrix values.
  12161. */
  12162. static FromRotationMatrix(matrix: Matrix): Quaternion;
  12163. /**
  12164. * Updates the passed quaternion "result" with the passed rotation matrix values.
  12165. */
  12166. static FromRotationMatrixToRef(matrix: Matrix, result: Quaternion): void;
  12167. /**
  12168. * Returns a new Quaternion set to (0.0, 0.0, 0.0).
  12169. */
  12170. static Zero(): Quaternion;
  12171. /**
  12172. * Returns a new Quaternion as the inverted current Quaternion.
  12173. */
  12174. static Inverse(q: Quaternion): Quaternion;
  12175. /**
  12176. * Returns the identity Quaternion.
  12177. */
  12178. static Identity(): Quaternion;
  12179. static IsIdentity(quaternion: Quaternion): boolean;
  12180. /**
  12181. * Returns a new Quaternion set from the passed axis (Vector3) and angle in radians (float).
  12182. */
  12183. static RotationAxis(axis: Vector3, angle: number): Quaternion;
  12184. /**
  12185. * Sets the passed quaternion "result" from the passed axis (Vector3) and angle in radians (float).
  12186. */
  12187. static RotationAxisToRef(axis: Vector3, angle: number, result: Quaternion): Quaternion;
  12188. /**
  12189. * Retuns a new Quaternion set from the starting index of the passed array.
  12190. */
  12191. static FromArray(array: ArrayLike<number>, offset?: number): Quaternion;
  12192. /**
  12193. * Returns a new Quaternion set from the passed Euler float angles (y, x, z).
  12194. */
  12195. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  12196. /**
  12197. * Sets the passed quaternion "result" from the passed float Euler angles (y, x, z).
  12198. */
  12199. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  12200. /**
  12201. * Returns a new Quaternion from the passed float Euler angles expressed in z-x-z orientation
  12202. */
  12203. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  12204. /**
  12205. * Sets the passed quaternion "result" from the passed float Euler angles expressed in z-x-z orientation
  12206. */
  12207. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  12208. /**
  12209. * Returns a new Quaternion as the quaternion rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system.
  12210. * cf to Vector3.RotationFromAxis() documentation.
  12211. * Note : axis1, axis2 and axis3 are normalized during this operation.
  12212. */
  12213. static RotationQuaternionFromAxis(axis1: Vector3, axis2: Vector3, axis3: Vector3, ref: Quaternion): Quaternion;
  12214. /**
  12215. * Sets the passed quaternion "ref" with the quaternion rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system.
  12216. * cf to Vector3.RotationFromAxis() documentation.
  12217. * Note : axis1, axis2 and axis3 are normalized during this operation.
  12218. */
  12219. static RotationQuaternionFromAxisToRef(axis1: Vector3, axis2: Vector3, axis3: Vector3, ref: Quaternion): void;
  12220. static Slerp(left: Quaternion, right: Quaternion, amount: number): Quaternion;
  12221. static SlerpToRef(left: Quaternion, right: Quaternion, amount: number, result: Quaternion): void;
  12222. /**
  12223. * Returns a new Quaternion located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2".
  12224. */
  12225. static Hermite(value1: Quaternion, tangent1: Quaternion, value2: Quaternion, tangent2: Quaternion, amount: number): Quaternion;
  12226. }
  12227. class Matrix {
  12228. private static _tempQuaternion;
  12229. private static _xAxis;
  12230. private static _yAxis;
  12231. private static _zAxis;
  12232. private static _updateFlagSeed;
  12233. private static _identityReadOnly;
  12234. private _isIdentity;
  12235. private _isIdentityDirty;
  12236. updateFlag: number;
  12237. m: Float32Array;
  12238. _markAsUpdated(): void;
  12239. constructor();
  12240. /**
  12241. * Boolean : True is the matrix is the identity matrix
  12242. */
  12243. isIdentity(considerAsTextureMatrix?: boolean): boolean;
  12244. /**
  12245. * Returns the matrix determinant (float).
  12246. */
  12247. determinant(): number;
  12248. /**
  12249. * Returns the matrix underlying array.
  12250. */
  12251. toArray(): Float32Array;
  12252. /**
  12253. * Returns the matrix underlying array.
  12254. */
  12255. asArray(): Float32Array;
  12256. /**
  12257. * Inverts in place the Matrix.
  12258. * Returns the Matrix inverted.
  12259. */
  12260. invert(): Matrix;
  12261. /**
  12262. * Sets all the matrix elements to zero.
  12263. * Returns the Matrix.
  12264. */
  12265. reset(): Matrix;
  12266. /**
  12267. * Returns a new Matrix as the addition result of the current Matrix and the passed one.
  12268. */
  12269. add(other: Matrix): Matrix;
  12270. /**
  12271. * Sets the passed matrix "result" with the ddition result of the current Matrix and the passed one.
  12272. * Returns the Matrix.
  12273. */
  12274. addToRef(other: Matrix, result: Matrix): Matrix;
  12275. /**
  12276. * Adds in place the passed matrix to the current Matrix.
  12277. * Returns the updated Matrix.
  12278. */
  12279. addToSelf(other: Matrix): Matrix;
  12280. /**
  12281. * Sets the passed matrix with the current inverted Matrix.
  12282. * Returns the unmodified current Matrix.
  12283. */
  12284. invertToRef(other: Matrix): Matrix;
  12285. /**
  12286. * Inserts the translation vector (using 3 x floats) in the current Matrix.
  12287. * Returns the updated Matrix.
  12288. */
  12289. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  12290. /**
  12291. * Inserts the translation vector in the current Matrix.
  12292. * Returns the updated Matrix.
  12293. */
  12294. setTranslation(vector3: Vector3): Matrix;
  12295. /**
  12296. * Returns a new Vector3 as the extracted translation from the Matrix.
  12297. */
  12298. getTranslation(): Vector3;
  12299. /**
  12300. * Fill a Vector3 with the extracted translation from the Matrix.
  12301. */
  12302. getTranslationToRef(result: Vector3): Matrix;
  12303. /**
  12304. * Remove rotation and scaling part from the Matrix.
  12305. * Returns the updated Matrix.
  12306. */
  12307. removeRotationAndScaling(): Matrix;
  12308. /**
  12309. * Returns a new Matrix set with the multiplication result of the current Matrix and the passed one.
  12310. */
  12311. multiply(other: Matrix): Matrix;
  12312. /**
  12313. * Updates the current Matrix from the passed one values.
  12314. * Returns the updated Matrix.
  12315. */
  12316. copyFrom(other: Matrix): Matrix;
  12317. /**
  12318. * Populates the passed array from the starting index with the Matrix values.
  12319. * Returns the Matrix.
  12320. */
  12321. copyToArray(array: Float32Array, offset?: number): Matrix;
  12322. /**
  12323. * Sets the passed matrix "result" with the multiplication result of the current Matrix and the passed one.
  12324. */
  12325. multiplyToRef(other: Matrix, result: Matrix): Matrix;
  12326. /**
  12327. * Sets the Float32Array "result" from the passed index "offset" with the multiplication result of the current Matrix and the passed one.
  12328. */
  12329. multiplyToArray(other: Matrix, result: Float32Array, offset: number): Matrix;
  12330. /**
  12331. * Boolean : True is the current Matrix and the passed one values are strictly equal.
  12332. */
  12333. equals(value: Matrix): boolean;
  12334. /**
  12335. * Returns a new Matrix from the current Matrix.
  12336. */
  12337. clone(): Matrix;
  12338. /**
  12339. * Returns the string "Matrix"
  12340. */
  12341. getClassName(): string;
  12342. /**
  12343. * Returns the Matrix hash code.
  12344. */
  12345. getHashCode(): number;
  12346. /**
  12347. * Decomposes the current Matrix into :
  12348. * - a scale vector3 passed as a reference to update,
  12349. * - a rotation quaternion passed as a reference to update,
  12350. * - a translation vector3 passed as a reference to update.
  12351. * Returns the true if operation was successful.
  12352. */
  12353. decompose(scale: Vector3, rotation: Quaternion, translation: Vector3): boolean;
  12354. /**
  12355. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  12356. * @param ref matrix to store the result
  12357. */
  12358. toNormalMatrix(ref: Matrix): void;
  12359. /**
  12360. * Returns a new Matrix as the extracted rotation matrix from the current one.
  12361. */
  12362. getRotationMatrix(): Matrix;
  12363. /**
  12364. * Extracts the rotation matrix from the current one and sets it as the passed "result".
  12365. * Returns the current Matrix.
  12366. */
  12367. getRotationMatrixToRef(result: Matrix): Matrix;
  12368. /**
  12369. * Returns a new Matrix set from the starting index of the passed array.
  12370. */
  12371. static FromArray(array: ArrayLike<number>, offset?: number): Matrix;
  12372. /**
  12373. * Sets the passed "result" matrix from the starting index of the passed array.
  12374. */
  12375. static FromArrayToRef(array: ArrayLike<number>, offset: number, result: Matrix): void;
  12376. /**
  12377. * Sets the passed "result" matrix from the starting index of the passed Float32Array by multiplying each element by the float "scale".
  12378. */
  12379. static FromFloat32ArrayToRefScaled(array: Float32Array, offset: number, scale: number, result: Matrix): void;
  12380. /**
  12381. * Sets the passed matrix "result" with the 16 passed floats.
  12382. */
  12383. 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;
  12384. /**
  12385. * Returns the index-th row of the current matrix as a new Vector4.
  12386. */
  12387. getRow(index: number): Nullable<Vector4>;
  12388. /**
  12389. * Sets the index-th row of the current matrix with the passed Vector4 values.
  12390. * Returns the updated Matrix.
  12391. */
  12392. setRow(index: number, row: Vector4): Matrix;
  12393. /**
  12394. * Compute the transpose of the matrix.
  12395. * Returns a new Matrix.
  12396. */
  12397. transpose(): Matrix;
  12398. /**
  12399. * Compute the transpose of the matrix.
  12400. * Returns the current matrix.
  12401. */
  12402. transposeToRef(result: Matrix): Matrix;
  12403. /**
  12404. * Sets the index-th row of the current matrix with the passed 4 x float values.
  12405. * Returns the updated Matrix.
  12406. */
  12407. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  12408. /**
  12409. * Static identity matrix to be used as readonly matrix
  12410. * Must not be updated.
  12411. */
  12412. static readonly IdentityReadOnly: Matrix;
  12413. /**
  12414. * Returns a new Matrix set from the 16 passed floats.
  12415. */
  12416. 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;
  12417. /**
  12418. * Returns a new Matrix composed by the passed scale (vector3), rotation (quaternion) and translation (vector3).
  12419. */
  12420. static Compose(scale: Vector3, rotation: Quaternion, translation: Vector3): Matrix;
  12421. /**
  12422. * Update a Matrix with values composed by the passed scale (vector3), rotation (quaternion) and translation (vector3).
  12423. */
  12424. static ComposeToRef(scale: Vector3, rotation: Quaternion, translation: Vector3, result: Matrix): void;
  12425. /**
  12426. * Returns a new indentity Matrix.
  12427. */
  12428. static Identity(): Matrix;
  12429. /**
  12430. * Sets the passed "result" as an identity matrix.
  12431. */
  12432. static IdentityToRef(result: Matrix): void;
  12433. /**
  12434. * Returns a new zero Matrix.
  12435. */
  12436. static Zero(): Matrix;
  12437. /**
  12438. * Returns a new rotation matrix for "angle" radians around the X axis.
  12439. */
  12440. static RotationX(angle: number): Matrix;
  12441. /**
  12442. * Returns a new Matrix as the passed inverted one.
  12443. */
  12444. static Invert(source: Matrix): Matrix;
  12445. /**
  12446. * Sets the passed matrix "result" as a rotation matrix for "angle" radians around the X axis.
  12447. */
  12448. static RotationXToRef(angle: number, result: Matrix): void;
  12449. /**
  12450. * Returns a new rotation matrix for "angle" radians around the Y axis.
  12451. */
  12452. static RotationY(angle: number): Matrix;
  12453. /**
  12454. * Sets the passed matrix "result" as a rotation matrix for "angle" radians around the Y axis.
  12455. */
  12456. static RotationYToRef(angle: number, result: Matrix): void;
  12457. /**
  12458. * Returns a new rotation matrix for "angle" radians around the Z axis.
  12459. */
  12460. static RotationZ(angle: number): Matrix;
  12461. /**
  12462. * Sets the passed matrix "result" as a rotation matrix for "angle" radians around the Z axis.
  12463. */
  12464. static RotationZToRef(angle: number, result: Matrix): void;
  12465. /**
  12466. * Returns a new rotation matrix for "angle" radians around the passed axis.
  12467. */
  12468. static RotationAxis(axis: Vector3, angle: number): Matrix;
  12469. /**
  12470. * Sets the passed matrix "result" as a rotation matrix for "angle" radians around the passed axis.
  12471. */
  12472. static RotationAxisToRef(axis: Vector3, angle: number, result: Matrix): void;
  12473. /**
  12474. * Returns a new Matrix as a rotation matrix from the Euler angles (y, x, z).
  12475. */
  12476. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  12477. /**
  12478. * Sets the passed matrix "result" as a rotation matrix from the Euler angles (y, x, z).
  12479. */
  12480. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  12481. /**
  12482. * Returns a new Matrix as a scaling matrix from the passed floats (x, y, z).
  12483. */
  12484. static Scaling(x: number, y: number, z: number): Matrix;
  12485. /**
  12486. * Sets the passed matrix "result" as a scaling matrix from the passed floats (x, y, z).
  12487. */
  12488. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  12489. /**
  12490. * Returns a new Matrix as a translation matrix from the passed floats (x, y, z).
  12491. */
  12492. static Translation(x: number, y: number, z: number): Matrix;
  12493. /**
  12494. * Sets the passed matrix "result" as a translation matrix from the passed floats (x, y, z).
  12495. */
  12496. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  12497. /**
  12498. * Returns a new Matrix whose values are the interpolated values for "gradien" (float) between the ones of the matrices "startValue" and "endValue".
  12499. */
  12500. static Lerp(startValue: Matrix, endValue: Matrix, gradient: number): Matrix;
  12501. /**
  12502. * Returns a new Matrix whose values are computed by :
  12503. * - decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices,
  12504. * - interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end,
  12505. * - recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices.
  12506. */
  12507. static DecomposeLerp(startValue: Matrix, endValue: Matrix, gradient: number): Matrix;
  12508. /**
  12509. * Returns a new rotation Matrix used to rotate a mesh so as it looks at the target Vector3, from the eye Vector3, the UP vector3 being orientated like "up".
  12510. * This methods works for a Left-Handed system.
  12511. */
  12512. static LookAtLH(eye: Vector3, target: Vector3, up: Vector3): Matrix;
  12513. /**
  12514. * Sets the passed "result" Matrix as a rotation matrix used to rotate a mesh so as it looks at the target Vector3, from the eye Vector3, the UP vector3 being orientated like "up".
  12515. * This methods works for a Left-Handed system.
  12516. */
  12517. static LookAtLHToRef(eye: Vector3, target: Vector3, up: Vector3, result: Matrix): void;
  12518. /**
  12519. * Returns a new rotation Matrix used to rotate a mesh so as it looks at the target Vector3, from the eye Vector3, the UP vector3 being orientated like "up".
  12520. * This methods works for a Right-Handed system.
  12521. */
  12522. static LookAtRH(eye: Vector3, target: Vector3, up: Vector3): Matrix;
  12523. /**
  12524. * Sets the passed "result" Matrix as a rotation matrix used to rotate a mesh so as it looks at the target Vector3, from the eye Vector3, the UP vector3 being orientated like "up".
  12525. * This methods works for a Left-Handed system.
  12526. */
  12527. static LookAtRHToRef(eye: Vector3, target: Vector3, up: Vector3, result: Matrix): void;
  12528. /**
  12529. * Returns a new Matrix as a left-handed orthographic projection matrix computed from the passed floats : width and height of the projection plane, z near and far limits.
  12530. */
  12531. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  12532. /**
  12533. * Sets the passed matrix "result" as a left-handed orthographic projection matrix computed from the passed floats : width and height of the projection plane, z near and far limits.
  12534. */
  12535. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  12536. /**
  12537. * Returns a new Matrix as a left-handed orthographic projection matrix computed from the passed floats : left, right, top and bottom being the coordinates of the projection plane, z near and far limits.
  12538. */
  12539. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  12540. /**
  12541. * Sets the passed matrix "result" as a left-handed orthographic projection matrix computed from the passed floats : left, right, top and bottom being the coordinates of the projection plane, z near and far limits.
  12542. */
  12543. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  12544. /**
  12545. * Returns a new Matrix as a right-handed orthographic projection matrix computed from the passed floats : left, right, top and bottom being the coordinates of the projection plane, z near and far limits.
  12546. */
  12547. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  12548. /**
  12549. * Sets the passed matrix "result" as a right-handed orthographic projection matrix computed from the passed floats : left, right, top and bottom being the coordinates of the projection plane, z near and far limits.
  12550. */
  12551. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  12552. /**
  12553. * Returns a new Matrix as a left-handed perspective projection matrix computed from the passed floats : width and height of the projection plane, z near and far limits.
  12554. */
  12555. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  12556. /**
  12557. * Returns a new Matrix as a left-handed perspective projection matrix computed from the passed floats : vertical angle of view (fov), width/height ratio (aspect), z near and far limits.
  12558. */
  12559. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  12560. /**
  12561. * Sets the passed matrix "result" as a left-handed perspective projection matrix computed from the passed floats : vertical angle of view (fov), width/height ratio (aspect), z near and far limits.
  12562. */
  12563. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  12564. /**
  12565. * Returns a new Matrix as a right-handed perspective projection matrix computed from the passed floats : vertical angle of view (fov), width/height ratio (aspect), z near and far limits.
  12566. */
  12567. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  12568. /**
  12569. * Sets the passed matrix "result" as a right-handed perspective projection matrix computed from the passed floats : vertical angle of view (fov), width/height ratio (aspect), z near and far limits.
  12570. */
  12571. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  12572. /**
  12573. * Sets the passed matrix "result" as a left-handed perspective projection matrix for WebVR computed from the passed floats : vertical angle of view (fov), width/height ratio (aspect), z near and far limits.
  12574. */
  12575. static PerspectiveFovWebVRToRef(fov: {
  12576. upDegrees: number;
  12577. downDegrees: number;
  12578. leftDegrees: number;
  12579. rightDegrees: number;
  12580. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  12581. /**
  12582. * Returns the final transformation matrix : world * view * projection * viewport
  12583. */
  12584. static GetFinalMatrix(viewport: Viewport, world: Matrix, view: Matrix, projection: Matrix, zmin: number, zmax: number): Matrix;
  12585. /**
  12586. * Returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the passed Matrix.
  12587. */
  12588. static GetAsMatrix2x2(matrix: Matrix): Float32Array;
  12589. /**
  12590. * Returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the passed Matrix.
  12591. */
  12592. static GetAsMatrix3x3(matrix: Matrix): Float32Array;
  12593. /**
  12594. * Compute the transpose of the passed Matrix.
  12595. * Returns a new Matrix.
  12596. */
  12597. static Transpose(matrix: Matrix): Matrix;
  12598. /**
  12599. * Compute the transpose of the passed Matrix and store it in the result matrix.
  12600. */
  12601. static TransposeToRef(matrix: Matrix, result: Matrix): void;
  12602. /**
  12603. * Returns a new Matrix as the reflection matrix across the passed plane.
  12604. */
  12605. static Reflection(plane: Plane): Matrix;
  12606. /**
  12607. * Sets the passed matrix "result" as the reflection matrix across the passed plane.
  12608. */
  12609. static ReflectionToRef(plane: Plane, result: Matrix): void;
  12610. /**
  12611. * Sets the passed matrix "mat" as a rotation matrix composed from the 3 passed left handed axis.
  12612. */
  12613. static FromXYZAxesToRef(xaxis: Vector3, yaxis: Vector3, zaxis: Vector3, result: Matrix): void;
  12614. /**
  12615. * Sets the passed matrix "result" as a rotation matrix according to the passed quaternion.
  12616. */
  12617. static FromQuaternionToRef(quat: Quaternion, result: Matrix): void;
  12618. }
  12619. class Plane {
  12620. normal: Vector3;
  12621. d: number;
  12622. /**
  12623. * Creates a Plane object according to the passed floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  12624. */
  12625. constructor(a: number, b: number, c: number, d: number);
  12626. /**
  12627. * Returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  12628. */
  12629. asArray(): number[];
  12630. /**
  12631. * Returns a new plane copied from the current Plane.
  12632. */
  12633. clone(): Plane;
  12634. /**
  12635. * Returns the string "Plane".
  12636. */
  12637. getClassName(): string;
  12638. /**
  12639. * Returns the Plane hash code.
  12640. */
  12641. getHashCode(): number;
  12642. /**
  12643. * Normalize the current Plane in place.
  12644. * Returns the updated Plane.
  12645. */
  12646. normalize(): Plane;
  12647. /**
  12648. * Returns a new Plane as the result of the transformation of the current Plane by the passed matrix.
  12649. */
  12650. transform(transformation: Matrix): Plane;
  12651. /**
  12652. * Returns the dot product (float) of the point coordinates and the plane normal.
  12653. */
  12654. dotCoordinate(point: Vector3): number;
  12655. /**
  12656. * Updates the current Plane from the plane defined by the three passed points.
  12657. * Returns the updated Plane.
  12658. */
  12659. copyFromPoints(point1: Vector3, point2: Vector3, point3: Vector3): Plane;
  12660. /**
  12661. * Boolean : True is the vector "direction" is the same side than the plane normal.
  12662. */
  12663. isFrontFacingTo(direction: Vector3, epsilon: number): boolean;
  12664. /**
  12665. * Returns the signed distance (float) from the passed point to the Plane.
  12666. */
  12667. signedDistanceTo(point: Vector3): number;
  12668. /**
  12669. * Returns a new Plane from the passed array.
  12670. */
  12671. static FromArray(array: ArrayLike<number>): Plane;
  12672. /**
  12673. * Returns a new Plane defined by the three passed points.
  12674. */
  12675. static FromPoints(point1: Vector3, point2: Vector3, point3: Vector3): Plane;
  12676. /**
  12677. * Returns a new Plane the normal vector to this plane at the passed origin point.
  12678. * Note : the vector "normal" is updated because normalized.
  12679. */
  12680. static FromPositionAndNormal(origin: Vector3, normal: Vector3): Plane;
  12681. /**
  12682. * Returns the signed distance between the plane defined by the normal vector at the "origin"" point and the passed other point.
  12683. */
  12684. static SignedDistanceToPlaneFromPositionAndNormal(origin: Vector3, normal: Vector3, point: Vector3): number;
  12685. }
  12686. class Viewport {
  12687. x: number;
  12688. y: number;
  12689. width: number;
  12690. height: number;
  12691. /**
  12692. * Creates a Viewport object located at (x, y) and sized (width, height).
  12693. */
  12694. constructor(x: number, y: number, width: number, height: number);
  12695. toGlobal(renderWidthOrEngine: number | Engine, renderHeight: number): Viewport;
  12696. /**
  12697. * Returns a new Viewport copied from the current one.
  12698. */
  12699. clone(): Viewport;
  12700. }
  12701. class Frustum {
  12702. /**
  12703. * Returns a new array of 6 Frustum planes computed by the passed transformation matrix.
  12704. */
  12705. static GetPlanes(transform: Matrix): Plane[];
  12706. static GetNearPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  12707. static GetFarPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  12708. static GetLeftPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  12709. static GetRightPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  12710. static GetTopPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  12711. static GetBottomPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  12712. /**
  12713. * Sets the passed array "frustumPlanes" with the 6 Frustum planes computed by the passed transformation matrix.
  12714. */
  12715. static GetPlanesToRef(transform: Matrix, frustumPlanes: Plane[]): void;
  12716. }
  12717. enum Space {
  12718. LOCAL = 0,
  12719. WORLD = 1,
  12720. BONE = 2,
  12721. }
  12722. class Axis {
  12723. static X: Vector3;
  12724. static Y: Vector3;
  12725. static Z: Vector3;
  12726. }
  12727. class BezierCurve {
  12728. /**
  12729. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the passed x1, y1, x2, y2 floats.
  12730. */
  12731. static interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  12732. }
  12733. enum Orientation {
  12734. CW = 0,
  12735. CCW = 1,
  12736. }
  12737. class Angle {
  12738. private _radians;
  12739. /**
  12740. * Creates an Angle object of "radians" radians (float).
  12741. */
  12742. constructor(radians: number);
  12743. /**
  12744. * Returns the Angle value in degrees (float).
  12745. */
  12746. degrees: () => number;
  12747. /**
  12748. * Returns the Angle value in radians (float).
  12749. */
  12750. radians: () => number;
  12751. /**
  12752. * Returns a new Angle object valued with the angle value in radians between the two passed vectors.
  12753. */
  12754. static BetweenTwoPoints(a: Vector2, b: Vector2): Angle;
  12755. /**
  12756. * Returns a new Angle object from the passed float in radians.
  12757. */
  12758. static FromRadians(radians: number): Angle;
  12759. /**
  12760. * Returns a new Angle object from the passed float in degrees.
  12761. */
  12762. static FromDegrees(degrees: number): Angle;
  12763. }
  12764. class Arc2 {
  12765. startPoint: Vector2;
  12766. midPoint: Vector2;
  12767. endPoint: Vector2;
  12768. centerPoint: Vector2;
  12769. radius: number;
  12770. angle: Angle;
  12771. startAngle: Angle;
  12772. orientation: Orientation;
  12773. /**
  12774. * Creates an Arc object from the three passed points : start, middle and end.
  12775. */
  12776. constructor(startPoint: Vector2, midPoint: Vector2, endPoint: Vector2);
  12777. }
  12778. class Path2 {
  12779. private _points;
  12780. private _length;
  12781. closed: boolean;
  12782. /**
  12783. * Creates a Path2 object from the starting 2D coordinates x and y.
  12784. */
  12785. constructor(x: number, y: number);
  12786. /**
  12787. * Adds a new segment until the passed coordinates (x, y) to the current Path2.
  12788. * Returns the updated Path2.
  12789. */
  12790. addLineTo(x: number, y: number): Path2;
  12791. /**
  12792. * 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.
  12793. * Returns the updated Path2.
  12794. */
  12795. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  12796. /**
  12797. * Closes the Path2.
  12798. * Returns the Path2.
  12799. */
  12800. close(): Path2;
  12801. /**
  12802. * Returns the Path2 total length (float).
  12803. */
  12804. length(): number;
  12805. /**
  12806. * Returns the Path2 internal array of points.
  12807. */
  12808. getPoints(): Vector2[];
  12809. /**
  12810. * Returns a new Vector2 located at a percentage of the Path2 total length on this path.
  12811. */
  12812. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  12813. /**
  12814. * Returns a new Path2 starting at the coordinates (x, y).
  12815. */
  12816. static StartingAt(x: number, y: number): Path2;
  12817. }
  12818. class Path3D {
  12819. path: Vector3[];
  12820. private _curve;
  12821. private _distances;
  12822. private _tangents;
  12823. private _normals;
  12824. private _binormals;
  12825. private _raw;
  12826. /**
  12827. * new Path3D(path, normal, raw)
  12828. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  12829. * please read the description in the tutorial : http://doc.babylonjs.com/tutorials/How_to_use_Path3D
  12830. * path : an array of Vector3, the curve axis of the Path3D
  12831. * normal (optional) : Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  12832. * raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  12833. */
  12834. constructor(path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  12835. /**
  12836. * Returns the Path3D array of successive Vector3 designing its curve.
  12837. */
  12838. getCurve(): Vector3[];
  12839. /**
  12840. * Returns an array populated with tangent vectors on each Path3D curve point.
  12841. */
  12842. getTangents(): Vector3[];
  12843. /**
  12844. * Returns an array populated with normal vectors on each Path3D curve point.
  12845. */
  12846. getNormals(): Vector3[];
  12847. /**
  12848. * Returns an array populated with binormal vectors on each Path3D curve point.
  12849. */
  12850. getBinormals(): Vector3[];
  12851. /**
  12852. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  12853. */
  12854. getDistances(): number[];
  12855. /**
  12856. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  12857. * Returns the same object updated.
  12858. */
  12859. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  12860. private _compute(firstNormal);
  12861. private _getFirstNonNullVector(index);
  12862. private _getLastNonNullVector(index);
  12863. private _normalVector(v0, vt, va);
  12864. }
  12865. class Curve3 {
  12866. private _points;
  12867. private _length;
  12868. /**
  12869. * Returns a Curve3 object along a Quadratic Bezier curve : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#quadratic-bezier-curve
  12870. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  12871. * @param v1 (Vector3) the control point
  12872. * @param v2 (Vector3) the end point of the Quadratic Bezier
  12873. * @param nbPoints (integer) the wanted number of points in the curve
  12874. */
  12875. static CreateQuadraticBezier(v0: Vector3, v1: Vector3, v2: Vector3, nbPoints: number): Curve3;
  12876. /**
  12877. * Returns a Curve3 object along a Cubic Bezier curve : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#cubic-bezier-curve
  12878. * @param v0 (Vector3) the origin point of the Cubic Bezier
  12879. * @param v1 (Vector3) the first control point
  12880. * @param v2 (Vector3) the second control point
  12881. * @param v3 (Vector3) the end point of the Cubic Bezier
  12882. * @param nbPoints (integer) the wanted number of points in the curve
  12883. */
  12884. static CreateCubicBezier(v0: Vector3, v1: Vector3, v2: Vector3, v3: Vector3, nbPoints: number): Curve3;
  12885. /**
  12886. * Returns a Curve3 object along a Hermite Spline curve : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#hermite-spline
  12887. * @param p1 (Vector3) the origin point of the Hermite Spline
  12888. * @param t1 (Vector3) the tangent vector at the origin point
  12889. * @param p2 (Vector3) the end point of the Hermite Spline
  12890. * @param t2 (Vector3) the tangent vector at the end point
  12891. * @param nbPoints (integer) the wanted number of points in the curve
  12892. */
  12893. static CreateHermiteSpline(p1: Vector3, t1: Vector3, p2: Vector3, t2: Vector3, nbPoints: number): Curve3;
  12894. /**
  12895. * Returns a Curve3 object along a CatmullRom Spline curve :
  12896. * @param points (array of Vector3) the points the spline must pass through. At least, four points required.
  12897. * @param nbPoints (integer) the wanted number of points between each curve control points.
  12898. */
  12899. static CreateCatmullRomSpline(points: Vector3[], nbPoints: number): Curve3;
  12900. /**
  12901. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  12902. * A Curve3 is designed from a series of successive Vector3.
  12903. * Tuto : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#curve3-object
  12904. */
  12905. constructor(points: Vector3[]);
  12906. /**
  12907. * Returns the Curve3 stored array of successive Vector3
  12908. */
  12909. getPoints(): Vector3[];
  12910. /**
  12911. * Returns the computed length (float) of the curve.
  12912. */
  12913. length(): number;
  12914. /**
  12915. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  12916. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  12917. * curveA and curveB keep unchanged.
  12918. */
  12919. continue(curve: Curve3): Curve3;
  12920. private _computeLength(path);
  12921. }
  12922. class PositionNormalVertex {
  12923. position: Vector3;
  12924. normal: Vector3;
  12925. constructor(position?: Vector3, normal?: Vector3);
  12926. clone(): PositionNormalVertex;
  12927. }
  12928. class PositionNormalTextureVertex {
  12929. position: Vector3;
  12930. normal: Vector3;
  12931. uv: Vector2;
  12932. constructor(position?: Vector3, normal?: Vector3, uv?: Vector2);
  12933. clone(): PositionNormalTextureVertex;
  12934. }
  12935. class Tmp {
  12936. static Color3: Color3[];
  12937. static Vector2: Vector2[];
  12938. static Vector3: Vector3[];
  12939. static Vector4: Vector4[];
  12940. static Quaternion: Quaternion[];
  12941. static Matrix: Matrix[];
  12942. }
  12943. }
  12944. declare module BABYLON {
  12945. class SphericalPolynomial {
  12946. x: Vector3;
  12947. y: Vector3;
  12948. z: Vector3;
  12949. xx: Vector3;
  12950. yy: Vector3;
  12951. zz: Vector3;
  12952. xy: Vector3;
  12953. yz: Vector3;
  12954. zx: Vector3;
  12955. addAmbient(color: Color3): void;
  12956. static getSphericalPolynomialFromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  12957. scale(scale: number): void;
  12958. }
  12959. class SphericalHarmonics {
  12960. L00: Vector3;
  12961. L1_1: Vector3;
  12962. L10: Vector3;
  12963. L11: Vector3;
  12964. L2_2: Vector3;
  12965. L2_1: Vector3;
  12966. L20: Vector3;
  12967. L21: Vector3;
  12968. L22: Vector3;
  12969. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  12970. scale(scale: number): void;
  12971. convertIncidentRadianceToIrradiance(): void;
  12972. convertIrradianceToLambertianRadiance(): void;
  12973. static getsphericalHarmonicsFromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  12974. }
  12975. }
  12976. declare module BABYLON {
  12977. class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  12978. static OCCLUSION_TYPE_NONE: number;
  12979. static OCCLUSION_TYPE_OPTIMISTIC: number;
  12980. static OCCLUSION_TYPE_STRICT: number;
  12981. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  12982. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  12983. static readonly BILLBOARDMODE_NONE: number;
  12984. static readonly BILLBOARDMODE_X: number;
  12985. static readonly BILLBOARDMODE_Y: number;
  12986. static readonly BILLBOARDMODE_Z: number;
  12987. static readonly BILLBOARDMODE_ALL: number;
  12988. private _facetPositions;
  12989. private _facetNormals;
  12990. private _facetPartitioning;
  12991. private _facetNb;
  12992. private _partitioningSubdivisions;
  12993. private _partitioningBBoxRatio;
  12994. private _facetDataEnabled;
  12995. private _facetParameters;
  12996. private _bbSize;
  12997. private _subDiv;
  12998. private _facetDepthSort;
  12999. private _facetDepthSortEnabled;
  13000. private _depthSortedIndices;
  13001. private _depthSortedFacets;
  13002. private _facetDepthSortFunction;
  13003. private _facetDepthSortFrom;
  13004. private _facetDepthSortOrigin;
  13005. private _invertedMatrix;
  13006. /**
  13007. * Read-only : the number of facets in the mesh
  13008. */
  13009. readonly facetNb: number;
  13010. /**
  13011. * The number (integer) of subdivisions per axis in the partioning space
  13012. */
  13013. partitioningSubdivisions: number;
  13014. /**
  13015. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  13016. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box.
  13017. */
  13018. partitioningBBoxRatio: number;
  13019. /**
  13020. * Boolean : must the facet be depth sorted on next call to `updateFacetData()` ?
  13021. * Works only for updatable meshes.
  13022. * Doesn't work with multi-materials.
  13023. */
  13024. mustDepthSortFacets: boolean;
  13025. /**
  13026. * The location (Vector3) where the facet depth sort must be computed from.
  13027. * By default, the active camera position.
  13028. * Used only when facet depth sort is enabled.
  13029. */
  13030. facetDepthSortFrom: Vector3;
  13031. /**
  13032. * Read-only boolean : is the feature facetData enabled ?
  13033. */
  13034. readonly isFacetDataEnabled: boolean;
  13035. _updateNonUniformScalingState(value: boolean): boolean;
  13036. /**
  13037. * An event triggered when this mesh collides with another one
  13038. * @type {BABYLON.Observable}
  13039. */
  13040. onCollideObservable: Observable<AbstractMesh>;
  13041. private _onCollideObserver;
  13042. onCollide: () => void;
  13043. /**
  13044. * An event triggered when the collision's position changes
  13045. * @type {BABYLON.Observable}
  13046. */
  13047. onCollisionPositionChangeObservable: Observable<Vector3>;
  13048. private _onCollisionPositionChangeObserver;
  13049. onCollisionPositionChange: () => void;
  13050. /**
  13051. * An event triggered when material is changed
  13052. * @type {BABYLON.Observable}
  13053. */
  13054. onMaterialChangedObservable: Observable<AbstractMesh>;
  13055. definedFacingForward: boolean;
  13056. /**
  13057. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  13058. * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  13059. * or
  13060. * 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.
  13061. * for more info check WebGl documentations
  13062. */
  13063. occlusionQueryAlgorithmType: number;
  13064. /**
  13065. * 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:
  13066. * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  13067. * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  13068. * 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.
  13069. */
  13070. occlusionType: number;
  13071. /**
  13072. * 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.
  13073. * The default value is -1 which means don't break the query and wait till the result.
  13074. */
  13075. occlusionRetryCount: number;
  13076. private _occlusionInternalRetryCounter;
  13077. protected _isOccluded: boolean;
  13078. /**
  13079. * Property isOccluded : 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.
  13080. */
  13081. isOccluded: boolean;
  13082. private _isOcclusionQueryInProgress;
  13083. /**
  13084. * Flag to check the progress status of the query
  13085. */
  13086. readonly isOcclusionQueryInProgress: boolean;
  13087. private _occlusionQuery;
  13088. private _visibility;
  13089. /**
  13090. * Gets or sets mesh visibility between 0 and 1 (defult is 1)
  13091. */
  13092. /**
  13093. * Gets or sets mesh visibility between 0 and 1 (defult is 1)
  13094. */
  13095. visibility: number;
  13096. alphaIndex: number;
  13097. isVisible: boolean;
  13098. isPickable: boolean;
  13099. showBoundingBox: boolean;
  13100. showSubMeshesBoundingBox: boolean;
  13101. isBlocker: boolean;
  13102. enablePointerMoveEvents: boolean;
  13103. renderingGroupId: number;
  13104. private _material;
  13105. material: Nullable<Material>;
  13106. private _receiveShadows;
  13107. receiveShadows: boolean;
  13108. renderOutline: boolean;
  13109. outlineColor: Color3;
  13110. outlineWidth: number;
  13111. renderOverlay: boolean;
  13112. overlayColor: Color3;
  13113. overlayAlpha: number;
  13114. private _hasVertexAlpha;
  13115. hasVertexAlpha: boolean;
  13116. private _useVertexColors;
  13117. useVertexColors: boolean;
  13118. private _computeBonesUsingShaders;
  13119. computeBonesUsingShaders: boolean;
  13120. private _numBoneInfluencers;
  13121. numBoneInfluencers: number;
  13122. private _applyFog;
  13123. applyFog: boolean;
  13124. useOctreeForRenderingSelection: boolean;
  13125. useOctreeForPicking: boolean;
  13126. useOctreeForCollisions: boolean;
  13127. private _layerMask;
  13128. layerMask: number;
  13129. /**
  13130. * True if the mesh must be rendered in any case.
  13131. */
  13132. alwaysSelectAsActiveMesh: boolean;
  13133. /**
  13134. * This scene's action manager
  13135. * @type {BABYLON.ActionManager}
  13136. */
  13137. actionManager: Nullable<ActionManager>;
  13138. physicsImpostor: Nullable<PhysicsImpostor>;
  13139. private _checkCollisions;
  13140. private _collisionMask;
  13141. private _collisionGroup;
  13142. ellipsoid: Vector3;
  13143. ellipsoidOffset: Vector3;
  13144. private _collider;
  13145. private _oldPositionForCollisions;
  13146. private _diffPositionForCollisions;
  13147. collisionMask: number;
  13148. collisionGroup: number;
  13149. edgesWidth: number;
  13150. edgesColor: Color4;
  13151. _edgesRenderer: Nullable<EdgesRenderer>;
  13152. private _collisionsTransformMatrix;
  13153. private _collisionsScalingMatrix;
  13154. _masterMesh: Nullable<AbstractMesh>;
  13155. _boundingInfo: Nullable<BoundingInfo>;
  13156. _renderId: number;
  13157. subMeshes: SubMesh[];
  13158. _submeshesOctree: Octree<SubMesh>;
  13159. _intersectionsInProgress: AbstractMesh[];
  13160. _unIndexed: boolean;
  13161. _lightSources: Light[];
  13162. readonly _positions: Nullable<Vector3[]>;
  13163. _waitingActions: any;
  13164. _waitingFreezeWorldMatrix: Nullable<boolean>;
  13165. private _skeleton;
  13166. _bonesTransformMatrices: Nullable<Float32Array>;
  13167. skeleton: Nullable<Skeleton>;
  13168. constructor(name: string, scene?: Nullable<Scene>);
  13169. /**
  13170. * Returns the string "AbstractMesh"
  13171. */
  13172. getClassName(): string;
  13173. /**
  13174. * @param {boolean} fullDetails - support for multiple levels of logging within scene loading
  13175. */
  13176. toString(fullDetails?: boolean): string;
  13177. _rebuild(): void;
  13178. _resyncLightSources(): void;
  13179. _resyncLighSource(light: Light): void;
  13180. _removeLightSource(light: Light): void;
  13181. private _markSubMeshesAsDirty(func);
  13182. _markSubMeshesAsLightDirty(): void;
  13183. _markSubMeshesAsAttributesDirty(): void;
  13184. _markSubMeshesAsMiscDirty(): void;
  13185. /**
  13186. * Scaling property : a Vector3 depicting the mesh scaling along each local axis X, Y, Z.
  13187. * Default : (1.0, 1.0, 1.0)
  13188. */
  13189. /**
  13190. * Scaling property : a Vector3 depicting the mesh scaling along each local axis X, Y, Z.
  13191. * Default : (1.0, 1.0, 1.0)
  13192. */
  13193. scaling: Vector3;
  13194. /**
  13195. * Disables the mesh edger rendering mode.
  13196. * Returns the AbstractMesh.
  13197. */
  13198. disableEdgesRendering(): AbstractMesh;
  13199. /**
  13200. * Enables the edge rendering mode on the mesh.
  13201. * This mode makes the mesh edges visible.
  13202. * Returns the AbstractMesh.
  13203. */
  13204. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  13205. /**
  13206. * Returns true if the mesh is blocked. Used by the class Mesh.
  13207. * Returns the boolean `false` by default.
  13208. */
  13209. readonly isBlocked: boolean;
  13210. /**
  13211. * Returns the mesh itself by default, used by the class Mesh.
  13212. * Returned type : AbstractMesh
  13213. */
  13214. getLOD(camera: Camera): AbstractMesh;
  13215. /**
  13216. * Returns 0 by default, used by the class Mesh.
  13217. * Returns an integer.
  13218. */
  13219. getTotalVertices(): number;
  13220. /**
  13221. * Returns null by default, used by the class Mesh.
  13222. * Returned type : integer array
  13223. */
  13224. getIndices(): Nullable<IndicesArray>;
  13225. /**
  13226. * Returns the array of the requested vertex data kind. Used by the class Mesh. Returns null here.
  13227. * Returned type : float array or Float32Array
  13228. */
  13229. getVerticesData(kind: string): Nullable<FloatArray>;
  13230. /**
  13231. * Sets the vertex data of the mesh geometry for the requested `kind`.
  13232. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  13233. * The `data` are either a numeric array either a Float32Array.
  13234. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  13235. * 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).
  13236. * Note that a new underlying VertexBuffer object is created each call.
  13237. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  13238. *
  13239. * Possible `kind` values :
  13240. * - BABYLON.VertexBuffer.PositionKind
  13241. * - BABYLON.VertexBuffer.UVKind
  13242. * - BABYLON.VertexBuffer.UV2Kind
  13243. * - BABYLON.VertexBuffer.UV3Kind
  13244. * - BABYLON.VertexBuffer.UV4Kind
  13245. * - BABYLON.VertexBuffer.UV5Kind
  13246. * - BABYLON.VertexBuffer.UV6Kind
  13247. * - BABYLON.VertexBuffer.ColorKind
  13248. * - BABYLON.VertexBuffer.MatricesIndicesKind
  13249. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  13250. * - BABYLON.VertexBuffer.MatricesWeightsKind
  13251. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  13252. *
  13253. * Returns the Mesh.
  13254. */
  13255. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  13256. /**
  13257. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  13258. * If the mesh has no geometry, it is simply returned as it is.
  13259. * The `data` are either a numeric array either a Float32Array.
  13260. * No new underlying VertexBuffer object is created.
  13261. * 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.
  13262. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  13263. *
  13264. * Possible `kind` values :
  13265. * - BABYLON.VertexBuffer.PositionKind
  13266. * - BABYLON.VertexBuffer.UVKind
  13267. * - BABYLON.VertexBuffer.UV2Kind
  13268. * - BABYLON.VertexBuffer.UV3Kind
  13269. * - BABYLON.VertexBuffer.UV4Kind
  13270. * - BABYLON.VertexBuffer.UV5Kind
  13271. * - BABYLON.VertexBuffer.UV6Kind
  13272. * - BABYLON.VertexBuffer.ColorKind
  13273. * - BABYLON.VertexBuffer.MatricesIndicesKind
  13274. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  13275. * - BABYLON.VertexBuffer.MatricesWeightsKind
  13276. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  13277. *
  13278. * Returns the Mesh.
  13279. */
  13280. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  13281. /**
  13282. * Sets the mesh indices.
  13283. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  13284. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  13285. * This method creates a new index buffer each call.
  13286. * Returns the Mesh.
  13287. */
  13288. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  13289. /** Returns false by default, used by the class Mesh.
  13290. * Returns a boolean
  13291. */
  13292. isVerticesDataPresent(kind: string): boolean;
  13293. /**
  13294. * Returns the mesh BoundingInfo object or creates a new one and returns it if undefined.
  13295. * Returns a BoundingInfo
  13296. */
  13297. getBoundingInfo(): BoundingInfo;
  13298. /**
  13299. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units).
  13300. * @param includeDescendants Take the hierarchy's bounding box instead of the mesh's bounding box.
  13301. */
  13302. normalizeToUnitCube(includeDescendants?: boolean): AbstractMesh;
  13303. /**
  13304. * Sets a mesh new object BoundingInfo.
  13305. * Returns the AbstractMesh.
  13306. */
  13307. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  13308. readonly useBones: boolean;
  13309. _preActivate(): void;
  13310. _preActivateForIntermediateRendering(renderId: number): void;
  13311. _activate(renderId: number): void;
  13312. /**
  13313. * Returns the latest update of the World matrix
  13314. * Returns a Matrix.
  13315. */
  13316. getWorldMatrix(): Matrix;
  13317. /**
  13318. * Returns the latest update of the World matrix determinant.
  13319. */
  13320. protected _getWorldMatrixDeterminant(): number;
  13321. /**
  13322. * Perform relative position change from the point of view of behind the front of the mesh.
  13323. * This is performed taking into account the meshes current rotation, so you do not have to care.
  13324. * Supports definition of mesh facing forward or backward.
  13325. * @param {number} amountRight
  13326. * @param {number} amountUp
  13327. * @param {number} amountForward
  13328. *
  13329. * Returns the AbstractMesh.
  13330. */
  13331. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  13332. /**
  13333. * Calculate relative position change from the point of view of behind the front of the mesh.
  13334. * This is performed taking into account the meshes current rotation, so you do not have to care.
  13335. * Supports definition of mesh facing forward or backward.
  13336. * @param {number} amountRight
  13337. * @param {number} amountUp
  13338. * @param {number} amountForward
  13339. *
  13340. * Returns a new Vector3.
  13341. */
  13342. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  13343. /**
  13344. * Perform relative rotation change from the point of view of behind the front of the mesh.
  13345. * Supports definition of mesh facing forward or backward.
  13346. * @param {number} flipBack
  13347. * @param {number} twirlClockwise
  13348. * @param {number} tiltRight
  13349. *
  13350. * Returns the AbstractMesh.
  13351. */
  13352. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  13353. /**
  13354. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  13355. * Supports definition of mesh facing forward or backward.
  13356. * @param {number} flipBack
  13357. * @param {number} twirlClockwise
  13358. * @param {number} tiltRight
  13359. *
  13360. * Returns a new Vector3.
  13361. */
  13362. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  13363. /**
  13364. * Return the minimum and maximum world vectors of the entire hierarchy under current mesh
  13365. * @param includeDescendants Include bounding info from descendants as well (true by default).
  13366. */
  13367. getHierarchyBoundingVectors(includeDescendants?: boolean): {
  13368. min: Vector3;
  13369. max: Vector3;
  13370. };
  13371. /**
  13372. * Updates the mesh BoundingInfo object and all its children BoundingInfo objects also.
  13373. * Returns the AbstractMesh.
  13374. */
  13375. _updateBoundingInfo(): AbstractMesh;
  13376. /**
  13377. * Update a mesh's children BoundingInfo objects only.
  13378. * Returns the AbstractMesh.
  13379. */
  13380. _updateSubMeshesBoundingInfo(matrix: Matrix): AbstractMesh;
  13381. protected _afterComputeWorldMatrix(): void;
  13382. /**
  13383. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  13384. * A mesh is in the frustum if its bounding box intersects the frustum.
  13385. * Boolean returned.
  13386. */
  13387. isInFrustum(frustumPlanes: Plane[]): boolean;
  13388. /**
  13389. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  13390. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  13391. * Boolean returned.
  13392. */
  13393. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  13394. /**
  13395. * True if the mesh intersects another mesh or a SolidParticle object.
  13396. * 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)
  13397. * includeDescendants can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  13398. * Returns a boolean.
  13399. */
  13400. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  13401. /**
  13402. * Returns true if the passed point (Vector3) is inside the mesh bounding box.
  13403. * Returns a boolean.
  13404. */
  13405. intersectsPoint(point: Vector3): boolean;
  13406. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  13407. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  13408. /**
  13409. * Returns the distance from the mesh to the active camera.
  13410. * Returns a float.
  13411. */
  13412. getDistanceToCamera(camera?: Nullable<Camera>): number;
  13413. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  13414. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  13415. /**
  13416. * Property checkCollisions : Boolean, whether the camera should check the collisions against the mesh.
  13417. * Default `false`.
  13418. */
  13419. checkCollisions: boolean;
  13420. /**
  13421. * Gets Collider object used to compute collisions (not physics)
  13422. */
  13423. readonly collider: Collider;
  13424. moveWithCollisions(displacement: Vector3): AbstractMesh;
  13425. private _onCollisionPositionChange;
  13426. /**
  13427. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  13428. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree.
  13429. * Returns an Octree of submeshes.
  13430. */
  13431. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  13432. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  13433. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  13434. _checkCollision(collider: Collider): AbstractMesh;
  13435. _generatePointsArray(): boolean;
  13436. /**
  13437. * Checks if the passed Ray intersects with the mesh.
  13438. * Returns an object PickingInfo.
  13439. */
  13440. intersects(ray: Ray, fastCheck?: boolean): PickingInfo;
  13441. /**
  13442. * Clones the mesh, used by the class Mesh.
  13443. * Just returns `null` for an AbstractMesh.
  13444. */
  13445. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  13446. /**
  13447. * Disposes all the mesh submeshes.
  13448. * Returns the AbstractMesh.
  13449. */
  13450. releaseSubMeshes(): AbstractMesh;
  13451. /**
  13452. * Disposes the AbstractMesh.
  13453. * By default, all the mesh children are also disposed unless the parameter `doNotRecurse` is set to `true`.
  13454. * Returns nothing.
  13455. */
  13456. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  13457. /**
  13458. * Adds the passed mesh as a child to the current mesh.
  13459. * Returns the AbstractMesh.
  13460. */
  13461. addChild(mesh: AbstractMesh): AbstractMesh;
  13462. /**
  13463. * Removes the passed mesh from the current mesh children list.
  13464. * Returns the AbstractMesh.
  13465. */
  13466. removeChild(mesh: AbstractMesh): AbstractMesh;
  13467. /**
  13468. * Initialize the facet data arrays : facetNormals, facetPositions and facetPartitioning.
  13469. * Returns the AbstractMesh.
  13470. */
  13471. private _initFacetData();
  13472. /**
  13473. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  13474. * This method can be called within the render loop.
  13475. * 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.
  13476. * Returns the AbstractMesh.
  13477. */
  13478. updateFacetData(): AbstractMesh;
  13479. /**
  13480. * Returns the facetLocalNormals array.
  13481. * The normals are expressed in the mesh local space.
  13482. */
  13483. getFacetLocalNormals(): Vector3[];
  13484. /**
  13485. * Returns the facetLocalPositions array.
  13486. * The facet positions are expressed in the mesh local space.
  13487. */
  13488. getFacetLocalPositions(): Vector3[];
  13489. /**
  13490. * Returns the facetLocalPartioning array.
  13491. */
  13492. getFacetLocalPartitioning(): number[][];
  13493. /**
  13494. * Returns the i-th facet position in the world system.
  13495. * This method allocates a new Vector3 per call.
  13496. */
  13497. getFacetPosition(i: number): Vector3;
  13498. /**
  13499. * Sets the reference Vector3 with the i-th facet position in the world system.
  13500. * Returns the AbstractMesh.
  13501. */
  13502. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  13503. /**
  13504. * Returns the i-th facet normal in the world system.
  13505. * This method allocates a new Vector3 per call.
  13506. */
  13507. getFacetNormal(i: number): Vector3;
  13508. /**
  13509. * Sets the reference Vector3 with the i-th facet normal in the world system.
  13510. * Returns the AbstractMesh.
  13511. */
  13512. getFacetNormalToRef(i: number, ref: Vector3): this;
  13513. /**
  13514. * 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).
  13515. */
  13516. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  13517. /**
  13518. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found.
  13519. * If the parameter projected (vector3) is passed, it is set as the (x,y,z) World projection on the facet.
  13520. * If checkFace is 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.
  13521. * If facing and checkFace are true, only the facet "facing" to (x, y, z) are returned : positive dot (x, y, z) * facet position.
  13522. * 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.
  13523. */
  13524. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  13525. /**
  13526. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found.
  13527. * If the parameter projected (vector3) is passed, it is set as the (x,y,z) local projection on the facet.
  13528. * If checkFace is 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.
  13529. * If facing and checkFace are true, only the facet "facing" to (x, y, z) are returned : positive dot (x, y, z) * facet position.
  13530. * 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.
  13531. */
  13532. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  13533. /**
  13534. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  13535. */
  13536. getFacetDataParameters(): any;
  13537. /**
  13538. * Disables the feature FacetData and frees the related memory.
  13539. * Returns the AbstractMesh.
  13540. */
  13541. disableFacetData(): AbstractMesh;
  13542. /**
  13543. * Updates the AbstractMesh indices array. Actually, used by the Mesh object.
  13544. * Returns the mesh.
  13545. */
  13546. updateIndices(indices: IndicesArray): AbstractMesh;
  13547. /**
  13548. * The mesh Geometry. Actually used by the Mesh object.
  13549. * Returns a blank geometry object.
  13550. */
  13551. /**
  13552. * Creates new normals data for the mesh.
  13553. * @param updatable.
  13554. */
  13555. createNormals(updatable: boolean): void;
  13556. /**
  13557. * Align the mesh with a normal.
  13558. * Returns the mesh.
  13559. */
  13560. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  13561. protected checkOcclusionQuery(): void;
  13562. }
  13563. }
  13564. declare module BABYLON {
  13565. class Buffer {
  13566. private _engine;
  13567. private _buffer;
  13568. private _data;
  13569. private _updatable;
  13570. private _strideSize;
  13571. private _instanced;
  13572. constructor(engine: any, data: FloatArray, updatable: boolean, stride: number, postponeInternalCreation?: boolean, instanced?: boolean);
  13573. /**
  13574. * Create a new {BABYLON.VertexBuffer} based on the current buffer
  13575. * @param kind defines the vertex buffer kind (position, normal, etc.)
  13576. * @param offset defines offset in the buffer (0 by default)
  13577. * @param size defines the size in floats of attributes (position is 3 for instance)
  13578. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  13579. * @param instanced defines if the vertex buffer contains indexed data
  13580. * @returns the new vertex buffer
  13581. */
  13582. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean): VertexBuffer;
  13583. isUpdatable(): boolean;
  13584. getData(): Nullable<FloatArray>;
  13585. getBuffer(): Nullable<WebGLBuffer>;
  13586. getStrideSize(): number;
  13587. create(data?: Nullable<FloatArray>): void;
  13588. _rebuild(): void;
  13589. update(data: FloatArray): void;
  13590. updateDirectly(data: Float32Array, offset: number, vertexCount?: number): void;
  13591. dispose(): void;
  13592. }
  13593. }
  13594. declare module BABYLON {
  13595. class CSG {
  13596. private polygons;
  13597. matrix: Matrix;
  13598. position: Vector3;
  13599. rotation: Vector3;
  13600. rotationQuaternion: Nullable<Quaternion>;
  13601. scaling: Vector3;
  13602. static FromMesh(mesh: Mesh): CSG;
  13603. private static FromPolygons(polygons);
  13604. clone(): CSG;
  13605. union(csg: CSG): CSG;
  13606. unionInPlace(csg: CSG): void;
  13607. subtract(csg: CSG): CSG;
  13608. subtractInPlace(csg: CSG): void;
  13609. intersect(csg: CSG): CSG;
  13610. intersectInPlace(csg: CSG): void;
  13611. inverse(): CSG;
  13612. inverseInPlace(): void;
  13613. copyTransformAttributes(csg: CSG): CSG;
  13614. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  13615. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  13616. }
  13617. }
  13618. declare module BABYLON {
  13619. /**
  13620. * Class used to store geometry data (vertex buffers + index buffer)
  13621. */
  13622. class Geometry implements IGetSetVerticesData {
  13623. /**
  13624. * Gets or sets the unique ID of the geometry
  13625. */
  13626. id: string;
  13627. /**
  13628. * Gets the delay loading state of the geometry (none by default which means not delayed)
  13629. */
  13630. delayLoadState: number;
  13631. /**
  13632. * Gets the file containing the data to load when running in delay load state
  13633. */
  13634. delayLoadingFile: Nullable<string>;
  13635. /**
  13636. * Callback called when the geometry is updated
  13637. */
  13638. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  13639. private _scene;
  13640. private _engine;
  13641. private _meshes;
  13642. private _totalVertices;
  13643. private _indices;
  13644. private _vertexBuffers;
  13645. private _isDisposed;
  13646. private _extend;
  13647. private _boundingBias;
  13648. /** @ignore */
  13649. _delayInfo: Array<string>;
  13650. private _indexBuffer;
  13651. private _indexBufferIsUpdatable;
  13652. /** @ignore */
  13653. _boundingInfo: Nullable<BoundingInfo>;
  13654. /** @ignore */
  13655. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  13656. /** @ignore */
  13657. _softwareSkinningRenderId: number;
  13658. private _vertexArrayObjects;
  13659. private _updatable;
  13660. /** @ignore */
  13661. _positions: Nullable<Vector3[]>;
  13662. /**
  13663. * 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
  13664. */
  13665. /**
  13666. * 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
  13667. */
  13668. boundingBias: Vector2;
  13669. /**
  13670. * Static function used to attach a new empty geometry to a mesh
  13671. * @param mesh defines the mesh to attach the geometry to
  13672. * @returns the new {BABYLON.Geometry}
  13673. */
  13674. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  13675. /**
  13676. * Creates a new geometry
  13677. * @param id defines the unique ID
  13678. * @param scene defines the hosting scene
  13679. * @param vertexData defines the {BABYLON.VertexData} used to get geometry data
  13680. * @param updatable defines if geometry must be updatable (false by default)
  13681. * @param mesh defines the mesh that will be associated with the geometry
  13682. */
  13683. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  13684. /**
  13685. * Gets the current extend of the geometry
  13686. */
  13687. readonly extend: {
  13688. minimum: Vector3;
  13689. maximum: Vector3;
  13690. };
  13691. /**
  13692. * Gets the hosting scene
  13693. * @returns the hosting {BABYLON.Scene}
  13694. */
  13695. getScene(): Scene;
  13696. /**
  13697. * Gets the hosting engine
  13698. * @returns the hosting {BABYLON.Engine}
  13699. */
  13700. getEngine(): Engine;
  13701. /**
  13702. * Defines if the geometry is ready to use
  13703. * @returns true if the geometry is ready to be used
  13704. */
  13705. isReady(): boolean;
  13706. /**
  13707. * Gets a value indicating that the geometry should not be serialized
  13708. */
  13709. readonly doNotSerialize: boolean;
  13710. /** @ignore */
  13711. _rebuild(): void;
  13712. /**
  13713. * Affects all gemetry data in one call
  13714. * @param vertexData defines the geometry data
  13715. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  13716. */
  13717. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  13718. /**
  13719. * Set specific vertex data
  13720. * @param kind defines the data kind (Position, normal, etc...)
  13721. * @param data defines the vertex data to use
  13722. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  13723. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  13724. */
  13725. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  13726. /**
  13727. * Removes a specific vertex data
  13728. * @param kind defines the data kind (Position, normal, etc...)
  13729. */
  13730. removeVerticesData(kind: string): void;
  13731. /**
  13732. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  13733. * @param buffer defines the vertex buffer to use
  13734. */
  13735. setVerticesBuffer(buffer: VertexBuffer): void;
  13736. /**
  13737. * Update a specific vertex buffer
  13738. * This function will directly update the underlying WebGLBuffer according to the passed numeric array or Float32Array
  13739. * It will do nothing if the buffer is not updatable
  13740. * @param kind defines the data kind (Position, normal, etc...)
  13741. * @param data defines the data to use
  13742. * @param offset defines the offset in the target buffer where to store the data
  13743. */
  13744. updateVerticesDataDirectly(kind: string, data: Float32Array, offset: number): void;
  13745. /**
  13746. * Update a specific vertex buffer
  13747. * This function will create a new buffer if the current one is not updatable
  13748. * @param kind defines the data kind (Position, normal, etc...)
  13749. * @param data defines the data to use
  13750. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  13751. */
  13752. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  13753. private updateBoundingInfo(updateExtends, data);
  13754. /** @ignore */
  13755. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<WebGLBuffer>): void;
  13756. /**
  13757. * Gets total number of vertices
  13758. * @returns the total number of vertices
  13759. */
  13760. getTotalVertices(): number;
  13761. /**
  13762. * Gets a specific vertex data attached to this geometry
  13763. * @param kind defines the data kind (Position, normal, etc...)
  13764. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  13765. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  13766. * @returns a float array containing vertex data
  13767. */
  13768. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  13769. /**
  13770. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  13771. * @param kind defines the data kind (Position, normal, etc...)
  13772. * @returns true if the vertex buffer with the specified kind is updatable
  13773. */
  13774. isVertexBufferUpdatable(kind: string): boolean;
  13775. /**
  13776. * Gets a specific vertex buffer
  13777. * @param kind defines the data kind (Position, normal, etc...)
  13778. * @returns a {BABYLON.VertexBuffer}
  13779. */
  13780. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  13781. /**
  13782. * Returns all vertex buffers
  13783. * @return an object holding all vertex buffers indexed by kind
  13784. */
  13785. getVertexBuffers(): Nullable<{
  13786. [key: string]: VertexBuffer;
  13787. }>;
  13788. /**
  13789. * Gets a boolean indicating if specific vertex buffer is present
  13790. * @param kind defines the data kind (Position, normal, etc...)
  13791. * @returns true if data is present
  13792. */
  13793. isVerticesDataPresent(kind: string): boolean;
  13794. /**
  13795. * Gets a list of all attached data kinds (Position, normal, etc...)
  13796. * @returns a list of string containing all kinds
  13797. */
  13798. getVerticesDataKinds(): string[];
  13799. /**
  13800. * Update index buffer
  13801. * @param indices defines the indices to store in the index buffer
  13802. * @param offset defines the offset in the target buffer where to store the data
  13803. */
  13804. updateIndices(indices: IndicesArray, offset?: number): void;
  13805. /**
  13806. * Creates a new index buffer
  13807. * @param indices defines the indices to store in the index buffer
  13808. * @param totalVertices defines the total number of vertices (could be null)
  13809. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  13810. */
  13811. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  13812. /**
  13813. * Return the total number of indices
  13814. * @returns the total number of indices
  13815. */
  13816. getTotalIndices(): number;
  13817. /**
  13818. * Gets the index buffer array
  13819. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  13820. * @returns the index buffer array
  13821. */
  13822. getIndices(copyWhenShared?: boolean): Nullable<IndicesArray>;
  13823. /**
  13824. * Gets the index buffer
  13825. * @return the index buffer
  13826. */
  13827. getIndexBuffer(): Nullable<WebGLBuffer>;
  13828. /** @ignore */
  13829. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  13830. /**
  13831. * Release the associated resources for a specific mesh
  13832. * @param mesh defines the source mesh
  13833. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  13834. */
  13835. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  13836. /**
  13837. * Apply current geometry to a given mesh
  13838. * @param mesh defines the mesh to apply geometry to
  13839. */
  13840. applyToMesh(mesh: Mesh): void;
  13841. private updateExtend(data?, stride?);
  13842. private _applyToMesh(mesh);
  13843. private notifyUpdate(kind?);
  13844. /**
  13845. * Load the geometry if it was flagged as delay loaded
  13846. * @param scene defines the hosting scene
  13847. * @param onLoaded defines a callback called when the geometry is loaded
  13848. */
  13849. load(scene: Scene, onLoaded?: () => void): void;
  13850. private _queueLoad(scene, onLoaded?);
  13851. /**
  13852. * Invert the geometry to move from a right handed system to a left handed one.
  13853. */
  13854. toLeftHanded(): void;
  13855. /** @ignore */
  13856. _resetPointsArrayCache(): void;
  13857. /** @ignore */
  13858. _generatePointsArray(): boolean;
  13859. /**
  13860. * Gets a value indicating if the geometry is disposed
  13861. * @returns true if the geometry was disposed
  13862. */
  13863. isDisposed(): boolean;
  13864. private _disposeVertexArrayObjects();
  13865. /**
  13866. * Free all associated resources
  13867. */
  13868. dispose(): void;
  13869. /**
  13870. * Clone the current geometry into a new geometry
  13871. * @param id defines the unique ID of the new geometry
  13872. * @returns a new geometry object
  13873. */
  13874. copy(id: string): Geometry;
  13875. /**
  13876. * Serialize the current geometry info (and not the vertices data) into a JSON object
  13877. * @return a JSON representation of the current geometry data (without the vertices data)
  13878. */
  13879. serialize(): any;
  13880. private toNumberArray(origin);
  13881. /**
  13882. * Serialize all vertices data into a JSON oject
  13883. * @returns a JSON representation of the current geometry data
  13884. */
  13885. serializeVerticeData(): any;
  13886. /**
  13887. * Extracts a clone of a mesh geometry
  13888. * @param mesh defines the source mesh
  13889. * @param id defines the unique ID of the new geometry object
  13890. * @returns the new geometry object
  13891. */
  13892. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  13893. /**
  13894. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  13895. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  13896. * Be aware Math.random() could cause collisions, but:
  13897. * "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"
  13898. * @returns a string containing a new GUID
  13899. */
  13900. static RandomId(): string;
  13901. /** @ignore */
  13902. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  13903. private static _CleanMatricesWeights(parsedGeometry, mesh);
  13904. /**
  13905. * Create a new geometry from persisted data (Using .babylon file format)
  13906. * @param parsedVertexData defines the persisted data
  13907. * @param scene defines the hosting scene
  13908. * @param rootUrl defines the root url to use to load assets (like delayed data)
  13909. * @returns the new geometry object
  13910. */
  13911. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  13912. }
  13913. /**
  13914. * Abstract class used to provide common services for all typed geometries
  13915. */
  13916. class _PrimitiveGeometry extends Geometry {
  13917. private _canBeRegenerated;
  13918. private _beingRegenerated;
  13919. /**
  13920. * Creates a new typed geometry
  13921. * @param id defines the unique ID of the geometry
  13922. * @param scene defines the hosting scene
  13923. * @param _canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  13924. * @param mesh defines the hosting mesh (can be null)
  13925. */
  13926. constructor(id: string, scene: Scene, _canBeRegenerated?: boolean, mesh?: Nullable<Mesh>);
  13927. /**
  13928. * Gets a value indicating if the geometry supports being regenerated with new parameters (false by default)
  13929. * @returns true if the geometry can be regenerated
  13930. */
  13931. canBeRegenerated(): boolean;
  13932. /**
  13933. * If the geometry supports regeneration, the function will recreates the geometry with updated parameter values
  13934. */
  13935. regenerate(): void;
  13936. /**
  13937. * Clone the geometry
  13938. * @param id defines the unique ID of the new geometry
  13939. * @returns the new geometry
  13940. */
  13941. asNewGeometry(id: string): Geometry;
  13942. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  13943. setVerticesData(kind: string, data: FloatArray, updatable?: boolean): void;
  13944. /** @ignore */
  13945. _regenerateVertexData(): VertexData;
  13946. copy(id: string): Geometry;
  13947. serialize(): any;
  13948. }
  13949. /**
  13950. * Creates a ribbon geometry
  13951. * @description See http://doc.babylonjs.com/how_to/ribbon_tutorial, http://doc.babylonjs.com/resources/maths_make_ribbons
  13952. */
  13953. class RibbonGeometry extends _PrimitiveGeometry {
  13954. /**
  13955. * Defines the array of paths to use
  13956. */
  13957. pathArray: Vector3[][];
  13958. /**
  13959. * Defines if the last and first points of each path in your pathArray must be joined
  13960. */
  13961. closeArray: boolean;
  13962. /**
  13963. * Defines if the last and first points of each path in your pathArray must be joined
  13964. */
  13965. closePath: boolean;
  13966. /**
  13967. * Defines the offset between points
  13968. */
  13969. offset: number;
  13970. /**
  13971. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  13972. */
  13973. side: number;
  13974. /**
  13975. * Creates a ribbon geometry
  13976. * @param id defines the unique ID of the geometry
  13977. * @param scene defines the hosting scene
  13978. * @param pathArray defines the array of paths to use
  13979. * @param closeArray defines if the last path and the first path must be joined
  13980. * @param closePath defines if the last and first points of each path in your pathArray must be joined
  13981. * @param offset defines the offset between points
  13982. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  13983. * @param mesh defines the hosting mesh (can be null)
  13984. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  13985. */
  13986. constructor(id: string, scene: Scene,
  13987. /**
  13988. * Defines the array of paths to use
  13989. */
  13990. pathArray: Vector3[][],
  13991. /**
  13992. * Defines if the last and first points of each path in your pathArray must be joined
  13993. */
  13994. closeArray: boolean,
  13995. /**
  13996. * Defines if the last and first points of each path in your pathArray must be joined
  13997. */
  13998. closePath: boolean,
  13999. /**
  14000. * Defines the offset between points
  14001. */
  14002. offset: number, canBeRegenerated?: boolean, mesh?: Mesh,
  14003. /**
  14004. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  14005. */
  14006. side?: number);
  14007. /** @ignore */
  14008. _regenerateVertexData(): VertexData;
  14009. copy(id: string): Geometry;
  14010. }
  14011. /**
  14012. * Creates a box geometry
  14013. * @description see http://doc.babylonjs.com/how_to/set_shapes#box
  14014. */
  14015. class BoxGeometry extends _PrimitiveGeometry {
  14016. /**
  14017. * Defines the zise of the box (width, height and depth are the same)
  14018. */
  14019. size: number;
  14020. /**
  14021. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  14022. */
  14023. side: number;
  14024. /**
  14025. * Creates a box geometry
  14026. * @param id defines the unique ID of the geometry
  14027. * @param scene defines the hosting scene
  14028. * @param size defines the zise of the box (width, height and depth are the same)
  14029. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  14030. * @param mesh defines the hosting mesh (can be null)
  14031. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  14032. */
  14033. constructor(id: string, scene: Scene,
  14034. /**
  14035. * Defines the zise of the box (width, height and depth are the same)
  14036. */
  14037. size: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  14038. /**
  14039. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  14040. */
  14041. side?: number);
  14042. _regenerateVertexData(): VertexData;
  14043. copy(id: string): Geometry;
  14044. serialize(): any;
  14045. static Parse(parsedBox: any, scene: Scene): Nullable<BoxGeometry>;
  14046. }
  14047. /**
  14048. * Creates a sphere geometry
  14049. * @description see http://doc.babylonjs.com/how_to/set_shapes#sphere
  14050. */
  14051. class SphereGeometry extends _PrimitiveGeometry {
  14052. /**
  14053. * Defines the number of segments to use to create the sphere
  14054. */
  14055. segments: number;
  14056. /**
  14057. * Defines the diameter of the sphere
  14058. */
  14059. diameter: number;
  14060. /**
  14061. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  14062. */
  14063. side: number;
  14064. /**
  14065. * Create a new sphere geometry
  14066. * @param id defines the unique ID of the geometry
  14067. * @param scene defines the hosting scene
  14068. * @param segments defines the number of segments to use to create the sphere
  14069. * @param diameter defines the diameter of the sphere
  14070. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  14071. * @param mesh defines the hosting mesh (can be null)
  14072. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  14073. */
  14074. constructor(id: string, scene: Scene,
  14075. /**
  14076. * Defines the number of segments to use to create the sphere
  14077. */
  14078. segments: number,
  14079. /**
  14080. * Defines the diameter of the sphere
  14081. */
  14082. diameter: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  14083. /**
  14084. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  14085. */
  14086. side?: number);
  14087. _regenerateVertexData(): VertexData;
  14088. copy(id: string): Geometry;
  14089. serialize(): any;
  14090. static Parse(parsedSphere: any, scene: Scene): Nullable<SphereGeometry>;
  14091. }
  14092. /**
  14093. * Creates a disc geometry
  14094. * @description see http://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  14095. */
  14096. class DiscGeometry extends _PrimitiveGeometry {
  14097. /**
  14098. * Defines the radius of the disc
  14099. */
  14100. radius: number;
  14101. /**
  14102. * Defines the tesselation factor to apply to the disc
  14103. */
  14104. tessellation: number;
  14105. /**
  14106. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  14107. */
  14108. side: number;
  14109. /**
  14110. * Creates a new disc geometry
  14111. * @param id defines the unique ID of the geometry
  14112. * @param scene defines the hosting scene
  14113. * @param radius defines the radius of the disc
  14114. * @param tessellation defines the tesselation factor to apply to the disc
  14115. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  14116. * @param mesh defines the hosting mesh (can be null)
  14117. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  14118. */
  14119. constructor(id: string, scene: Scene,
  14120. /**
  14121. * Defines the radius of the disc
  14122. */
  14123. radius: number,
  14124. /**
  14125. * Defines the tesselation factor to apply to the disc
  14126. */
  14127. tessellation: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  14128. /**
  14129. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  14130. */
  14131. side?: number);
  14132. _regenerateVertexData(): VertexData;
  14133. copy(id: string): Geometry;
  14134. }
  14135. /**
  14136. * Creates a new cylinder geometry
  14137. * @description see http://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  14138. */
  14139. class CylinderGeometry extends _PrimitiveGeometry {
  14140. /**
  14141. * Defines the height of the cylinder
  14142. */
  14143. height: number;
  14144. /**
  14145. * Defines the diameter of the cylinder's top cap
  14146. */
  14147. diameterTop: number;
  14148. /**
  14149. * Defines the diameter of the cylinder's bottom cap
  14150. */
  14151. diameterBottom: number;
  14152. /**
  14153. * Defines the tessellation factor to apply to the cylinder
  14154. */
  14155. tessellation: number;
  14156. /**
  14157. * Defines the number of subdivisions to apply to the cylinder (1 by default)
  14158. */
  14159. subdivisions: number;
  14160. /**
  14161. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  14162. */
  14163. side: number;
  14164. /**
  14165. * Creates a new cylinder geometry
  14166. * @param id defines the unique ID of the geometry
  14167. * @param scene defines the hosting scene
  14168. * @param height defines the height of the cylinder
  14169. * @param diameterTop defines the diameter of the cylinder's top cap
  14170. * @param diameterBottom defines the diameter of the cylinder's bottom cap
  14171. * @param tessellation defines the tessellation factor to apply to the cylinder (number of radial sides)
  14172. * @param subdivisions defines the number of subdivisions to apply to the cylinder (number of rings) (1 by default)
  14173. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  14174. * @param mesh defines the hosting mesh (can be null)
  14175. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  14176. */
  14177. constructor(id: string, scene: Scene,
  14178. /**
  14179. * Defines the height of the cylinder
  14180. */
  14181. height: number,
  14182. /**
  14183. * Defines the diameter of the cylinder's top cap
  14184. */
  14185. diameterTop: number,
  14186. /**
  14187. * Defines the diameter of the cylinder's bottom cap
  14188. */
  14189. diameterBottom: number,
  14190. /**
  14191. * Defines the tessellation factor to apply to the cylinder
  14192. */
  14193. tessellation: number,
  14194. /**
  14195. * Defines the number of subdivisions to apply to the cylinder (1 by default)
  14196. */
  14197. subdivisions?: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  14198. /**
  14199. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  14200. */
  14201. side?: number);
  14202. _regenerateVertexData(): VertexData;
  14203. copy(id: string): Geometry;
  14204. serialize(): any;
  14205. static Parse(parsedCylinder: any, scene: Scene): Nullable<CylinderGeometry>;
  14206. }
  14207. /**
  14208. * Creates a new torus geometry
  14209. * @description see http://doc.babylonjs.com/how_to/set_shapes#torus
  14210. */
  14211. class TorusGeometry extends _PrimitiveGeometry {
  14212. /**
  14213. * Defines the diameter of the torus
  14214. */
  14215. diameter: number;
  14216. /**
  14217. * Defines the thickness of the torus (ie. internal diameter)
  14218. */
  14219. thickness: number;
  14220. /**
  14221. * Defines the tesselation factor to apply to the torus
  14222. */
  14223. tessellation: number;
  14224. /**
  14225. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  14226. */
  14227. side: number;
  14228. /**
  14229. * Creates a new torus geometry
  14230. * @param id defines the unique ID of the geometry
  14231. * @param scene defines the hosting scene
  14232. * @param diameter defines the diameter of the torus
  14233. * @param thickness defines the thickness of the torus (ie. internal diameter)
  14234. * @param tessellation defines the tesselation factor to apply to the torus (number of segments along the circle)
  14235. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  14236. * @param mesh defines the hosting mesh (can be null)
  14237. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  14238. */
  14239. constructor(id: string, scene: Scene,
  14240. /**
  14241. * Defines the diameter of the torus
  14242. */
  14243. diameter: number,
  14244. /**
  14245. * Defines the thickness of the torus (ie. internal diameter)
  14246. */
  14247. thickness: number,
  14248. /**
  14249. * Defines the tesselation factor to apply to the torus
  14250. */
  14251. tessellation: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  14252. /**
  14253. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  14254. */
  14255. side?: number);
  14256. _regenerateVertexData(): VertexData;
  14257. copy(id: string): Geometry;
  14258. serialize(): any;
  14259. static Parse(parsedTorus: any, scene: Scene): Nullable<TorusGeometry>;
  14260. }
  14261. /**
  14262. * Creates a new ground geometry
  14263. * @description see http://doc.babylonjs.com/how_to/set_shapes#ground
  14264. */
  14265. class GroundGeometry extends _PrimitiveGeometry {
  14266. /**
  14267. * Defines the width of the ground
  14268. */
  14269. width: number;
  14270. /**
  14271. * Defines the height of the ground
  14272. */
  14273. height: number;
  14274. /**
  14275. * Defines the subdivisions to apply to the ground
  14276. */
  14277. subdivisions: number;
  14278. /**
  14279. * Creates a new ground geometry
  14280. * @param id defines the unique ID of the geometry
  14281. * @param scene defines the hosting scene
  14282. * @param width defines the width of the ground
  14283. * @param height defines the height of the ground
  14284. * @param subdivisions defines the subdivisions to apply to the ground
  14285. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  14286. * @param mesh defines the hosting mesh (can be null)
  14287. */
  14288. constructor(id: string, scene: Scene,
  14289. /**
  14290. * Defines the width of the ground
  14291. */
  14292. width: number,
  14293. /**
  14294. * Defines the height of the ground
  14295. */
  14296. height: number,
  14297. /**
  14298. * Defines the subdivisions to apply to the ground
  14299. */
  14300. subdivisions: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>);
  14301. _regenerateVertexData(): VertexData;
  14302. copy(id: string): Geometry;
  14303. serialize(): any;
  14304. static Parse(parsedGround: any, scene: Scene): Nullable<GroundGeometry>;
  14305. }
  14306. /**
  14307. * Creates a tiled ground geometry
  14308. * @description see http://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  14309. */
  14310. class TiledGroundGeometry extends _PrimitiveGeometry {
  14311. /**
  14312. * Defines the minimum value on X axis
  14313. */
  14314. xmin: number;
  14315. /**
  14316. * Defines the minimum value on Z axis
  14317. */
  14318. zmin: number;
  14319. /**
  14320. * Defines the maximum value on X axis
  14321. */
  14322. xmax: number;
  14323. /**
  14324. * Defines the maximum value on Z axis
  14325. */
  14326. zmax: number;
  14327. /**
  14328. * Defines the subdivisions to apply to the ground
  14329. */
  14330. subdivisions: {
  14331. w: number;
  14332. h: number;
  14333. };
  14334. /**
  14335. * Defines the precision to use when computing the tiles
  14336. */
  14337. precision: {
  14338. w: number;
  14339. h: number;
  14340. };
  14341. /**
  14342. * Creates a tiled ground geometry
  14343. * @param id defines the unique ID of the geometry
  14344. * @param scene defines the hosting scene
  14345. * @param xmin defines the minimum value on X axis
  14346. * @param zmin defines the minimum value on Z axis
  14347. * @param xmax defines the maximum value on X axis
  14348. * @param zmax defines the maximum value on Z axis
  14349. * @param subdivisions defines the subdivisions to apply to the ground (number of subdivisions (tiles) on the height and the width of the map)
  14350. * @param precision defines the precision to use when computing the tiles
  14351. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  14352. * @param mesh defines the hosting mesh (can be null)
  14353. */
  14354. constructor(id: string, scene: Scene,
  14355. /**
  14356. * Defines the minimum value on X axis
  14357. */
  14358. xmin: number,
  14359. /**
  14360. * Defines the minimum value on Z axis
  14361. */
  14362. zmin: number,
  14363. /**
  14364. * Defines the maximum value on X axis
  14365. */
  14366. xmax: number,
  14367. /**
  14368. * Defines the maximum value on Z axis
  14369. */
  14370. zmax: number,
  14371. /**
  14372. * Defines the subdivisions to apply to the ground
  14373. */
  14374. subdivisions: {
  14375. w: number;
  14376. h: number;
  14377. },
  14378. /**
  14379. * Defines the precision to use when computing the tiles
  14380. */
  14381. precision: {
  14382. w: number;
  14383. h: number;
  14384. }, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>);
  14385. _regenerateVertexData(): VertexData;
  14386. copy(id: string): Geometry;
  14387. }
  14388. /**
  14389. * Creates a plane geometry
  14390. * @description see http://doc.babylonjs.com/how_to/set_shapes#plane
  14391. */
  14392. class PlaneGeometry extends _PrimitiveGeometry {
  14393. /**
  14394. * Defines the size of the plane (width === height)
  14395. */
  14396. size: number;
  14397. /**
  14398. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  14399. */
  14400. side: number;
  14401. /**
  14402. * Creates a plane geometry
  14403. * @param id defines the unique ID of the geometry
  14404. * @param scene defines the hosting scene
  14405. * @param size defines the size of the plane (width === height)
  14406. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  14407. * @param mesh defines the hosting mesh (can be null)
  14408. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  14409. */
  14410. constructor(id: string, scene: Scene,
  14411. /**
  14412. * Defines the size of the plane (width === height)
  14413. */
  14414. size: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  14415. /**
  14416. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  14417. */
  14418. side?: number);
  14419. _regenerateVertexData(): VertexData;
  14420. copy(id: string): Geometry;
  14421. serialize(): any;
  14422. static Parse(parsedPlane: any, scene: Scene): Nullable<PlaneGeometry>;
  14423. }
  14424. /**
  14425. * Creates a torus knot geometry
  14426. * @description see http://doc.babylonjs.com/how_to/set_shapes#torus-knot
  14427. */
  14428. class TorusKnotGeometry extends _PrimitiveGeometry {
  14429. /**
  14430. * Defines the radius of the torus knot
  14431. */
  14432. radius: number;
  14433. /**
  14434. * Defines the thickness of the torus knot tube
  14435. */
  14436. tube: number;
  14437. /**
  14438. * Defines the number of radial segments
  14439. */
  14440. radialSegments: number;
  14441. /**
  14442. * Defines the number of tubular segments
  14443. */
  14444. tubularSegments: number;
  14445. /**
  14446. * Defines the first number of windings
  14447. */
  14448. p: number;
  14449. /**
  14450. * Defines the second number of windings
  14451. */
  14452. q: number;
  14453. /**
  14454. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  14455. */
  14456. side: number;
  14457. /**
  14458. * Creates a torus knot geometry
  14459. * @param id defines the unique ID of the geometry
  14460. * @param scene defines the hosting scene
  14461. * @param radius defines the radius of the torus knot
  14462. * @param tube defines the thickness of the torus knot tube
  14463. * @param radialSegments defines the number of radial segments
  14464. * @param tubularSegments defines the number of tubular segments
  14465. * @param p defines the first number of windings
  14466. * @param q defines the second number of windings
  14467. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  14468. * @param mesh defines the hosting mesh (can be null)
  14469. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  14470. */
  14471. constructor(id: string, scene: Scene,
  14472. /**
  14473. * Defines the radius of the torus knot
  14474. */
  14475. radius: number,
  14476. /**
  14477. * Defines the thickness of the torus knot tube
  14478. */
  14479. tube: number,
  14480. /**
  14481. * Defines the number of radial segments
  14482. */
  14483. radialSegments: number,
  14484. /**
  14485. * Defines the number of tubular segments
  14486. */
  14487. tubularSegments: number,
  14488. /**
  14489. * Defines the first number of windings
  14490. */
  14491. p: number,
  14492. /**
  14493. * Defines the second number of windings
  14494. */
  14495. q: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  14496. /**
  14497. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  14498. */
  14499. side?: number);
  14500. _regenerateVertexData(): VertexData;
  14501. copy(id: string): Geometry;
  14502. serialize(): any;
  14503. static Parse(parsedTorusKnot: any, scene: Scene): Nullable<TorusKnotGeometry>;
  14504. }
  14505. }
  14506. declare module BABYLON {
  14507. class GroundMesh extends Mesh {
  14508. generateOctree: boolean;
  14509. private _heightQuads;
  14510. _subdivisionsX: number;
  14511. _subdivisionsY: number;
  14512. _width: number;
  14513. _height: number;
  14514. _minX: number;
  14515. _maxX: number;
  14516. _minZ: number;
  14517. _maxZ: number;
  14518. constructor(name: string, scene: Scene);
  14519. getClassName(): string;
  14520. readonly subdivisions: number;
  14521. readonly subdivisionsX: number;
  14522. readonly subdivisionsY: number;
  14523. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  14524. /**
  14525. * Returns a height (y) value in the Worl system :
  14526. * the ground altitude at the coordinates (x, z) expressed in the World system.
  14527. * Returns the ground y position if (x, z) are outside the ground surface.
  14528. */
  14529. getHeightAtCoordinates(x: number, z: number): number;
  14530. /**
  14531. * Returns a normalized vector (Vector3) orthogonal to the ground
  14532. * at the ground coordinates (x, z) expressed in the World system.
  14533. * Returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  14534. */
  14535. getNormalAtCoordinates(x: number, z: number): Vector3;
  14536. /**
  14537. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  14538. * at the ground coordinates (x, z) expressed in the World system.
  14539. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  14540. * Returns the GroundMesh.
  14541. */
  14542. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  14543. /**
  14544. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  14545. * if the ground has been updated.
  14546. * This can be used in the render loop.
  14547. * Returns the GroundMesh.
  14548. */
  14549. updateCoordinateHeights(): GroundMesh;
  14550. private _getFacetAt(x, z);
  14551. private _initHeightQuads();
  14552. private _computeHeightQuads();
  14553. serialize(serializationObject: any): void;
  14554. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  14555. }
  14556. }
  14557. declare module BABYLON {
  14558. /**
  14559. * Creates an instance based on a source mesh.
  14560. */
  14561. class InstancedMesh extends AbstractMesh {
  14562. private _sourceMesh;
  14563. private _currentLOD;
  14564. constructor(name: string, source: Mesh);
  14565. /**
  14566. * Returns the string "InstancedMesh".
  14567. */
  14568. getClassName(): string;
  14569. readonly receiveShadows: boolean;
  14570. readonly material: Nullable<Material>;
  14571. readonly visibility: number;
  14572. readonly skeleton: Nullable<Skeleton>;
  14573. readonly renderingGroupId: number;
  14574. /**
  14575. * Returns the total number of vertices (integer).
  14576. */
  14577. getTotalVertices(): number;
  14578. readonly sourceMesh: Mesh;
  14579. /**
  14580. * Is this node ready to be used/rendered
  14581. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  14582. * @return {boolean} is it ready
  14583. */
  14584. isReady(completeCheck?: boolean): boolean;
  14585. /**
  14586. * Returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  14587. */
  14588. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  14589. /**
  14590. * Sets the vertex data of the mesh geometry for the requested `kind`.
  14591. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  14592. * The `data` are either a numeric array either a Float32Array.
  14593. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  14594. * 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).
  14595. * Note that a new underlying VertexBuffer object is created each call.
  14596. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  14597. *
  14598. * Possible `kind` values :
  14599. * - BABYLON.VertexBuffer.PositionKind
  14600. * - BABYLON.VertexBuffer.UVKind
  14601. * - BABYLON.VertexBuffer.UV2Kind
  14602. * - BABYLON.VertexBuffer.UV3Kind
  14603. * - BABYLON.VertexBuffer.UV4Kind
  14604. * - BABYLON.VertexBuffer.UV5Kind
  14605. * - BABYLON.VertexBuffer.UV6Kind
  14606. * - BABYLON.VertexBuffer.ColorKind
  14607. * - BABYLON.VertexBuffer.MatricesIndicesKind
  14608. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  14609. * - BABYLON.VertexBuffer.MatricesWeightsKind
  14610. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  14611. *
  14612. * Returns the Mesh.
  14613. */
  14614. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  14615. /**
  14616. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  14617. * If the mesh has no geometry, it is simply returned as it is.
  14618. * The `data` are either a numeric array either a Float32Array.
  14619. * No new underlying VertexBuffer object is created.
  14620. * 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.
  14621. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  14622. *
  14623. * Possible `kind` values :
  14624. * - BABYLON.VertexBuffer.PositionKind
  14625. * - BABYLON.VertexBuffer.UVKind
  14626. * - BABYLON.VertexBuffer.UV2Kind
  14627. * - BABYLON.VertexBuffer.UV3Kind
  14628. * - BABYLON.VertexBuffer.UV4Kind
  14629. * - BABYLON.VertexBuffer.UV5Kind
  14630. * - BABYLON.VertexBuffer.UV6Kind
  14631. * - BABYLON.VertexBuffer.ColorKind
  14632. * - BABYLON.VertexBuffer.MatricesIndicesKind
  14633. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  14634. * - BABYLON.VertexBuffer.MatricesWeightsKind
  14635. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  14636. *
  14637. * Returns the Mesh.
  14638. */
  14639. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  14640. /**
  14641. * Sets the mesh indices.
  14642. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  14643. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  14644. * This method creates a new index buffer each call.
  14645. * Returns the Mesh.
  14646. */
  14647. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  14648. /**
  14649. * Boolean : True if the mesh owns the requested kind of data.
  14650. */
  14651. isVerticesDataPresent(kind: string): boolean;
  14652. /**
  14653. * Returns an array of indices (IndicesArray).
  14654. */
  14655. getIndices(): Nullable<IndicesArray>;
  14656. readonly _positions: Nullable<Vector3[]>;
  14657. /**
  14658. * Sets a new updated BoundingInfo to the mesh.
  14659. * Returns the mesh.
  14660. */
  14661. refreshBoundingInfo(): InstancedMesh;
  14662. _preActivate(): InstancedMesh;
  14663. _activate(renderId: number): InstancedMesh;
  14664. /**
  14665. * Returns the current associated LOD AbstractMesh.
  14666. */
  14667. getLOD(camera: Camera): AbstractMesh;
  14668. _syncSubMeshes(): InstancedMesh;
  14669. _generatePointsArray(): boolean;
  14670. /**
  14671. * Creates a new InstancedMesh from the current mesh.
  14672. * - name (string) : the cloned mesh name
  14673. * - newParent (optional Node) : the optional Node to parent the clone to.
  14674. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  14675. *
  14676. * Returns the clone.
  14677. */
  14678. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  14679. /**
  14680. * Disposes the InstancedMesh.
  14681. * Returns nothing.
  14682. */
  14683. dispose(doNotRecurse?: boolean): void;
  14684. }
  14685. }
  14686. declare module BABYLON {
  14687. class LinesMesh extends Mesh {
  14688. useVertexColor: boolean | undefined;
  14689. useVertexAlpha: boolean | undefined;
  14690. color: Color3;
  14691. alpha: number;
  14692. /**
  14693. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  14694. * This margin is expressed in world space coordinates, so its value may vary.
  14695. * Default value is 0.1
  14696. * @returns the intersection Threshold value.
  14697. */
  14698. /**
  14699. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  14700. * This margin is expressed in world space coordinates, so its value may vary.
  14701. * @param value the new threshold to apply
  14702. */
  14703. intersectionThreshold: number;
  14704. private _intersectionThreshold;
  14705. private _colorShader;
  14706. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean, useVertexColor?: boolean | undefined, useVertexAlpha?: boolean | undefined);
  14707. /**
  14708. * Returns the string "LineMesh"
  14709. */
  14710. getClassName(): string;
  14711. material: Material;
  14712. readonly checkCollisions: boolean;
  14713. createInstance(name: string): InstancedMesh;
  14714. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  14715. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  14716. dispose(doNotRecurse?: boolean): void;
  14717. /**
  14718. * Returns a new LineMesh object cloned from the current one.
  14719. */
  14720. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  14721. }
  14722. }
  14723. declare module BABYLON {
  14724. class _InstancesBatch {
  14725. mustReturn: boolean;
  14726. visibleInstances: Nullable<InstancedMesh[]>[];
  14727. renderSelf: boolean[];
  14728. }
  14729. class Mesh extends AbstractMesh implements IGetSetVerticesData {
  14730. static _FRONTSIDE: number;
  14731. static _BACKSIDE: number;
  14732. static _DOUBLESIDE: number;
  14733. static _DEFAULTSIDE: number;
  14734. static _NO_CAP: number;
  14735. static _CAP_START: number;
  14736. static _CAP_END: number;
  14737. static _CAP_ALL: number;
  14738. /**
  14739. * Mesh side orientation : usually the external or front surface
  14740. */
  14741. static readonly FRONTSIDE: number;
  14742. /**
  14743. * Mesh side orientation : usually the internal or back surface
  14744. */
  14745. static readonly BACKSIDE: number;
  14746. /**
  14747. * Mesh side orientation : both internal and external or front and back surfaces
  14748. */
  14749. static readonly DOUBLESIDE: number;
  14750. /**
  14751. * Mesh side orientation : by default, `FRONTSIDE`
  14752. */
  14753. static readonly DEFAULTSIDE: number;
  14754. /**
  14755. * Mesh cap setting : no cap
  14756. */
  14757. static readonly NO_CAP: number;
  14758. /**
  14759. * Mesh cap setting : one cap at the beginning of the mesh
  14760. */
  14761. static readonly CAP_START: number;
  14762. /**
  14763. * Mesh cap setting : one cap at the end of the mesh
  14764. */
  14765. static readonly CAP_END: number;
  14766. /**
  14767. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  14768. */
  14769. static readonly CAP_ALL: number;
  14770. /**
  14771. * An event triggered before rendering the mesh
  14772. * @type {BABYLON.Observable}
  14773. */
  14774. onBeforeRenderObservable: Observable<Mesh>;
  14775. /**
  14776. * An event triggered after rendering the mesh
  14777. * @type {BABYLON.Observable}
  14778. */
  14779. onAfterRenderObservable: Observable<Mesh>;
  14780. /**
  14781. * An event triggered before drawing the mesh
  14782. * @type {BABYLON.Observable}
  14783. */
  14784. onBeforeDrawObservable: Observable<Mesh>;
  14785. private _onBeforeDrawObserver;
  14786. onBeforeDraw: () => void;
  14787. delayLoadState: number;
  14788. instances: InstancedMesh[];
  14789. delayLoadingFile: string;
  14790. _binaryInfo: any;
  14791. private _LODLevels;
  14792. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Mesh) => void;
  14793. private _morphTargetManager;
  14794. morphTargetManager: Nullable<MorphTargetManager>;
  14795. _geometry: Nullable<Geometry>;
  14796. _delayInfo: Array<string>;
  14797. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  14798. _visibleInstances: any;
  14799. private _renderIdForInstances;
  14800. private _batchCache;
  14801. private _instancesBufferSize;
  14802. private _instancesBuffer;
  14803. private _instancesData;
  14804. private _overridenInstanceCount;
  14805. private _effectiveMaterial;
  14806. _shouldGenerateFlatShading: boolean;
  14807. private _preActivateId;
  14808. _originalBuilderSideOrientation: number;
  14809. overrideMaterialSideOrientation: Nullable<number>;
  14810. private _areNormalsFrozen;
  14811. private _sourcePositions;
  14812. private _sourceNormals;
  14813. private _source;
  14814. readonly source: Nullable<Mesh>;
  14815. isUnIndexed: boolean;
  14816. /**
  14817. * @constructor
  14818. * @param {string} name The value used by scene.getMeshByName() to do a lookup.
  14819. * @param {Scene} scene The scene to add this mesh to.
  14820. * @param {Node} parent The parent of this mesh, if it has one
  14821. * @param {Mesh} source An optional Mesh from which geometry is shared, cloned.
  14822. * @param {boolean} doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  14823. * When false, achieved by calling a clone(), also passing False.
  14824. * This will make creation of children, recursive.
  14825. * @param {boolean} clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  14826. */
  14827. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  14828. /**
  14829. * Returns the string "Mesh".
  14830. */
  14831. getClassName(): string;
  14832. /**
  14833. * Returns a string.
  14834. * @param {boolean} fullDetails - support for multiple levels of logging within scene loading
  14835. */
  14836. toString(fullDetails?: boolean): string;
  14837. /**
  14838. * True if the mesh has some Levels Of Details (LOD).
  14839. * Returns a boolean.
  14840. */
  14841. readonly hasLODLevels: boolean;
  14842. /**
  14843. * Gets the list of {BABYLON.MeshLODLevel} associated with the current mesh
  14844. * @returns an array of {BABYLON.MeshLODLevel}
  14845. */
  14846. getLODLevels(): MeshLODLevel[];
  14847. private _sortLODLevels();
  14848. /**
  14849. * Add a mesh as LOD level triggered at the given distance.
  14850. * tuto : http://doc.babylonjs.com/tutorials/How_to_use_LOD
  14851. * @param {number} distance The distance from the center of the object to show this level
  14852. * @param {Mesh} mesh The mesh to be added as LOD level
  14853. * @return {Mesh} This mesh (for chaining)
  14854. */
  14855. addLODLevel(distance: number, mesh: Mesh): Mesh;
  14856. /**
  14857. * Returns the LOD level mesh at the passed distance or null if not found.
  14858. * It is related to the method `addLODLevel(distance, mesh)`.
  14859. * tuto : http://doc.babylonjs.com/tutorials/How_to_use_LOD
  14860. * Returns an object Mesh or `null`.
  14861. */
  14862. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  14863. /**
  14864. * Remove a mesh from the LOD array
  14865. * tuto : http://doc.babylonjs.com/tutorials/How_to_use_LOD
  14866. * @param {Mesh} mesh The mesh to be removed.
  14867. * @return {Mesh} This mesh (for chaining)
  14868. */
  14869. removeLODLevel(mesh: Mesh): Mesh;
  14870. /**
  14871. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  14872. * tuto : http://doc.babylonjs.com/tutorials/How_to_use_LOD
  14873. */
  14874. getLOD(camera: Camera, boundingSphere?: BoundingSphere): AbstractMesh;
  14875. /**
  14876. * Returns the mesh internal Geometry object.
  14877. */
  14878. readonly geometry: Nullable<Geometry>;
  14879. /**
  14880. * Returns a positive integer : the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  14881. */
  14882. getTotalVertices(): number;
  14883. /**
  14884. * Returns an array of integers or floats, or a Float32Array, depending on the requested `kind` (positions, indices, normals, etc).
  14885. * 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.
  14886. * You can force the copy with forceCopy === true
  14887. * Returns null if the mesh has no geometry or no vertex buffer.
  14888. * Possible `kind` values :
  14889. * - BABYLON.VertexBuffer.PositionKind
  14890. * - BABYLON.VertexBuffer.UVKind
  14891. * - BABYLON.VertexBuffer.UV2Kind
  14892. * - BABYLON.VertexBuffer.UV3Kind
  14893. * - BABYLON.VertexBuffer.UV4Kind
  14894. * - BABYLON.VertexBuffer.UV5Kind
  14895. * - BABYLON.VertexBuffer.UV6Kind
  14896. * - BABYLON.VertexBuffer.ColorKind
  14897. * - BABYLON.VertexBuffer.MatricesIndicesKind
  14898. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  14899. * - BABYLON.VertexBuffer.MatricesWeightsKind
  14900. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  14901. */
  14902. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  14903. /**
  14904. * Returns the mesh VertexBuffer object from the requested `kind` : positions, indices, normals, etc.
  14905. * Returns `null` if the mesh has no geometry.
  14906. * Possible `kind` values :
  14907. * - BABYLON.VertexBuffer.PositionKind
  14908. * - BABYLON.VertexBuffer.UVKind
  14909. * - BABYLON.VertexBuffer.UV2Kind
  14910. * - BABYLON.VertexBuffer.UV3Kind
  14911. * - BABYLON.VertexBuffer.UV4Kind
  14912. * - BABYLON.VertexBuffer.UV5Kind
  14913. * - BABYLON.VertexBuffer.UV6Kind
  14914. * - BABYLON.VertexBuffer.ColorKind
  14915. * - BABYLON.VertexBuffer.MatricesIndicesKind
  14916. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  14917. * - BABYLON.VertexBuffer.MatricesWeightsKind
  14918. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  14919. */
  14920. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  14921. /**
  14922. * Returns a boolean depending on the existence of the Vertex Data for the requested `kind`.
  14923. * Possible `kind` values :
  14924. * - BABYLON.VertexBuffer.PositionKind
  14925. * - BABYLON.VertexBuffer.UVKind
  14926. * - BABYLON.VertexBuffer.UV2Kind
  14927. * - BABYLON.VertexBuffer.UV3Kind
  14928. * - BABYLON.VertexBuffer.UV4Kind
  14929. * - BABYLON.VertexBuffer.UV5Kind
  14930. * - BABYLON.VertexBuffer.UV6Kind
  14931. * - BABYLON.VertexBuffer.ColorKind
  14932. * - BABYLON.VertexBuffer.MatricesIndicesKind
  14933. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  14934. * - BABYLON.VertexBuffer.MatricesWeightsKind
  14935. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  14936. */
  14937. isVerticesDataPresent(kind: string): boolean;
  14938. /**
  14939. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  14940. * Possible `kind` values :
  14941. * - BABYLON.VertexBuffer.PositionKind
  14942. * - BABYLON.VertexBuffer.UVKind
  14943. * - BABYLON.VertexBuffer.UV2Kind
  14944. * - BABYLON.VertexBuffer.UV3Kind
  14945. * - BABYLON.VertexBuffer.UV4Kind
  14946. * - BABYLON.VertexBuffer.UV5Kind
  14947. * - BABYLON.VertexBuffer.UV6Kind
  14948. * - BABYLON.VertexBuffer.ColorKind
  14949. * - BABYLON.VertexBuffer.MatricesIndicesKind
  14950. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  14951. * - BABYLON.VertexBuffer.MatricesWeightsKind
  14952. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  14953. */
  14954. isVertexBufferUpdatable(kind: string): boolean;
  14955. /**
  14956. * Returns a string : the list of existing `kinds` of Vertex Data for this mesh.
  14957. * Possible `kind` values :
  14958. * - BABYLON.VertexBuffer.PositionKind
  14959. * - BABYLON.VertexBuffer.UVKind
  14960. * - BABYLON.VertexBuffer.UV2Kind
  14961. * - BABYLON.VertexBuffer.UV3Kind
  14962. * - BABYLON.VertexBuffer.UV4Kind
  14963. * - BABYLON.VertexBuffer.UV5Kind
  14964. * - BABYLON.VertexBuffer.UV6Kind
  14965. * - BABYLON.VertexBuffer.ColorKind
  14966. * - BABYLON.VertexBuffer.MatricesIndicesKind
  14967. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  14968. * - BABYLON.VertexBuffer.MatricesWeightsKind
  14969. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  14970. */
  14971. getVerticesDataKinds(): string[];
  14972. /**
  14973. * Returns a positive integer : the total number of indices in this mesh geometry.
  14974. * Returns zero if the mesh has no geometry.
  14975. */
  14976. getTotalIndices(): number;
  14977. /**
  14978. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  14979. * 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.
  14980. * Returns an empty array if the mesh has no geometry.
  14981. */
  14982. getIndices(copyWhenShared?: boolean): Nullable<IndicesArray>;
  14983. readonly isBlocked: boolean;
  14984. /**
  14985. * Determine if the current mesh is ready to be rendered
  14986. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  14987. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  14988. * @returns true if all associated assets are ready (material, textures, shaders)
  14989. */
  14990. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  14991. /**
  14992. * Boolean : true if the normals aren't to be recomputed on next mesh `positions` array update.
  14993. * This property is pertinent only for updatable parametric shapes.
  14994. */
  14995. readonly areNormalsFrozen: boolean;
  14996. /**
  14997. * This function affects parametric shapes on vertex position update only : ribbons, tubes, etc.
  14998. * It has no effect at all on other shapes.
  14999. * It prevents the mesh normals from being recomputed on next `positions` array update.
  15000. * Returns the Mesh.
  15001. */
  15002. freezeNormals(): Mesh;
  15003. /**
  15004. * This function affects parametric shapes on vertex position update only : ribbons, tubes, etc.
  15005. * It has no effect at all on other shapes.
  15006. * It reactivates the mesh normals computation if it was previously frozen.
  15007. * Returns the Mesh.
  15008. */
  15009. unfreezeNormals(): Mesh;
  15010. /**
  15011. * Overrides instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  15012. */
  15013. overridenInstanceCount: number;
  15014. _preActivate(): Mesh;
  15015. _preActivateForIntermediateRendering(renderId: number): Mesh;
  15016. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  15017. /**
  15018. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  15019. * This means the mesh underlying bounding box and sphere are recomputed.
  15020. * Returns the Mesh.
  15021. */
  15022. refreshBoundingInfo(): Mesh;
  15023. _refreshBoundingInfo(applySkeleton: boolean): Mesh;
  15024. private _getPositionData(applySkeleton);
  15025. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  15026. subdivide(count: number): void;
  15027. /**
  15028. * Sets the vertex data of the mesh geometry for the requested `kind`.
  15029. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  15030. * The `data` are either a numeric array either a Float32Array.
  15031. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  15032. * 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).
  15033. * Note that a new underlying VertexBuffer object is created each call.
  15034. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  15035. *
  15036. * Possible `kind` values :
  15037. * - BABYLON.VertexBuffer.PositionKind
  15038. * - BABYLON.VertexBuffer.UVKind
  15039. * - BABYLON.VertexBuffer.UV2Kind
  15040. * - BABYLON.VertexBuffer.UV3Kind
  15041. * - BABYLON.VertexBuffer.UV4Kind
  15042. * - BABYLON.VertexBuffer.UV5Kind
  15043. * - BABYLON.VertexBuffer.UV6Kind
  15044. * - BABYLON.VertexBuffer.ColorKind
  15045. * - BABYLON.VertexBuffer.MatricesIndicesKind
  15046. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  15047. * - BABYLON.VertexBuffer.MatricesWeightsKind
  15048. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  15049. *
  15050. * Returns the Mesh.
  15051. */
  15052. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  15053. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  15054. /**
  15055. * Sets the mesh VertexBuffer.
  15056. * Returns the Mesh.
  15057. */
  15058. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  15059. /**
  15060. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  15061. * If the mesh has no geometry, it is simply returned as it is.
  15062. * The `data` are either a numeric array either a Float32Array.
  15063. * No new underlying VertexBuffer object is created.
  15064. * 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.
  15065. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  15066. *
  15067. * Possible `kind` values :
  15068. * - BABYLON.VertexBuffer.PositionKind
  15069. * - BABYLON.VertexBuffer.UVKind
  15070. * - BABYLON.VertexBuffer.UV2Kind
  15071. * - BABYLON.VertexBuffer.UV3Kind
  15072. * - BABYLON.VertexBuffer.UV4Kind
  15073. * - BABYLON.VertexBuffer.UV5Kind
  15074. * - BABYLON.VertexBuffer.UV6Kind
  15075. * - BABYLON.VertexBuffer.ColorKind
  15076. * - BABYLON.VertexBuffer.MatricesIndicesKind
  15077. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  15078. * - BABYLON.VertexBuffer.MatricesWeightsKind
  15079. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  15080. *
  15081. * Returns the Mesh.
  15082. */
  15083. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  15084. /**
  15085. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  15086. * tuto : http://doc.babylonjs.com/tutorials/How_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  15087. * The parameter `positionFunction` is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything.
  15088. * The parameter `computeNormals` is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update.
  15089. * Returns the Mesh.
  15090. */
  15091. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  15092. /**
  15093. * Creates a un-shared specific occurence of the geometry for the mesh.
  15094. * Returns the Mesh.
  15095. */
  15096. makeGeometryUnique(): Mesh;
  15097. /**
  15098. * Sets the mesh indices.
  15099. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  15100. * Type is Uint16Array by default unless the mesh has more than 65536 vertices.
  15101. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  15102. * This method creates a new index buffer each call.
  15103. * Returns the Mesh.
  15104. */
  15105. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  15106. /**
  15107. * Update the current index buffer
  15108. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  15109. * Returns the Mesh.
  15110. */
  15111. updateIndices(indices: IndicesArray, offset?: number): Mesh;
  15112. /**
  15113. * Invert the geometry to move from a right handed system to a left handed one.
  15114. * Returns the Mesh.
  15115. */
  15116. toLeftHanded(): Mesh;
  15117. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  15118. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number, alternate?: boolean): Mesh;
  15119. /**
  15120. * Registers for this mesh a javascript function called just before the rendering process.
  15121. * This function is passed the current mesh.
  15122. * Return the Mesh.
  15123. */
  15124. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  15125. /**
  15126. * Disposes a previously registered javascript function called before the rendering.
  15127. * This function is passed the current mesh.
  15128. * Returns the Mesh.
  15129. */
  15130. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  15131. /**
  15132. * Registers for this mesh a javascript function called just after the rendering is complete.
  15133. * This function is passed the current mesh.
  15134. * Returns the Mesh.
  15135. */
  15136. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  15137. /**
  15138. * Disposes a previously registered javascript function called after the rendering.
  15139. * This function is passed the current mesh.
  15140. * Return the Mesh.
  15141. */
  15142. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  15143. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  15144. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  15145. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  15146. /**
  15147. * Triggers the draw call for the mesh.
  15148. * Usually, you don't need to call this method by your own because the mesh rendering is handled by the scene rendering manager.
  15149. * Returns the Mesh.
  15150. */
  15151. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  15152. private _onBeforeDraw(isInstance, world, effectiveMaterial?);
  15153. /**
  15154. * Returns an array populated with ParticleSystem objects whose the mesh is the emitter.
  15155. */
  15156. getEmittedParticleSystems(): IParticleSystem[];
  15157. /**
  15158. * Returns an array populated with ParticleSystem objects whose the mesh or its children are the emitter.
  15159. */
  15160. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  15161. _checkDelayState(): Mesh;
  15162. private _queueLoad(scene);
  15163. /**
  15164. * Boolean, true is the mesh in the frustum defined by the Plane objects from the `frustumPlanes` array parameter.
  15165. */
  15166. isInFrustum(frustumPlanes: Plane[]): boolean;
  15167. /**
  15168. * Sets the mesh material by the material or multiMaterial `id` property.
  15169. * The material `id` is a string identifying the material or the multiMaterial.
  15170. * This method returns the Mesh.
  15171. */
  15172. setMaterialByID(id: string): Mesh;
  15173. /**
  15174. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  15175. */
  15176. getAnimatables(): IAnimatable[];
  15177. /**
  15178. * Modifies the mesh geometry according to the passed transformation matrix.
  15179. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  15180. * The mesh normals are modified accordingly the same transformation.
  15181. * tuto : http://doc.babylonjs.com/tutorials/How_Rotations_and_Translations_Work#baking-transform
  15182. * Note that, under the hood, this method sets a new VertexBuffer each call.
  15183. * Returns the Mesh.
  15184. */
  15185. bakeTransformIntoVertices(transform: Matrix): Mesh;
  15186. /**
  15187. * Modifies the mesh geometry according to its own current World Matrix.
  15188. * The mesh World Matrix is then reset.
  15189. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  15190. * tuto : tuto : http://doc.babylonjs.com/resources/baking_transformations
  15191. * Note that, under the hood, this method sets a new VertexBuffer each call.
  15192. * Returns the Mesh.
  15193. */
  15194. bakeCurrentTransformIntoVertices(): Mesh;
  15195. readonly _positions: Nullable<Vector3[]>;
  15196. _resetPointsArrayCache(): Mesh;
  15197. _generatePointsArray(): boolean;
  15198. /**
  15199. * Returns a new Mesh object generated from the current mesh properties.
  15200. * This method must not get confused with createInstance().
  15201. * The parameter `name` is a string, the name given to the new mesh.
  15202. * The optional parameter `newParent` can be any Node object (default `null`).
  15203. * The optional parameter `doNotCloneChildren` (default `false`) allows/denies the recursive cloning of the original mesh children if any.
  15204. * 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.
  15205. */
  15206. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  15207. /**
  15208. * Disposes the Mesh.
  15209. * By default, all the mesh children are also disposed unless the parameter `doNotRecurse` is set to `true`.
  15210. * Returns nothing.
  15211. */
  15212. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  15213. /**
  15214. * Modifies the mesh geometry according to a displacement map.
  15215. * 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.
  15216. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  15217. * This method returns nothing.
  15218. * The parameter `url` is a string, the URL from the image file is to be downloaded.
  15219. * The parameters `minHeight` and `maxHeight` are the lower and upper limits of the displacement.
  15220. * 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.
  15221. * The parameter `uvOffset` is an optional vector2 used to offset UV.
  15222. * The parameter `uvScale` is an optional vector2 used to scale UV.
  15223. *
  15224. * Returns the Mesh.
  15225. */
  15226. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2): Mesh;
  15227. /**
  15228. * Modifies the mesh geometry according to a displacementMap buffer.
  15229. * 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.
  15230. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  15231. * This method returns nothing.
  15232. * 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.
  15233. * The parameters `heightMapWidth` and `heightMapHeight` are positive integers to set the width and height of the buffer image.
  15234. * The parameters `minHeight` and `maxHeight` are the lower and upper limits of the displacement.
  15235. * The parameter `uvOffset` is an optional vector2 used to offset UV.
  15236. * The parameter `uvScale` is an optional vector2 used to scale UV.
  15237. *
  15238. * Returns the Mesh.
  15239. */
  15240. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2): Mesh;
  15241. /**
  15242. * Modify the mesh to get a flat shading rendering.
  15243. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  15244. * This method returns the Mesh.
  15245. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  15246. */
  15247. convertToFlatShadedMesh(): Mesh;
  15248. /**
  15249. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  15250. * In other words, more vertices, no more indices and a single bigger VBO.
  15251. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  15252. * Returns the Mesh.
  15253. */
  15254. convertToUnIndexedMesh(): Mesh;
  15255. /**
  15256. * Inverses facet orientations and inverts also the normals with `flipNormals` (default `false`) if true.
  15257. * This method returns the Mesh.
  15258. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  15259. */
  15260. flipFaces(flipNormals?: boolean): Mesh;
  15261. /**
  15262. * Creates a new InstancedMesh object from the mesh model.
  15263. * An instance shares the same properties and the same material than its model.
  15264. * Only these properties of each instance can then be set individually :
  15265. * - position
  15266. * - rotation
  15267. * - rotationQuaternion
  15268. * - setPivotMatrix
  15269. * - scaling
  15270. * tuto : http://doc.babylonjs.com/tutorials/How_to_use_Instances
  15271. * Warning : this method is not supported for Line mesh and LineSystem
  15272. */
  15273. createInstance(name: string): InstancedMesh;
  15274. /**
  15275. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  15276. * After this call, all the mesh instances have the same submeshes than the current mesh.
  15277. * This method returns the Mesh.
  15278. */
  15279. synchronizeInstances(): Mesh;
  15280. /**
  15281. * Simplify the mesh according to the given array of settings.
  15282. * Function will return immediately and will simplify async. It returns the Mesh.
  15283. * @param settings a collection of simplification settings.
  15284. * @param parallelProcessing should all levels calculate parallel or one after the other.
  15285. * @param type the type of simplification to run.
  15286. * @param successCallback optional success callback to be called after the simplification finished processing all settings.
  15287. */
  15288. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  15289. /**
  15290. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  15291. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  15292. * This should be used together with the simplification to avoid disappearing triangles.
  15293. * Returns the Mesh.
  15294. * @param successCallback an optional success callback to be called after the optimization finished.
  15295. */
  15296. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  15297. serialize(serializationObject: any): void;
  15298. _syncGeometryWithMorphTargetManager(): void;
  15299. /**
  15300. * Returns a new Mesh object parsed from the source provided.
  15301. * The parameter `parsedMesh` is the source.
  15302. * The parameter `rootUrl` is a string, it's the root URL to prefix the `delayLoadingFile` property with
  15303. */
  15304. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  15305. /**
  15306. * Creates a ribbon mesh.
  15307. * Please consider using the same method from the MeshBuilder class instead.
  15308. * 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.
  15309. *
  15310. * Please read this full tutorial to understand how to design a ribbon : http://doc.babylonjs.com/tutorials/Ribbon_Tutorial
  15311. * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  15312. * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array.
  15313. * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array.
  15314. * 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.
  15315. * 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.
  15316. * 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
  15317. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  15318. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  15319. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  15320. */
  15321. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean | undefined, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  15322. /**
  15323. * Creates a plane polygonal mesh. By default, this is a disc.
  15324. * Please consider using the same method from the MeshBuilder class instead.
  15325. * The parameter `radius` sets the radius size (float) of the polygon (default 0.5).
  15326. * 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.
  15327. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  15328. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  15329. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  15330. */
  15331. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  15332. /**
  15333. * Creates a box mesh.
  15334. * Please consider using the same method from the MeshBuilder class instead.
  15335. * The parameter `size` sets the size (float) of each box side (default 1).
  15336. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  15337. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  15338. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  15339. */
  15340. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  15341. /**
  15342. * Creates a sphere mesh.
  15343. * Please consider using the same method from the MeshBuilder class instead.
  15344. * The parameter `diameter` sets the diameter size (float) of the sphere (default 1).
  15345. * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32).
  15346. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  15347. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  15348. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  15349. */
  15350. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  15351. /**
  15352. * Creates a cylinder or a cone mesh.
  15353. * Please consider using the same method from the MeshBuilder class instead.
  15354. * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  15355. * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  15356. * 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.
  15357. * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  15358. * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  15359. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  15360. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  15361. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  15362. */
  15363. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  15364. /**
  15365. * Creates a torus mesh.
  15366. * Please consider using the same method from the MeshBuilder class instead.
  15367. * The parameter `diameter` sets the diameter size (float) of the torus (default 1).
  15368. * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5).
  15369. * The parameter `tessellation` sets the number of torus sides (postive integer, default 16).
  15370. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  15371. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  15372. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  15373. */
  15374. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  15375. /**
  15376. * Creates a torus knot mesh.
  15377. * Please consider using the same method from the MeshBuilder class instead.
  15378. * The parameter `radius` sets the global radius size (float) of the torus knot (default 2).
  15379. * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32).
  15380. * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32).
  15381. * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3).
  15382. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  15383. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  15384. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  15385. */
  15386. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  15387. /**
  15388. * Creates a line mesh.
  15389. * Please consider using the same method from the MeshBuilder class instead.
  15390. * 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.
  15391. * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function.
  15392. * The parameter `points` is an array successive Vector3.
  15393. * 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
  15394. * When updating an instance, remember that only point positions can change, not the number of points.
  15395. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  15396. */
  15397. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  15398. /**
  15399. * Creates a dashed line mesh.
  15400. * Please consider using the same method from the MeshBuilder class instead.
  15401. * 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.
  15402. * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function.
  15403. * The parameter `points` is an array successive Vector3.
  15404. * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200).
  15405. * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3).
  15406. * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1).
  15407. * 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
  15408. * When updating an instance, remember that only point positions can change, not the number of points.
  15409. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  15410. */
  15411. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  15412. /**
  15413. * Creates a polygon mesh.
  15414. * Please consider using the same method from the MeshBuilder class instead.
  15415. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  15416. * 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.
  15417. * You can set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  15418. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  15419. * Remember you can only change the shape positions, not their number when updating a polygon.
  15420. */
  15421. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number): Mesh;
  15422. /**
  15423. * Creates an extruded polygon mesh, with depth in the Y direction.
  15424. * Please consider using the same method from the MeshBuilder class instead.
  15425. */
  15426. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number): Mesh;
  15427. /**
  15428. * Creates an extruded shape mesh.
  15429. * 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.
  15430. * Please consider using the same method from the MeshBuilder class instead.
  15431. *
  15432. * Please read this full tutorial to understand how to design an extruded shape : http://doc.babylonjs.com/tutorials/Parametric_Shapes#extrusion
  15433. * 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
  15434. * extruded along the Z axis.
  15435. * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  15436. * 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.
  15437. * The parameter `scale` (float, default 1) is the value to scale the shape.
  15438. * 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
  15439. * 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
  15440. * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  15441. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  15442. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  15443. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  15444. */
  15445. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  15446. /**
  15447. * Creates an custom extruded shape mesh.
  15448. * 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.
  15449. * Please consider using the same method from the MeshBuilder class instead.
  15450. *
  15451. * Please read this full tutorial to understand how to design a custom extruded shape : http://doc.babylonjs.com/tutorials/Parametric_Shapes#extrusion
  15452. * 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
  15453. * extruded along the Z axis.
  15454. * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  15455. * 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
  15456. * and the distance of this point from the begining of the path :
  15457. * ```javascript
  15458. * var rotationFunction = function(i, distance) {
  15459. * // do things
  15460. * return rotationValue; }
  15461. * ```
  15462. * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  15463. * 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
  15464. * and the distance of this point from the begining of the path :
  15465. * ```javascript
  15466. * var scaleFunction = function(i, distance) {
  15467. * // do things
  15468. * return scaleValue;}
  15469. * ```
  15470. * It must returns a float value that will be the scale value applied to the shape on each path point.
  15471. * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`.
  15472. * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`.
  15473. * 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
  15474. * 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
  15475. * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  15476. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  15477. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  15478. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  15479. */
  15480. 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;
  15481. /**
  15482. * Creates lathe mesh.
  15483. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  15484. * Please consider using the same method from the MeshBuilder class instead.
  15485. * 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
  15486. * rotated around the Y axis. It's usually a 2D shape, so the Vector3 z coordinates are often set to zero.
  15487. * The parameter `radius` (positive float, default 1) is the radius value of the lathe.
  15488. * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe.
  15489. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  15490. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  15491. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  15492. */
  15493. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  15494. /**
  15495. * Creates a plane mesh.
  15496. * Please consider using the same method from the MeshBuilder class instead.
  15497. * The parameter `size` sets the size (float) of both sides of the plane at once (default 1).
  15498. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  15499. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  15500. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  15501. */
  15502. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  15503. /**
  15504. * Creates a ground mesh.
  15505. * Please consider using the same method from the MeshBuilder class instead.
  15506. * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground.
  15507. * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side.
  15508. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  15509. */
  15510. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  15511. /**
  15512. * Creates a tiled ground mesh.
  15513. * Please consider using the same method from the MeshBuilder class instead.
  15514. * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates.
  15515. * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates.
  15516. * The parameter `subdivisions` is a javascript object `{w: positive integer, h: positive integer}` (default `{w: 6, h: 6}`). `w` and `h` are the
  15517. * numbers of subdivisions on the ground width and height. Each subdivision is called a tile.
  15518. * The parameter `precision` is a javascript object `{w: positive integer, h: positive integer}` (default `{w: 2, h: 2}`). `w` and `h` are the
  15519. * numbers of subdivisions on the ground width and height of each tile.
  15520. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  15521. */
  15522. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  15523. w: number;
  15524. h: number;
  15525. }, precision: {
  15526. w: number;
  15527. h: number;
  15528. }, scene: Scene, updatable?: boolean): Mesh;
  15529. /**
  15530. * Creates a ground mesh from a height map.
  15531. * tuto : http://doc.babylonjs.com/tutorials/14._Height_Map
  15532. * Please consider using the same method from the MeshBuilder class instead.
  15533. * The parameter `url` sets the URL of the height map image resource.
  15534. * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  15535. * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  15536. * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  15537. * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  15538. * 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).
  15539. * This function is passed the newly built mesh :
  15540. * ```javascript
  15541. * function(mesh) { // do things
  15542. * return; }
  15543. * ```
  15544. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  15545. */
  15546. 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;
  15547. /**
  15548. * Creates a tube mesh.
  15549. * 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.
  15550. * Please consider using the same method from the MeshBuilder class instead.
  15551. * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube.
  15552. * The parameter `radius` (positive float, default 1) sets the tube radius size.
  15553. * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface.
  15554. * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`.
  15555. * 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.
  15556. * It must return a radius value (positive float) :
  15557. * ```javascript
  15558. * var radiusFunction = function(i, distance) {
  15559. * // do things
  15560. * return radius; }
  15561. * ```
  15562. * 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
  15563. * 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
  15564. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  15565. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  15566. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  15567. */
  15568. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  15569. (i: number, distance: number): number;
  15570. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  15571. /**
  15572. * Creates a polyhedron mesh.
  15573. * Please consider using the same method from the MeshBuilder class instead.
  15574. * 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
  15575. * to choose the wanted type.
  15576. * The parameter `size` (positive float, default 1) sets the polygon size.
  15577. * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value).
  15578. * 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`.
  15579. * 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
  15580. * 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)`).
  15581. * 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
  15582. * 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.
  15583. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  15584. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  15585. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  15586. */
  15587. static CreatePolyhedron(name: string, options: {
  15588. type?: number;
  15589. size?: number;
  15590. sizeX?: number;
  15591. sizeY?: number;
  15592. sizeZ?: number;
  15593. custom?: any;
  15594. faceUV?: Vector4[];
  15595. faceColors?: Color4[];
  15596. updatable?: boolean;
  15597. sideOrientation?: number;
  15598. }, scene: Scene): Mesh;
  15599. /**
  15600. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided.
  15601. * Please consider using the same method from the MeshBuilder class instead.
  15602. * The parameter `radius` sets the radius size (float) of the icosphere (default 1).
  15603. * 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`).
  15604. * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size.
  15605. * 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.
  15606. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  15607. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  15608. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  15609. */
  15610. static CreateIcoSphere(name: string, options: {
  15611. radius?: number;
  15612. flat?: boolean;
  15613. subdivisions?: number;
  15614. sideOrientation?: number;
  15615. updatable?: boolean;
  15616. }, scene: Scene): Mesh;
  15617. /**
  15618. * Creates a decal mesh.
  15619. * Please consider using the same method from the MeshBuilder class instead.
  15620. * 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.
  15621. * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates.
  15622. * The parameter `normal` (Vector3, default Vector3.Up) sets the normal of the mesh where the decal is applied onto in World coordinates.
  15623. * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling.
  15624. * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal.
  15625. */
  15626. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  15627. /**
  15628. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  15629. */
  15630. setPositionsForCPUSkinning(): Float32Array;
  15631. /**
  15632. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  15633. */
  15634. setNormalsForCPUSkinning(): Float32Array;
  15635. /**
  15636. * Updates the vertex buffer by applying transformation from the bones.
  15637. * Returns the Mesh.
  15638. *
  15639. * @param {skeleton} skeleton to apply
  15640. */
  15641. applySkeleton(skeleton: Skeleton): Mesh;
  15642. /**
  15643. * Returns an object `{min:` Vector3`, max:` Vector3`}`
  15644. * This min and max Vector3 are the minimum and maximum vectors of each mesh bounding box from the passed array, in the World system
  15645. */
  15646. static MinMax(meshes: AbstractMesh[]): {
  15647. min: Vector3;
  15648. max: Vector3;
  15649. };
  15650. /**
  15651. * Returns a Vector3, the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array.
  15652. */
  15653. static Center(meshesOrMinMaxVector: {
  15654. min: Vector3;
  15655. max: Vector3;
  15656. } | AbstractMesh[]): Vector3;
  15657. /**
  15658. * Merge the array of meshes into a single mesh for performance reasons.
  15659. * @param {Array<Mesh>} meshes - The vertices source. They should all be of the same material. Entries can empty
  15660. * @param {boolean} disposeSource - When true (default), dispose of the vertices from the source meshes
  15661. * @param {boolean} allow32BitsIndices - When the sum of the vertices > 64k, this must be set to true.
  15662. * @param {Mesh} meshSubclass - When set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  15663. * @param {boolean} subdivideWithSubMeshes - When true (false default), subdivide mesh to his subMesh array with meshes source.
  15664. */
  15665. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean): Nullable<Mesh>;
  15666. }
  15667. }
  15668. declare module BABYLON {
  15669. interface IGetSetVerticesData {
  15670. isVerticesDataPresent(kind: string): boolean;
  15671. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  15672. getIndices(copyWhenShared?: boolean): Nullable<IndicesArray>;
  15673. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  15674. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  15675. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  15676. }
  15677. class VertexData {
  15678. positions: Nullable<FloatArray>;
  15679. normals: Nullable<FloatArray>;
  15680. tangents: Nullable<FloatArray>;
  15681. uvs: Nullable<FloatArray>;
  15682. uvs2: Nullable<FloatArray>;
  15683. uvs3: Nullable<FloatArray>;
  15684. uvs4: Nullable<FloatArray>;
  15685. uvs5: Nullable<FloatArray>;
  15686. uvs6: Nullable<FloatArray>;
  15687. colors: Nullable<FloatArray>;
  15688. matricesIndices: Nullable<FloatArray>;
  15689. matricesWeights: Nullable<FloatArray>;
  15690. matricesIndicesExtra: Nullable<FloatArray>;
  15691. matricesWeightsExtra: Nullable<FloatArray>;
  15692. indices: Nullable<IndicesArray>;
  15693. set(data: FloatArray, kind: string): void;
  15694. /**
  15695. * Associates the vertexData to the passed Mesh.
  15696. * Sets it as updatable or not (default `false`).
  15697. * Returns the VertexData.
  15698. */
  15699. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  15700. /**
  15701. * Associates the vertexData to the passed Geometry.
  15702. * Sets it as updatable or not (default `false`).
  15703. * Returns the VertexData.
  15704. */
  15705. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  15706. /**
  15707. * Updates the associated mesh.
  15708. * Returns the VertexData.
  15709. */
  15710. updateMesh(mesh: Mesh, updateExtends?: boolean, makeItUnique?: boolean): VertexData;
  15711. /**
  15712. * Updates the associated geometry.
  15713. * Returns the VertexData.
  15714. */
  15715. updateGeometry(geometry: Geometry, updateExtends?: boolean, makeItUnique?: boolean): VertexData;
  15716. private _applyTo(meshOrGeometry, updatable?);
  15717. private _update(meshOrGeometry, updateExtends?, makeItUnique?);
  15718. /**
  15719. * Transforms each position and each normal of the vertexData according to the passed Matrix.
  15720. * Returns the VertexData.
  15721. */
  15722. transform(matrix: Matrix): VertexData;
  15723. /**
  15724. * Merges the passed VertexData into the current one.
  15725. * Returns the modified VertexData.
  15726. */
  15727. merge(other: VertexData): VertexData;
  15728. private _mergeElement(source, other);
  15729. private _validate();
  15730. /**
  15731. * Serializes the VertexData.
  15732. * Returns a serialized object.
  15733. */
  15734. serialize(): any;
  15735. /**
  15736. * Returns the object VertexData associated to the passed mesh.
  15737. */
  15738. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  15739. /**
  15740. * Returns the object VertexData associated to the passed geometry.
  15741. */
  15742. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  15743. private static _ExtractFrom(meshOrGeometry, copyWhenShared?, forceCopy?);
  15744. /**
  15745. * Creates the vertexData of the Ribbon.
  15746. */
  15747. static CreateRibbon(options: {
  15748. pathArray: Vector3[][];
  15749. closeArray?: boolean;
  15750. closePath?: boolean;
  15751. offset?: number;
  15752. sideOrientation?: number;
  15753. frontUVs?: Vector4;
  15754. backUVs?: Vector4;
  15755. invertUV?: boolean;
  15756. uvs?: Vector2[];
  15757. colors?: Color4[];
  15758. }): VertexData;
  15759. /**
  15760. * Creates the VertexData of the Box.
  15761. */
  15762. static CreateBox(options: {
  15763. size?: number;
  15764. width?: number;
  15765. height?: number;
  15766. depth?: number;
  15767. faceUV?: Vector4[];
  15768. faceColors?: Color4[];
  15769. sideOrientation?: number;
  15770. frontUVs?: Vector4;
  15771. backUVs?: Vector4;
  15772. }): VertexData;
  15773. /**
  15774. * Creates the VertexData of the Sphere.
  15775. */
  15776. static CreateSphere(options: {
  15777. segments?: number;
  15778. diameter?: number;
  15779. diameterX?: number;
  15780. diameterY?: number;
  15781. diameterZ?: number;
  15782. arc?: number;
  15783. slice?: number;
  15784. sideOrientation?: number;
  15785. frontUVs?: Vector4;
  15786. backUVs?: Vector4;
  15787. }): VertexData;
  15788. /**
  15789. * Creates the VertexData of the Cylinder or Cone.
  15790. */
  15791. static CreateCylinder(options: {
  15792. height?: number;
  15793. diameterTop?: number;
  15794. diameterBottom?: number;
  15795. diameter?: number;
  15796. tessellation?: number;
  15797. subdivisions?: number;
  15798. arc?: number;
  15799. faceColors?: Color4[];
  15800. faceUV?: Vector4[];
  15801. hasRings?: boolean;
  15802. enclose?: boolean;
  15803. sideOrientation?: number;
  15804. frontUVs?: Vector4;
  15805. backUVs?: Vector4;
  15806. }): VertexData;
  15807. /**
  15808. * Creates the VertexData of the Torus.
  15809. */
  15810. static CreateTorus(options: {
  15811. diameter?: number;
  15812. thickness?: number;
  15813. tessellation?: number;
  15814. sideOrientation?: number;
  15815. frontUVs?: Vector4;
  15816. backUVs?: Vector4;
  15817. }): VertexData;
  15818. /**
  15819. * Creates the VertexData of the LineSystem.
  15820. */
  15821. static CreateLineSystem(options: {
  15822. lines: Vector3[][];
  15823. colors?: Nullable<Color4[][]>;
  15824. }): VertexData;
  15825. /**
  15826. * Create the VertexData of the DashedLines.
  15827. */
  15828. static CreateDashedLines(options: {
  15829. points: Vector3[];
  15830. dashSize?: number;
  15831. gapSize?: number;
  15832. dashNb?: number;
  15833. }): VertexData;
  15834. /**
  15835. * Creates the VertexData of the Ground.
  15836. */
  15837. static CreateGround(options: {
  15838. width?: number;
  15839. height?: number;
  15840. subdivisions?: number;
  15841. subdivisionsX?: number;
  15842. subdivisionsY?: number;
  15843. }): VertexData;
  15844. /**
  15845. * Creates the VertexData of the TiledGround.
  15846. */
  15847. static CreateTiledGround(options: {
  15848. xmin: number;
  15849. zmin: number;
  15850. xmax: number;
  15851. zmax: number;
  15852. subdivisions?: {
  15853. w: number;
  15854. h: number;
  15855. };
  15856. precision?: {
  15857. w: number;
  15858. h: number;
  15859. };
  15860. }): VertexData;
  15861. /**
  15862. * Creates the VertexData of the Ground designed from a heightmap.
  15863. */
  15864. static CreateGroundFromHeightMap(options: {
  15865. width: number;
  15866. height: number;
  15867. subdivisions: number;
  15868. minHeight: number;
  15869. maxHeight: number;
  15870. colorFilter: Color3;
  15871. buffer: Uint8Array;
  15872. bufferWidth: number;
  15873. bufferHeight: number;
  15874. }): VertexData;
  15875. /**
  15876. * Creates the VertexData of the Plane.
  15877. */
  15878. static CreatePlane(options: {
  15879. size?: number;
  15880. width?: number;
  15881. height?: number;
  15882. sideOrientation?: number;
  15883. frontUVs?: Vector4;
  15884. backUVs?: Vector4;
  15885. }): VertexData;
  15886. /**
  15887. * Creates the VertexData of the Disc or regular Polygon.
  15888. */
  15889. static CreateDisc(options: {
  15890. radius?: number;
  15891. tessellation?: number;
  15892. arc?: number;
  15893. sideOrientation?: number;
  15894. frontUVs?: Vector4;
  15895. backUVs?: Vector4;
  15896. }): VertexData;
  15897. /**
  15898. * Re-creates the VertexData of the Polygon for sideOrientation.
  15899. */
  15900. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  15901. /**
  15902. * Creates the VertexData of the IcoSphere.
  15903. */
  15904. static CreateIcoSphere(options: {
  15905. radius?: number;
  15906. radiusX?: number;
  15907. radiusY?: number;
  15908. radiusZ?: number;
  15909. flat?: boolean;
  15910. subdivisions?: number;
  15911. sideOrientation?: number;
  15912. frontUVs?: Vector4;
  15913. backUVs?: Vector4;
  15914. }): VertexData;
  15915. /**
  15916. * Creates the VertexData of the Polyhedron.
  15917. */
  15918. static CreatePolyhedron(options: {
  15919. type?: number;
  15920. size?: number;
  15921. sizeX?: number;
  15922. sizeY?: number;
  15923. sizeZ?: number;
  15924. custom?: any;
  15925. faceUV?: Vector4[];
  15926. faceColors?: Color4[];
  15927. flat?: boolean;
  15928. sideOrientation?: number;
  15929. frontUVs?: Vector4;
  15930. backUVs?: Vector4;
  15931. }): VertexData;
  15932. /**
  15933. * Creates the VertexData of the Torus Knot.
  15934. */
  15935. static CreateTorusKnot(options: {
  15936. radius?: number;
  15937. tube?: number;
  15938. radialSegments?: number;
  15939. tubularSegments?: number;
  15940. p?: number;
  15941. q?: number;
  15942. sideOrientation?: number;
  15943. frontUVs?: Vector4;
  15944. backUVs?: Vector4;
  15945. }): VertexData;
  15946. /**
  15947. * @param {any} - positions (number[] or Float32Array)
  15948. * @param {any} - indices (number[] or Uint16Array)
  15949. * @param {any} - normals (number[] or Float32Array)
  15950. * options (optional) :
  15951. * facetPositions : optional array of facet positions (vector3)
  15952. * facetNormals : optional array of facet normals (vector3)
  15953. * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  15954. * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  15955. * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  15956. * bbSize : optional bounding box size data, required for facetPartitioning computation
  15957. * bInfo : optional bounding info, required for facetPartitioning computation
  15958. * useRightHandedSystem: optional boolean to for right handed system computation
  15959. * depthSort : optional boolean to enable the facet depth sort computation
  15960. * distanceTo : optional Vector3 to compute the facet depth from this location
  15961. * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  15962. */
  15963. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  15964. facetNormals?: any;
  15965. facetPositions?: any;
  15966. facetPartitioning?: any;
  15967. ratio?: number;
  15968. bInfo?: any;
  15969. bbSize?: Vector3;
  15970. subDiv?: any;
  15971. useRightHandedSystem?: boolean;
  15972. depthSort?: boolean;
  15973. distanceTo?: Vector3;
  15974. depthSortedFacets?: any;
  15975. }): void;
  15976. private static _ComputeSides(sideOrientation, positions, indices, normals, uvs, frontUVs?, backUVs?);
  15977. /**
  15978. * Creates a new VertexData from the imported parameters.
  15979. */
  15980. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  15981. }
  15982. }
  15983. declare module BABYLON {
  15984. class MeshBuilder {
  15985. private static updateSideOrientation(orientation?);
  15986. /**
  15987. * Creates a box mesh.
  15988. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#box
  15989. * The parameter `size` sets the size (float) of each box side (default 1).
  15990. * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value than `size`).
  15991. * 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).
  15992. * Please read this tutorial : http://doc.babylonjs.com/tutorials/CreateBox_Per_Face_Textures_And_Colors
  15993. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  15994. * 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).
  15995. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  15996. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  15997. */
  15998. static CreateBox(name: string, options: {
  15999. size?: number;
  16000. width?: number;
  16001. height?: number;
  16002. depth?: number;
  16003. faceUV?: Vector4[];
  16004. faceColors?: Color4[];
  16005. sideOrientation?: number;
  16006. frontUVs?: Vector4;
  16007. backUVs?: Vector4;
  16008. updatable?: boolean;
  16009. }, scene?: Nullable<Scene>): Mesh;
  16010. /**
  16011. * Creates a sphere mesh.
  16012. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#sphere
  16013. * The parameter `diameter` sets the diameter size (float) of the sphere (default 1).
  16014. * 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`).
  16015. * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32).
  16016. * 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
  16017. * 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).
  16018. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  16019. * 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).
  16020. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  16021. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  16022. */
  16023. static CreateSphere(name: string, options: {
  16024. segments?: number;
  16025. diameter?: number;
  16026. diameterX?: number;
  16027. diameterY?: number;
  16028. diameterZ?: number;
  16029. arc?: number;
  16030. slice?: number;
  16031. sideOrientation?: number;
  16032. frontUVs?: Vector4;
  16033. backUVs?: Vector4;
  16034. updatable?: boolean;
  16035. }, scene: any): Mesh;
  16036. /**
  16037. * Creates a plane polygonal mesh. By default, this is a disc.
  16038. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#disc
  16039. * The parameter `radius` sets the radius size (float) of the polygon (default 0.5).
  16040. * 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.
  16041. * 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
  16042. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  16043. * 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).
  16044. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  16045. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  16046. */
  16047. static CreateDisc(name: string, options: {
  16048. radius?: number;
  16049. tessellation?: number;
  16050. arc?: number;
  16051. updatable?: boolean;
  16052. sideOrientation?: number;
  16053. frontUVs?: Vector4;
  16054. backUVs?: Vector4;
  16055. }, scene?: Nullable<Scene>): Mesh;
  16056. /**
  16057. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided.
  16058. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#icosphere
  16059. * The parameter `radius` sets the radius size (float) of the icosphere (default 1).
  16060. * 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`).
  16061. * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size.
  16062. * 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.
  16063. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  16064. * 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).
  16065. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  16066. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  16067. */
  16068. static CreateIcoSphere(name: string, options: {
  16069. radius?: number;
  16070. radiusX?: number;
  16071. radiusY?: number;
  16072. radiusZ?: number;
  16073. flat?: boolean;
  16074. subdivisions?: number;
  16075. sideOrientation?: number;
  16076. frontUVs?: Vector4;
  16077. backUVs?: Vector4;
  16078. updatable?: boolean;
  16079. }, scene: Scene): Mesh;
  16080. /**
  16081. * Creates a ribbon mesh.
  16082. * 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.
  16083. *
  16084. * Please read this full tutorial to understand how to design a ribbon : http://doc.babylonjs.com/tutorials/Ribbon_Tutorial
  16085. * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  16086. * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array.
  16087. * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array.
  16088. * 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.
  16089. * 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.
  16090. * 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
  16091. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  16092. * 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).
  16093. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  16094. * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  16095. * 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.
  16096. * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values.
  16097. * 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
  16098. * if you set `closePath` to `true`, there's one extra vertex per path in the geometry.
  16099. * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time.
  16100. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  16101. */
  16102. static CreateRibbon(name: string, options: {
  16103. pathArray: Vector3[][];
  16104. closeArray?: boolean;
  16105. closePath?: boolean;
  16106. offset?: number;
  16107. updatable?: boolean;
  16108. sideOrientation?: number;
  16109. frontUVs?: Vector4;
  16110. backUVs?: Vector4;
  16111. instance?: Mesh;
  16112. invertUV?: boolean;
  16113. uvs?: Vector2[];
  16114. colors?: Color4[];
  16115. }, scene?: Nullable<Scene>): Mesh;
  16116. /**
  16117. * Creates a cylinder or a cone mesh.
  16118. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#cylinder-or-cone
  16119. * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  16120. * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  16121. * 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.
  16122. * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  16123. * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  16124. * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  16125. * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  16126. * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  16127. * 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).
  16128. * 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
  16129. * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  16130. * 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
  16131. * 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.
  16132. * If `enclose` is false, a ring surface is one element.
  16133. * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  16134. * 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
  16135. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  16136. * 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).
  16137. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  16138. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  16139. */
  16140. static CreateCylinder(name: string, options: {
  16141. height?: number;
  16142. diameterTop?: number;
  16143. diameterBottom?: number;
  16144. diameter?: number;
  16145. tessellation?: number;
  16146. subdivisions?: number;
  16147. arc?: number;
  16148. faceColors?: Color4[];
  16149. faceUV?: Vector4[];
  16150. updatable?: boolean;
  16151. hasRings?: boolean;
  16152. enclose?: boolean;
  16153. sideOrientation?: number;
  16154. frontUVs?: Vector4;
  16155. backUVs?: Vector4;
  16156. }, scene: any): Mesh;
  16157. /**
  16158. * Creates a torus mesh.
  16159. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#torus
  16160. * The parameter `diameter` sets the diameter size (float) of the torus (default 1).
  16161. * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5).
  16162. * The parameter `tessellation` sets the number of torus sides (postive integer, default 16).
  16163. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  16164. * 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).
  16165. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  16166. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  16167. */
  16168. static CreateTorus(name: string, options: {
  16169. diameter?: number;
  16170. thickness?: number;
  16171. tessellation?: number;
  16172. updatable?: boolean;
  16173. sideOrientation?: number;
  16174. frontUVs?: Vector4;
  16175. backUVs?: Vector4;
  16176. }, scene: any): Mesh;
  16177. /**
  16178. * Creates a torus knot mesh.
  16179. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#torus-knot
  16180. * The parameter `radius` sets the global radius size (float) of the torus knot (default 2).
  16181. * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32).
  16182. * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32).
  16183. * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3).
  16184. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  16185. * 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).
  16186. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  16187. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  16188. */
  16189. static CreateTorusKnot(name: string, options: {
  16190. radius?: number;
  16191. tube?: number;
  16192. radialSegments?: number;
  16193. tubularSegments?: number;
  16194. p?: number;
  16195. q?: number;
  16196. updatable?: boolean;
  16197. sideOrientation?: number;
  16198. frontUVs?: Vector4;
  16199. backUVs?: Vector4;
  16200. }, scene: any): Mesh;
  16201. /**
  16202. * Creates a line system mesh.
  16203. * A line system is a pool of many lines gathered in a single mesh.
  16204. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#linesystem
  16205. * 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.
  16206. * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function.
  16207. * The parameter `lines` is an array of lines, each line being an array of successive Vector3.
  16208. * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter. The way to update it is the same than for
  16209. * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point.
  16210. * The optional parameter `useVertexAlpha' is to be set to `false` (default `true`) when you don't need the alpha blending (faster).
  16211. * 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
  16212. * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines.
  16213. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  16214. */
  16215. static CreateLineSystem(name: string, options: {
  16216. lines: Vector3[][];
  16217. updatable: boolean;
  16218. instance: Nullable<LinesMesh>;
  16219. colors?: Nullable<Color4[][]>;
  16220. useVertexAlpha?: boolean;
  16221. }, scene: Nullable<Scene>): LinesMesh;
  16222. /**
  16223. * Creates a line mesh.
  16224. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#lines
  16225. * 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.
  16226. * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function.
  16227. * The parameter `points` is an array successive Vector3.
  16228. * 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
  16229. * The optional parameter `colors` is an array of successive Color4, one per line point.
  16230. * The optional parameter `useVertexAlpha' is to be set to `false` (default `true`) when you don't need alpha blending (faster).
  16231. * When updating an instance, remember that only point positions can change, not the number of points.
  16232. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  16233. */
  16234. static CreateLines(name: string, options: {
  16235. points: Vector3[];
  16236. updatable: boolean;
  16237. instance: Nullable<LinesMesh>;
  16238. colors?: Color4[];
  16239. useVertexAlpha?: boolean;
  16240. }, scene?: Nullable<Scene>): LinesMesh;
  16241. /**
  16242. * Creates a dashed line mesh.
  16243. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#dashed-lines
  16244. * 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.
  16245. * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function.
  16246. * The parameter `points` is an array successive Vector3.
  16247. * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200).
  16248. * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3).
  16249. * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1).
  16250. * 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
  16251. * When updating an instance, remember that only point positions can change, not the number of points.
  16252. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  16253. */
  16254. static CreateDashedLines(name: string, options: {
  16255. points: Vector3[];
  16256. dashSize?: number;
  16257. gapSize?: number;
  16258. dashNb?: number;
  16259. updatable?: boolean;
  16260. instance?: LinesMesh;
  16261. }, scene?: Nullable<Scene>): LinesMesh;
  16262. /**
  16263. * Creates an extruded shape mesh.
  16264. * 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.
  16265. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#extruded-shapes
  16266. *
  16267. * Please read this full tutorial to understand how to design an extruded shape : http://doc.babylonjs.com/tutorials/Parametric_Shapes#extrusion
  16268. * 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
  16269. * extruded along the Z axis.
  16270. * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  16271. * 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.
  16272. * The parameter `scale` (float, default 1) is the value to scale the shape.
  16273. * 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
  16274. * 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
  16275. * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  16276. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  16277. * 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).
  16278. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  16279. * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  16280. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  16281. */
  16282. static ExtrudeShape(name: string, options: {
  16283. shape: Vector3[];
  16284. path: Vector3[];
  16285. scale?: number;
  16286. rotation?: number;
  16287. cap?: number;
  16288. updatable?: boolean;
  16289. sideOrientation?: number;
  16290. frontUVs?: Vector4;
  16291. backUVs?: Vector4;
  16292. instance?: Mesh;
  16293. invertUV?: boolean;
  16294. }, scene?: Nullable<Scene>): Mesh;
  16295. /**
  16296. * Creates an custom extruded shape mesh.
  16297. * 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.
  16298. * tuto :http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#custom-extruded-shapes
  16299. *
  16300. * Please read this full tutorial to understand how to design a custom extruded shape : http://doc.babylonjs.com/tutorials/Parametric_Shapes#extrusion
  16301. * 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
  16302. * extruded along the Z axis.
  16303. * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  16304. * 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
  16305. * and the distance of this point from the begining of the path :
  16306. * ```javascript
  16307. * var rotationFunction = function(i, distance) {
  16308. * // do things
  16309. * return rotationValue; }
  16310. * ```
  16311. * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  16312. * 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
  16313. * and the distance of this point from the begining of the path :
  16314. * ```javascript
  16315. * var scaleFunction = function(i, distance) {
  16316. * // do things
  16317. * return scaleValue;}
  16318. * ```
  16319. * It must returns a float value that will be the scale value applied to the shape on each path point.
  16320. * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`.
  16321. * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`.
  16322. * 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
  16323. * 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
  16324. * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  16325. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  16326. * 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).
  16327. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  16328. * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  16329. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  16330. */
  16331. static ExtrudeShapeCustom(name: string, options: {
  16332. shape: Vector3[];
  16333. path: Vector3[];
  16334. scaleFunction?: any;
  16335. rotationFunction?: any;
  16336. ribbonCloseArray?: boolean;
  16337. ribbonClosePath?: boolean;
  16338. cap?: number;
  16339. updatable?: boolean;
  16340. sideOrientation?: number;
  16341. frontUVs?: Vector4;
  16342. backUVs?: Vector4;
  16343. instance?: Mesh;
  16344. invertUV?: boolean;
  16345. }, scene: Scene): Mesh;
  16346. /**
  16347. * Creates lathe mesh.
  16348. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  16349. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#lathe
  16350. *
  16351. * 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
  16352. * rotated around the Y axis. It's usually a 2D shape, so the Vector3 z coordinates are often set to zero.
  16353. * The parameter `radius` (positive float, default 1) is the radius value of the lathe.
  16354. * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe.
  16355. * 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.
  16356. * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc".
  16357. * 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
  16358. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  16359. * 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).
  16360. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  16361. * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  16362. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  16363. */
  16364. static CreateLathe(name: string, options: {
  16365. shape: Vector3[];
  16366. radius?: number;
  16367. tessellation?: number;
  16368. arc?: number;
  16369. closed?: boolean;
  16370. updatable?: boolean;
  16371. sideOrientation?: number;
  16372. frontUVs?: Vector4;
  16373. backUVs?: Vector4;
  16374. cap?: number;
  16375. invertUV?: boolean;
  16376. }, scene: Scene): Mesh;
  16377. /**
  16378. * Creates a plane mesh.
  16379. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#plane
  16380. * The parameter `size` sets the size (float) of both sides of the plane at once (default 1).
  16381. * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value than `size`).
  16382. * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane.
  16383. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  16384. * 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).
  16385. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  16386. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  16387. */
  16388. static CreatePlane(name: string, options: {
  16389. size?: number;
  16390. width?: number;
  16391. height?: number;
  16392. sideOrientation?: number;
  16393. frontUVs?: Vector4;
  16394. backUVs?: Vector4;
  16395. updatable?: boolean;
  16396. sourcePlane?: Plane;
  16397. }, scene: Scene): Mesh;
  16398. /**
  16399. * Creates a ground mesh.
  16400. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#plane
  16401. * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground.
  16402. * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side.
  16403. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  16404. */
  16405. static CreateGround(name: string, options: {
  16406. width?: number;
  16407. height?: number;
  16408. subdivisions?: number;
  16409. subdivisionsX?: number;
  16410. subdivisionsY?: number;
  16411. updatable?: boolean;
  16412. }, scene: any): Mesh;
  16413. /**
  16414. * Creates a tiled ground mesh.
  16415. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#tiled-ground
  16416. * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates.
  16417. * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates.
  16418. * The parameter `subdivisions` is a javascript object `{w: positive integer, h: positive integer}` (default `{w: 6, h: 6}`). `w` and `h` are the
  16419. * numbers of subdivisions on the ground width and height. Each subdivision is called a tile.
  16420. * The parameter `precision` is a javascript object `{w: positive integer, h: positive integer}` (default `{w: 2, h: 2}`). `w` and `h` are the
  16421. * numbers of subdivisions on the ground width and height of each tile.
  16422. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  16423. */
  16424. static CreateTiledGround(name: string, options: {
  16425. xmin: number;
  16426. zmin: number;
  16427. xmax: number;
  16428. zmax: number;
  16429. subdivisions?: {
  16430. w: number;
  16431. h: number;
  16432. };
  16433. precision?: {
  16434. w: number;
  16435. h: number;
  16436. };
  16437. updatable?: boolean;
  16438. }, scene: Scene): Mesh;
  16439. /**
  16440. * Creates a ground mesh from a height map.
  16441. * tuto : http://doc.babylonjs.com/tutorials/14._Height_Map
  16442. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#ground-from-a-height-map
  16443. * The parameter `url` sets the URL of the height map image resource.
  16444. * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  16445. * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  16446. * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  16447. * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  16448. * 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.
  16449. * 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).
  16450. * This function is passed the newly built mesh :
  16451. * ```javascript
  16452. * function(mesh) { // do things
  16453. * return; }
  16454. * ```
  16455. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  16456. */
  16457. static CreateGroundFromHeightMap(name: string, url: string, options: {
  16458. width?: number;
  16459. height?: number;
  16460. subdivisions?: number;
  16461. minHeight?: number;
  16462. maxHeight?: number;
  16463. colorFilter?: Color3;
  16464. updatable?: boolean;
  16465. onReady?: (mesh: GroundMesh) => void;
  16466. }, scene: Scene): GroundMesh;
  16467. /**
  16468. * Creates a polygon mesh.
  16469. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  16470. * 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.
  16471. * You can set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  16472. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  16473. * 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).
  16474. * Remember you can only change the shape positions, not their number when updating a polygon.
  16475. */
  16476. static CreatePolygon(name: string, options: {
  16477. shape: Vector3[];
  16478. holes?: Vector3[][];
  16479. depth?: number;
  16480. faceUV?: Vector4[];
  16481. faceColors?: Color4[];
  16482. updatable?: boolean;
  16483. sideOrientation?: number;
  16484. frontUVs?: Vector4;
  16485. backUVs?: Vector4;
  16486. }, scene: Scene): Mesh;
  16487. /**
  16488. * Creates an extruded polygon mesh, with depth in the Y direction.
  16489. * 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).
  16490. * Please read this tutorial : http://doc.babylonjs.com/tutorials/CreateBox_Per_Face_Textures_And_Colors
  16491. */
  16492. static ExtrudePolygon(name: string, options: {
  16493. shape: Vector3[];
  16494. holes?: Vector3[][];
  16495. depth?: number;
  16496. faceUV?: Vector4[];
  16497. faceColors?: Color4[];
  16498. updatable?: boolean;
  16499. sideOrientation?: number;
  16500. frontUVs?: Vector4;
  16501. backUVs?: Vector4;
  16502. }, scene: Scene): Mesh;
  16503. /**
  16504. * Creates a tube mesh.
  16505. * 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.
  16506. *
  16507. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#tube
  16508. * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube.
  16509. * The parameter `radius` (positive float, default 1) sets the tube radius size.
  16510. * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface.
  16511. * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`.
  16512. * 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.
  16513. * It must return a radius value (positive float) :
  16514. * ```javascript
  16515. * var radiusFunction = function(i, distance) {
  16516. * // do things
  16517. * return radius; }
  16518. * ```
  16519. * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc.
  16520. * 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
  16521. * 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
  16522. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  16523. * 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).
  16524. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  16525. * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  16526. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  16527. */
  16528. static CreateTube(name: string, options: {
  16529. path: Vector3[];
  16530. radius?: number;
  16531. tessellation?: number;
  16532. radiusFunction?: {
  16533. (i: number, distance: number): number;
  16534. };
  16535. cap?: number;
  16536. arc?: number;
  16537. updatable?: boolean;
  16538. sideOrientation?: number;
  16539. frontUVs?: Vector4;
  16540. backUVs?: Vector4;
  16541. instance?: Mesh;
  16542. invertUV?: boolean;
  16543. }, scene: Scene): Mesh;
  16544. /**
  16545. * Creates a polyhedron mesh.
  16546. *
  16547. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#polyhedron
  16548. * 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
  16549. * to choose the wanted type.
  16550. * The parameter `size` (positive float, default 1) sets the polygon size.
  16551. * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value).
  16552. * 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`.
  16553. * 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
  16554. * 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)`).
  16555. * 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
  16556. * 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.
  16557. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  16558. * 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).
  16559. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  16560. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  16561. */
  16562. static CreatePolyhedron(name: string, options: {
  16563. type?: number;
  16564. size?: number;
  16565. sizeX?: number;
  16566. sizeY?: number;
  16567. sizeZ?: number;
  16568. custom?: any;
  16569. faceUV?: Vector4[];
  16570. faceColors?: Color4[];
  16571. flat?: boolean;
  16572. updatable?: boolean;
  16573. sideOrientation?: number;
  16574. frontUVs?: Vector4;
  16575. backUVs?: Vector4;
  16576. }, scene: Scene): Mesh;
  16577. /**
  16578. * Creates a decal mesh.
  16579. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#decals
  16580. * 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.
  16581. * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates.
  16582. * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates.
  16583. * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling.
  16584. * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal.
  16585. */
  16586. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  16587. position?: Vector3;
  16588. normal?: Vector3;
  16589. size?: Vector3;
  16590. angle?: number;
  16591. }): Mesh;
  16592. private static _ExtrudeShapeGeneric(name, shape, curve, scale, rotation, scaleFunction, rotateFunction, rbCA, rbCP, cap, custom, scene, updtbl, side, instance, invertUV, frontUVs, backUVs);
  16593. }
  16594. }
  16595. declare module BABYLON {
  16596. class MeshLODLevel {
  16597. distance: number;
  16598. mesh: Mesh;
  16599. constructor(distance: number, mesh: Mesh);
  16600. }
  16601. }
  16602. declare module BABYLON {
  16603. /**
  16604. * A simplifier interface for future simplification implementations.
  16605. */
  16606. interface ISimplifier {
  16607. /**
  16608. * Simplification of a given mesh according to the given settings.
  16609. * Since this requires computation, it is assumed that the function runs async.
  16610. * @param settings The settings of the simplification, including quality and distance
  16611. * @param successCallback A callback that will be called after the mesh was simplified.
  16612. * @param errorCallback in case of an error, this callback will be called. optional.
  16613. */
  16614. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  16615. }
  16616. /**
  16617. * Expected simplification settings.
  16618. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%);
  16619. */
  16620. interface ISimplificationSettings {
  16621. quality: number;
  16622. distance: number;
  16623. optimizeMesh?: boolean;
  16624. }
  16625. class SimplificationSettings implements ISimplificationSettings {
  16626. quality: number;
  16627. distance: number;
  16628. optimizeMesh: boolean | undefined;
  16629. constructor(quality: number, distance: number, optimizeMesh?: boolean | undefined);
  16630. }
  16631. interface ISimplificationTask {
  16632. settings: Array<ISimplificationSettings>;
  16633. simplificationType: SimplificationType;
  16634. mesh: Mesh;
  16635. successCallback?: () => void;
  16636. parallelProcessing: boolean;
  16637. }
  16638. class SimplificationQueue {
  16639. private _simplificationArray;
  16640. running: boolean;
  16641. constructor();
  16642. addTask(task: ISimplificationTask): void;
  16643. executeNext(): void;
  16644. runSimplification(task: ISimplificationTask): void;
  16645. private getSimplifier(task);
  16646. }
  16647. /**
  16648. * The implemented types of simplification.
  16649. * At the moment only Quadratic Error Decimation is implemented.
  16650. */
  16651. enum SimplificationType {
  16652. QUADRATIC = 0,
  16653. }
  16654. class DecimationTriangle {
  16655. vertices: Array<DecimationVertex>;
  16656. normal: Vector3;
  16657. error: Array<number>;
  16658. deleted: boolean;
  16659. isDirty: boolean;
  16660. borderFactor: number;
  16661. deletePending: boolean;
  16662. originalOffset: number;
  16663. constructor(vertices: Array<DecimationVertex>);
  16664. }
  16665. class DecimationVertex {
  16666. position: Vector3;
  16667. id: number;
  16668. q: QuadraticMatrix;
  16669. isBorder: boolean;
  16670. triangleStart: number;
  16671. triangleCount: number;
  16672. originalOffsets: Array<number>;
  16673. constructor(position: Vector3, id: number);
  16674. updatePosition(newPosition: Vector3): void;
  16675. }
  16676. class QuadraticMatrix {
  16677. data: Array<number>;
  16678. constructor(data?: Array<number>);
  16679. det(a11: number, a12: number, a13: number, a21: number, a22: number, a23: number, a31: number, a32: number, a33: number): number;
  16680. addInPlace(matrix: QuadraticMatrix): void;
  16681. addArrayInPlace(data: Array<number>): void;
  16682. add(matrix: QuadraticMatrix): QuadraticMatrix;
  16683. static FromData(a: number, b: number, c: number, d: number): QuadraticMatrix;
  16684. static DataFromNumbers(a: number, b: number, c: number, d: number): number[];
  16685. }
  16686. class Reference {
  16687. vertexId: number;
  16688. triangleId: number;
  16689. constructor(vertexId: number, triangleId: number);
  16690. }
  16691. /**
  16692. * An implementation of the Quadratic Error simplification algorithm.
  16693. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  16694. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  16695. * @author RaananW
  16696. */
  16697. class QuadraticErrorSimplification implements ISimplifier {
  16698. private _mesh;
  16699. private triangles;
  16700. private vertices;
  16701. private references;
  16702. private _reconstructedMesh;
  16703. syncIterations: number;
  16704. aggressiveness: number;
  16705. decimationIterations: number;
  16706. boundingBoxEpsilon: number;
  16707. constructor(_mesh: Mesh);
  16708. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  16709. private runDecimation(settings, submeshIndex, successCallback);
  16710. private initWithMesh(submeshIndex, callback, optimizeMesh?);
  16711. private init(callback);
  16712. private reconstructMesh(submeshIndex);
  16713. private initDecimatedMesh();
  16714. private isFlipped(vertex1, vertex2, point, deletedArray, borderFactor, delTr);
  16715. private updateTriangles(origVertex, vertex, deletedArray, deletedTriangles);
  16716. private identifyBorder();
  16717. private updateMesh(identifyBorders?);
  16718. private vertexError(q, point);
  16719. private calculateError(vertex1, vertex2, pointResult?, normalResult?, uvResult?, colorResult?);
  16720. }
  16721. }
  16722. declare module BABYLON {
  16723. class Polygon {
  16724. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  16725. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  16726. static Parse(input: string): Vector2[];
  16727. static StartingAt(x: number, y: number): Path2;
  16728. }
  16729. class PolygonMeshBuilder {
  16730. private _points;
  16731. private _outlinepoints;
  16732. private _holes;
  16733. private _name;
  16734. private _scene;
  16735. private _epoints;
  16736. private _eholes;
  16737. private _addToepoint(points);
  16738. constructor(name: string, contours: Path2, scene: Scene);
  16739. constructor(name: string, contours: Vector2[], scene: Scene);
  16740. addHole(hole: Vector2[]): PolygonMeshBuilder;
  16741. build(updatable?: boolean, depth?: number): Mesh;
  16742. private addSide(positions, normals, uvs, indices, bounds, points, depth, flip);
  16743. }
  16744. }
  16745. declare module BABYLON {
  16746. class BaseSubMesh {
  16747. _materialDefines: Nullable<MaterialDefines>;
  16748. _materialEffect: Nullable<Effect>;
  16749. readonly effect: Nullable<Effect>;
  16750. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  16751. }
  16752. class SubMesh extends BaseSubMesh implements ICullable {
  16753. materialIndex: number;
  16754. verticesStart: number;
  16755. verticesCount: number;
  16756. indexStart: number;
  16757. indexCount: number;
  16758. linesIndexCount: number;
  16759. private _mesh;
  16760. private _renderingMesh;
  16761. private _boundingInfo;
  16762. private _linesIndexBuffer;
  16763. _lastColliderWorldVertices: Nullable<Vector3[]>;
  16764. _trianglePlanes: Plane[];
  16765. _lastColliderTransformMatrix: Matrix;
  16766. _renderId: number;
  16767. _alphaIndex: number;
  16768. _distanceToCamera: number;
  16769. _id: number;
  16770. private _currentMaterial;
  16771. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  16772. constructor(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  16773. readonly IsGlobal: boolean;
  16774. /**
  16775. * Returns the submesh BoudingInfo object.
  16776. */
  16777. getBoundingInfo(): BoundingInfo;
  16778. /**
  16779. * Sets the submesh BoundingInfo.
  16780. * Return the SubMesh.
  16781. */
  16782. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  16783. /**
  16784. * Returns the mesh of the current submesh.
  16785. */
  16786. getMesh(): AbstractMesh;
  16787. /**
  16788. * Returns the rendering mesh of the submesh.
  16789. */
  16790. getRenderingMesh(): Mesh;
  16791. /**
  16792. * Returns the submesh material.
  16793. */
  16794. getMaterial(): Nullable<Material>;
  16795. /**
  16796. * Sets a new updated BoundingInfo object to the submesh.
  16797. * Returns the SubMesh.
  16798. */
  16799. refreshBoundingInfo(): SubMesh;
  16800. _checkCollision(collider: Collider): boolean;
  16801. /**
  16802. * Updates the submesh BoundingInfo.
  16803. * Returns the Submesh.
  16804. */
  16805. updateBoundingInfo(world: Matrix): SubMesh;
  16806. /**
  16807. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  16808. * Boolean returned.
  16809. */
  16810. isInFrustum(frustumPlanes: Plane[]): boolean;
  16811. /**
  16812. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes.
  16813. * Boolean returned.
  16814. */
  16815. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  16816. /**
  16817. * Renders the submesh.
  16818. * Returns it.
  16819. */
  16820. render(enableAlphaMode: boolean): SubMesh;
  16821. /**
  16822. * Returns a new Index Buffer.
  16823. * Type returned : WebGLBuffer.
  16824. */
  16825. getLinesIndexBuffer(indices: IndicesArray, engine: Engine): WebGLBuffer;
  16826. /**
  16827. * True is the passed Ray intersects the submesh bounding box.
  16828. * Boolean returned.
  16829. */
  16830. canIntersects(ray: Ray): boolean;
  16831. /**
  16832. * Returns an object IntersectionInfo.
  16833. */
  16834. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean): Nullable<IntersectionInfo>;
  16835. _rebuild(): void;
  16836. /**
  16837. * Creates a new Submesh from the passed Mesh.
  16838. */
  16839. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  16840. /**
  16841. * Disposes the Submesh.
  16842. * Returns nothing.
  16843. */
  16844. dispose(): void;
  16845. /**
  16846. * Creates a new Submesh from the passed parameters :
  16847. * - materialIndex (integer) : the index of the main mesh material.
  16848. * - startIndex (integer) : the index where to start the copy in the mesh indices array.
  16849. * - indexCount (integer) : the number of indices to copy then from the startIndex.
  16850. * - mesh (Mesh) : the main mesh to create the submesh from.
  16851. * - renderingMesh (optional Mesh) : rendering mesh.
  16852. */
  16853. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  16854. }
  16855. }
  16856. declare module BABYLON {
  16857. class TransformNode extends Node {
  16858. static BILLBOARDMODE_NONE: number;
  16859. static BILLBOARDMODE_X: number;
  16860. static BILLBOARDMODE_Y: number;
  16861. static BILLBOARDMODE_Z: number;
  16862. static BILLBOARDMODE_ALL: number;
  16863. private _rotation;
  16864. private _rotationQuaternion;
  16865. protected _scaling: Vector3;
  16866. protected _isDirty: boolean;
  16867. private _transformToBoneReferal;
  16868. billboardMode: number;
  16869. scalingDeterminant: number;
  16870. infiniteDistance: boolean;
  16871. position: Vector3;
  16872. _poseMatrix: Matrix;
  16873. private _localWorld;
  16874. _worldMatrix: Matrix;
  16875. _worldMatrixDeterminant: number;
  16876. private _absolutePosition;
  16877. private _pivotMatrix;
  16878. private _pivotMatrixInverse;
  16879. private _postMultiplyPivotMatrix;
  16880. protected _isWorldMatrixFrozen: boolean;
  16881. /**
  16882. * An event triggered after the world matrix is updated
  16883. * @type {BABYLON.Observable}
  16884. */
  16885. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  16886. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  16887. /**
  16888. * Rotation property : a Vector3 depicting the rotation value in radians around each local axis X, Y, Z.
  16889. * If rotation quaternion is set, this Vector3 will (almost always) be the Zero vector!
  16890. * Default : (0.0, 0.0, 0.0)
  16891. */
  16892. rotation: Vector3;
  16893. /**
  16894. * Scaling property : a Vector3 depicting the mesh scaling along each local axis X, Y, Z.
  16895. * Default : (1.0, 1.0, 1.0)
  16896. */
  16897. /**
  16898. * Scaling property : a Vector3 depicting the mesh scaling along each local axis X, Y, Z.
  16899. * Default : (1.0, 1.0, 1.0)
  16900. */
  16901. scaling: Vector3;
  16902. /**
  16903. * Rotation Quaternion property : this a Quaternion object depicting the mesh rotation by using a unit quaternion.
  16904. * It's null by default.
  16905. * 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)
  16906. */
  16907. rotationQuaternion: Nullable<Quaternion>;
  16908. /**
  16909. * Returns the latest update of the World matrix
  16910. * Returns a Matrix.
  16911. */
  16912. getWorldMatrix(): Matrix;
  16913. /**
  16914. * Returns the latest update of the World matrix determinant.
  16915. */
  16916. protected _getWorldMatrixDeterminant(): number;
  16917. /**
  16918. * Returns directly the latest state of the mesh World matrix.
  16919. * A Matrix is returned.
  16920. */
  16921. readonly worldMatrixFromCache: Matrix;
  16922. /**
  16923. * Copies the paramater passed Matrix into the mesh Pose matrix.
  16924. * Returns the AbstractMesh.
  16925. */
  16926. updatePoseMatrix(matrix: Matrix): TransformNode;
  16927. /**
  16928. * Returns the mesh Pose matrix.
  16929. * Returned object : Matrix
  16930. */
  16931. getPoseMatrix(): Matrix;
  16932. _isSynchronized(): boolean;
  16933. _initCache(): void;
  16934. markAsDirty(property: string): TransformNode;
  16935. /**
  16936. * Returns the current mesh absolute position.
  16937. * Retuns a Vector3.
  16938. */
  16939. readonly absolutePosition: Vector3;
  16940. /**
  16941. * Sets a new matrix to apply before all other transformation
  16942. * @param matrix defines the transform matrix
  16943. * @returns the current TransformNode
  16944. */
  16945. setPreTransformMatrix(matrix: Matrix): TransformNode;
  16946. /**
  16947. * Sets a new pivot matrix to the current node
  16948. * @param matrix defines the new pivot matrix to use
  16949. * @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
  16950. * @returns the current TransformNode
  16951. */
  16952. setPivotMatrix(matrix: Matrix, postMultiplyPivotMatrix?: boolean): TransformNode;
  16953. /**
  16954. * Returns the mesh pivot matrix.
  16955. * Default : Identity.
  16956. * A Matrix is returned.
  16957. */
  16958. getPivotMatrix(): Matrix;
  16959. /**
  16960. * Prevents the World matrix to be computed any longer.
  16961. * Returns the AbstractMesh.
  16962. */
  16963. freezeWorldMatrix(): TransformNode;
  16964. /**
  16965. * Allows back the World matrix computation.
  16966. * Returns the AbstractMesh.
  16967. */
  16968. unfreezeWorldMatrix(): this;
  16969. /**
  16970. * True if the World matrix has been frozen.
  16971. * Returns a boolean.
  16972. */
  16973. readonly isWorldMatrixFrozen: boolean;
  16974. /**
  16975. * Retuns the mesh absolute position in the World.
  16976. * Returns a Vector3.
  16977. */
  16978. getAbsolutePosition(): Vector3;
  16979. /**
  16980. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  16981. * Returns the AbstractMesh.
  16982. */
  16983. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  16984. /**
  16985. * Sets the mesh position in its local space.
  16986. * Returns the AbstractMesh.
  16987. */
  16988. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  16989. /**
  16990. * Returns the mesh position in the local space from the current World matrix values.
  16991. * Returns a new Vector3.
  16992. */
  16993. getPositionExpressedInLocalSpace(): Vector3;
  16994. /**
  16995. * Translates the mesh along the passed Vector3 in its local space.
  16996. * Returns the AbstractMesh.
  16997. */
  16998. locallyTranslate(vector3: Vector3): TransformNode;
  16999. private static _lookAtVectorCache;
  17000. /**
  17001. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  17002. * @param targetPoint the position (must be in same space as current mesh) to look at
  17003. * @param yawCor optional yaw (y-axis) correction in radians
  17004. * @param pitchCor optional pitch (x-axis) correction in radians
  17005. * @param rollCor optional roll (z-axis) correction in radians
  17006. * @param space the choosen space of the target
  17007. * @returns the TransformNode.
  17008. */
  17009. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  17010. /**
  17011. * Returns a new Vector3 what is the localAxis, expressed in the mesh local space, rotated like the mesh.
  17012. * This Vector3 is expressed in the World space.
  17013. */
  17014. getDirection(localAxis: Vector3): Vector3;
  17015. /**
  17016. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  17017. * localAxis is expressed in the mesh local space.
  17018. * result is computed in the Wordl space from the mesh World matrix.
  17019. * Returns the AbstractMesh.
  17020. */
  17021. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  17022. /**
  17023. * Sets a new pivot point to the current node
  17024. * @param point defines the new pivot point to use
  17025. * @param space defines if the point is in world or local space (local by default)
  17026. * @returns the current TransformNode
  17027. */
  17028. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  17029. /**
  17030. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  17031. */
  17032. getPivotPoint(): Vector3;
  17033. /**
  17034. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  17035. * Returns the AbstractMesh.
  17036. */
  17037. getPivotPointToRef(result: Vector3): TransformNode;
  17038. /**
  17039. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  17040. */
  17041. getAbsolutePivotPoint(): Vector3;
  17042. /**
  17043. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  17044. * Returns the AbstractMesh.
  17045. */
  17046. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  17047. /**
  17048. * Defines the passed node as the parent of the current node.
  17049. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  17050. * Returns the TransformNode.
  17051. */
  17052. setParent(node: Nullable<Node>): TransformNode;
  17053. private _nonUniformScaling;
  17054. readonly nonUniformScaling: boolean;
  17055. _updateNonUniformScalingState(value: boolean): boolean;
  17056. /**
  17057. * Attach the current TransformNode to another TransformNode associated with a bone
  17058. * @param bone Bone affecting the TransformNode
  17059. * @param affectedTransformNode TransformNode associated with the bone
  17060. */
  17061. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  17062. detachFromBone(): TransformNode;
  17063. private static _rotationAxisCache;
  17064. /**
  17065. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  17066. * space (default LOCAL) can be either BABYLON.Space.LOCAL, either BABYLON.Space.WORLD.
  17067. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  17068. * The passed axis is also normalized.
  17069. * Returns the AbstractMesh.
  17070. */
  17071. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  17072. /**
  17073. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  17074. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  17075. * The passed axis is also normalized.
  17076. * Returns the AbstractMesh.
  17077. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  17078. */
  17079. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  17080. /**
  17081. * Translates the mesh along the axis vector for the passed distance in the given space.
  17082. * space (default LOCAL) can be either BABYLON.Space.LOCAL, either BABYLON.Space.WORLD.
  17083. * Returns the AbstractMesh.
  17084. */
  17085. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  17086. /**
  17087. * Adds a rotation step to the mesh current rotation.
  17088. * x, y, z are Euler angles expressed in radians.
  17089. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  17090. * This means this rotation is made in the mesh local space only.
  17091. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  17092. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  17093. * ```javascript
  17094. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  17095. * ```
  17096. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  17097. * 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.
  17098. * Returns the AbstractMesh.
  17099. */
  17100. addRotation(x: number, y: number, z: number): TransformNode;
  17101. /**
  17102. * Computes the mesh World matrix and returns it.
  17103. * If the mesh world matrix is frozen, this computation does nothing more than returning the last frozen values.
  17104. * If the parameter `force` is let to `false` (default), the current cached World matrix is returned.
  17105. * If the parameter `force`is set to `true`, the actual computation is done.
  17106. * Returns the mesh World Matrix.
  17107. */
  17108. computeWorldMatrix(force?: boolean): Matrix;
  17109. protected _afterComputeWorldMatrix(): void;
  17110. /**
  17111. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  17112. * @param func: callback function to add
  17113. *
  17114. * Returns the TransformNode.
  17115. */
  17116. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  17117. /**
  17118. * Removes a registered callback function.
  17119. * Returns the TransformNode.
  17120. */
  17121. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  17122. /**
  17123. * Clone the current transform node
  17124. * Returns the new transform node
  17125. * @param name Name of the new clone
  17126. * @param newParent New parent for the clone
  17127. * @param doNotCloneChildren Do not clone children hierarchy
  17128. */
  17129. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  17130. serialize(currentSerializationObject?: any): any;
  17131. /**
  17132. * Returns a new TransformNode object parsed from the source provided.
  17133. * The parameter `parsedMesh` is the source.
  17134. * The parameter `rootUrl` is a string, it's the root URL to prefix the `delayLoadingFile` property with
  17135. */
  17136. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  17137. /**
  17138. * Disposes the TransformNode.
  17139. * By default, all the children are also disposed unless the parameter `doNotRecurse` is set to `true`.
  17140. * Returns nothing.
  17141. */
  17142. dispose(doNotRecurse?: boolean): void;
  17143. }
  17144. }
  17145. declare module BABYLON {
  17146. class VertexBuffer {
  17147. private _buffer;
  17148. private _kind;
  17149. private _offset;
  17150. private _size;
  17151. private _stride;
  17152. private _ownsBuffer;
  17153. private _instanced;
  17154. private _instanceDivisor;
  17155. /**
  17156. * Gets or sets the instance divisor when in instanced mode
  17157. */
  17158. instanceDivisor: number;
  17159. constructor(engine: any, data: FloatArray | Buffer, kind: string, updatable: boolean, postponeInternalCreation?: boolean, stride?: number, instanced?: boolean, offset?: number, size?: number);
  17160. _rebuild(): void;
  17161. /**
  17162. * Returns the kind of the VertexBuffer (string).
  17163. */
  17164. getKind(): string;
  17165. /**
  17166. * Boolean : is the VertexBuffer updatable ?
  17167. */
  17168. isUpdatable(): boolean;
  17169. /**
  17170. * Returns an array of numbers or a Float32Array containing the VertexBuffer data.
  17171. */
  17172. getData(): Nullable<FloatArray>;
  17173. /**
  17174. * Returns the WebGLBuffer associated to the VertexBuffer.
  17175. */
  17176. getBuffer(): Nullable<WebGLBuffer>;
  17177. /**
  17178. * Returns the stride of the VertexBuffer (integer).
  17179. */
  17180. getStrideSize(): number;
  17181. /**
  17182. * Returns the offset (integer).
  17183. */
  17184. getOffset(): number;
  17185. /**
  17186. * Returns the VertexBuffer total size (integer).
  17187. */
  17188. getSize(): number;
  17189. /**
  17190. * Boolean : is the WebGLBuffer of the VertexBuffer instanced now ?
  17191. */
  17192. getIsInstanced(): boolean;
  17193. /**
  17194. * Returns the instancing divisor, zero for non-instanced (integer).
  17195. */
  17196. getInstanceDivisor(): number;
  17197. /**
  17198. * Creates the underlying WebGLBuffer from the passed numeric array or Float32Array.
  17199. * Returns the created WebGLBuffer.
  17200. */
  17201. create(data?: FloatArray): void;
  17202. /**
  17203. * Updates the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  17204. * This function will create a new buffer if the current one is not updatable
  17205. * Returns the updated WebGLBuffer.
  17206. */
  17207. update(data: FloatArray): void;
  17208. /**
  17209. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  17210. * Returns the directly updated WebGLBuffer.
  17211. */
  17212. updateDirectly(data: Float32Array, offset: number): void;
  17213. /**
  17214. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  17215. */
  17216. dispose(): void;
  17217. private static _PositionKind;
  17218. private static _NormalKind;
  17219. private static _TangentKind;
  17220. private static _UVKind;
  17221. private static _UV2Kind;
  17222. private static _UV3Kind;
  17223. private static _UV4Kind;
  17224. private static _UV5Kind;
  17225. private static _UV6Kind;
  17226. private static _ColorKind;
  17227. private static _MatricesIndicesKind;
  17228. private static _MatricesWeightsKind;
  17229. private static _MatricesIndicesExtraKind;
  17230. private static _MatricesWeightsExtraKind;
  17231. static readonly PositionKind: string;
  17232. static readonly NormalKind: string;
  17233. static readonly TangentKind: string;
  17234. static readonly UVKind: string;
  17235. static readonly UV2Kind: string;
  17236. static readonly UV3Kind: string;
  17237. static readonly UV4Kind: string;
  17238. static readonly UV5Kind: string;
  17239. static readonly UV6Kind: string;
  17240. static readonly ColorKind: string;
  17241. static readonly MatricesIndicesKind: string;
  17242. static readonly MatricesWeightsKind: string;
  17243. static readonly MatricesIndicesExtraKind: string;
  17244. static readonly MatricesWeightsExtraKind: string;
  17245. /**
  17246. * Deduces the stride given a kind.
  17247. * @param kind The kind string to deduce
  17248. * @returns The deduced stride
  17249. */
  17250. static DeduceStride(kind: string): number;
  17251. }
  17252. }
  17253. declare module BABYLON {
  17254. class MorphTarget {
  17255. name: string;
  17256. animations: Animation[];
  17257. private _positions;
  17258. private _normals;
  17259. private _tangents;
  17260. private _influence;
  17261. onInfluenceChanged: Observable<boolean>;
  17262. influence: number;
  17263. constructor(name: string, influence?: number);
  17264. readonly hasPositions: boolean;
  17265. readonly hasNormals: boolean;
  17266. readonly hasTangents: boolean;
  17267. setPositions(data: Nullable<FloatArray>): void;
  17268. getPositions(): Nullable<FloatArray>;
  17269. setNormals(data: Nullable<FloatArray>): void;
  17270. getNormals(): Nullable<FloatArray>;
  17271. setTangents(data: Nullable<FloatArray>): void;
  17272. getTangents(): Nullable<FloatArray>;
  17273. /**
  17274. * Serializes the current target into a Serialization object.
  17275. * Returns the serialized object.
  17276. */
  17277. serialize(): any;
  17278. static Parse(serializationObject: any): MorphTarget;
  17279. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  17280. }
  17281. }
  17282. declare module BABYLON {
  17283. class MorphTargetManager {
  17284. private _targets;
  17285. private _targetObservable;
  17286. private _activeTargets;
  17287. private _scene;
  17288. private _influences;
  17289. private _supportsNormals;
  17290. private _supportsTangents;
  17291. private _vertexCount;
  17292. private _uniqueId;
  17293. private _tempInfluences;
  17294. constructor(scene?: Nullable<Scene>);
  17295. readonly uniqueId: number;
  17296. readonly vertexCount: number;
  17297. readonly supportsNormals: boolean;
  17298. readonly supportsTangents: boolean;
  17299. readonly numTargets: number;
  17300. readonly numInfluencers: number;
  17301. readonly influences: Float32Array;
  17302. getActiveTarget(index: number): MorphTarget;
  17303. getTarget(index: number): MorphTarget;
  17304. addTarget(target: MorphTarget): void;
  17305. removeTarget(target: MorphTarget): void;
  17306. /**
  17307. * Serializes the current manager into a Serialization object.
  17308. * Returns the serialized object.
  17309. */
  17310. serialize(): any;
  17311. private _syncActiveTargets(needUpdate);
  17312. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  17313. }
  17314. }
  17315. declare module BABYLON {
  17316. /**
  17317. * This represents a GPU particle system in Babylon
  17318. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  17319. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  17320. */
  17321. class GPUParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  17322. /**
  17323. * The id of the Particle system.
  17324. */
  17325. id: string;
  17326. /**
  17327. * The friendly name of the Particle system.
  17328. */
  17329. name: string;
  17330. /**
  17331. * The emitter represents the Mesh or position we are attaching the particle system to.
  17332. */
  17333. emitter: Nullable<AbstractMesh | Vector3>;
  17334. /**
  17335. * The rendering group used by the Particle system to chose when to render.
  17336. */
  17337. renderingGroupId: number;
  17338. /**
  17339. * The layer mask we are rendering the particles through.
  17340. */
  17341. layerMask: number;
  17342. private _capacity;
  17343. private _activeCount;
  17344. private _currentActiveCount;
  17345. private _renderEffect;
  17346. private _updateEffect;
  17347. private _buffer0;
  17348. private _buffer1;
  17349. private _spriteBuffer;
  17350. private _updateVAO;
  17351. private _renderVAO;
  17352. private _targetIndex;
  17353. private _sourceBuffer;
  17354. private _targetBuffer;
  17355. private _scene;
  17356. private _engine;
  17357. private _currentRenderId;
  17358. private _started;
  17359. private _stopped;
  17360. private _timeDelta;
  17361. private _randomTexture;
  17362. private readonly _attributesStrideSize;
  17363. private _updateEffectOptions;
  17364. private _randomTextureSize;
  17365. private _actualFrame;
  17366. /**
  17367. * List of animations used by the particle system.
  17368. */
  17369. animations: Animation[];
  17370. /**
  17371. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  17372. */
  17373. static readonly IsSupported: boolean;
  17374. /**
  17375. * An event triggered when the system is disposed.
  17376. */
  17377. onDisposeObservable: Observable<GPUParticleSystem>;
  17378. /**
  17379. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  17380. */
  17381. updateSpeed: number;
  17382. /**
  17383. * The amount of time the particle system is running (depends of the overall update speed).
  17384. */
  17385. targetStopDuration: number;
  17386. /**
  17387. * The texture used to render each particle. (this can be a spritesheet)
  17388. */
  17389. particleTexture: Nullable<Texture>;
  17390. /**
  17391. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  17392. */
  17393. blendMode: number;
  17394. /**
  17395. * Minimum life time of emitting particles.
  17396. */
  17397. minLifeTime: number;
  17398. /**
  17399. * Maximum life time of emitting particles.
  17400. */
  17401. maxLifeTime: number;
  17402. /**
  17403. * Minimum Size of emitting particles.
  17404. */
  17405. minSize: number;
  17406. /**
  17407. * Maximum Size of emitting particles.
  17408. */
  17409. maxSize: number;
  17410. /**
  17411. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  17412. */
  17413. color1: Color4;
  17414. /**
  17415. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  17416. */
  17417. color2: Color4;
  17418. /**
  17419. * Color the particle will have at the end of its lifetime.
  17420. */
  17421. colorDead: Color4;
  17422. /**
  17423. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  17424. */
  17425. emitRate: number;
  17426. /**
  17427. * You can use gravity if you want to give an orientation to your particles.
  17428. */
  17429. gravity: Vector3;
  17430. /**
  17431. * Minimum power of emitting particles.
  17432. */
  17433. minEmitPower: number;
  17434. /**
  17435. * Maximum power of emitting particles.
  17436. */
  17437. maxEmitPower: number;
  17438. /**
  17439. * The particle emitter type defines the emitter used by the particle system.
  17440. * It can be for example box, sphere, or cone...
  17441. */
  17442. particleEmitterType: Nullable<IParticleEmitterType>;
  17443. /**
  17444. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17445. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17446. */
  17447. direction1: Vector3;
  17448. /**
  17449. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17450. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17451. */
  17452. direction2: Vector3;
  17453. /**
  17454. * 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.
  17455. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17456. */
  17457. minEmitBox: Vector3;
  17458. /**
  17459. * 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.
  17460. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17461. */
  17462. maxEmitBox: Vector3;
  17463. /**
  17464. * Gets the maximum number of particles active at the same time.
  17465. * @returns The max number of active particles.
  17466. */
  17467. getCapacity(): number;
  17468. /**
  17469. * Gets or set the number of active particles
  17470. */
  17471. activeParticleCount: number;
  17472. /**
  17473. * Gets Wether the system has been started.
  17474. * @returns True if it has been started, otherwise false.
  17475. */
  17476. isStarted(): boolean;
  17477. /**
  17478. * Starts the particle system and begins to emit.
  17479. */
  17480. start(): void;
  17481. /**
  17482. * Stops the particle system.
  17483. */
  17484. stop(): void;
  17485. /**
  17486. * Remove all active particles
  17487. */
  17488. reset(): void;
  17489. /**
  17490. * Returns the string "GPUParticleSystem"
  17491. * @returns a string containing the class name
  17492. */
  17493. getClassName(): string;
  17494. /**
  17495. * Instantiates a GPU particle system.
  17496. * 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.
  17497. * @param name The name of the particle system
  17498. * @param capacity The max number of particles alive at the same time
  17499. * @param scene The scene the particle system belongs to
  17500. */
  17501. constructor(name: string, options: Partial<{
  17502. capacity: number;
  17503. randomTextureSize: number;
  17504. }>, scene: Scene);
  17505. private _createUpdateVAO(source);
  17506. private _createRenderVAO(source, spriteSource);
  17507. private _initialize(force?);
  17508. /** @ignore */
  17509. _recreateUpdateEffect(): void;
  17510. /** @ignore */
  17511. _recreateRenderEffect(): void;
  17512. /**
  17513. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  17514. */
  17515. animate(): void;
  17516. /**
  17517. * Renders the particle system in its current state.
  17518. * @returns the current number of particles
  17519. */
  17520. render(): number;
  17521. /**
  17522. * Rebuilds the particle system
  17523. */
  17524. rebuild(): void;
  17525. private _releaseBuffers();
  17526. private _releaseVAOs();
  17527. /**
  17528. * Disposes the particle system and free the associated resources
  17529. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  17530. */
  17531. dispose(disposeTexture?: boolean): void;
  17532. /**
  17533. * Clones the particle system.
  17534. * @param name The name of the cloned object
  17535. * @param newEmitter The new emitter to use
  17536. * @returns the cloned particle system
  17537. */
  17538. clone(name: string, newEmitter: any): Nullable<GPUParticleSystem>;
  17539. /**
  17540. * Serializes the particle system to a JSON object.
  17541. * @returns the JSON object
  17542. */
  17543. serialize(): any;
  17544. /**
  17545. * Parses a JSON object to create a GPU particle system.
  17546. * @param parsedParticleSystem The JSON object to parse
  17547. * @param scene The scene to create the particle system in
  17548. * @param rootUrl The root url to use to load external dependencies like texture
  17549. * @returns the parsed GPU particle system
  17550. */
  17551. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string): GPUParticleSystem;
  17552. }
  17553. }
  17554. declare module BABYLON {
  17555. /**
  17556. * Interface representing a particle system in Babylon.
  17557. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  17558. * A particle system represents a way to manage particles (@see Particle) from their emission to their animation and rendering.
  17559. */
  17560. interface IParticleSystem {
  17561. /**
  17562. * The id of the Particle system.
  17563. */
  17564. id: string;
  17565. /**
  17566. * The name of the Particle system.
  17567. */
  17568. name: string;
  17569. /**
  17570. * The emitter represents the Mesh or position we are attaching the particle system to.
  17571. */
  17572. emitter: Nullable<AbstractMesh | Vector3>;
  17573. /**
  17574. * The rendering group used by the Particle system to chose when to render.
  17575. */
  17576. renderingGroupId: number;
  17577. /**
  17578. * The layer mask we are rendering the particles through.
  17579. */
  17580. layerMask: number;
  17581. /**
  17582. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  17583. */
  17584. updateSpeed: number;
  17585. /**
  17586. * The amount of time the particle system is running (depends of the overall update speed).
  17587. */
  17588. targetStopDuration: number;
  17589. /**
  17590. * The texture used to render each particle. (this can be a spritesheet)
  17591. */
  17592. particleTexture: Nullable<Texture>;
  17593. /**
  17594. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  17595. */
  17596. blendMode: number;
  17597. /**
  17598. * Minimum life time of emitting particles.
  17599. */
  17600. minLifeTime: number;
  17601. /**
  17602. * Maximum life time of emitting particles.
  17603. */
  17604. maxLifeTime: number;
  17605. /**
  17606. * Minimum Size of emitting particles.
  17607. */
  17608. minSize: number;
  17609. /**
  17610. * Maximum Size of emitting particles.
  17611. */
  17612. maxSize: number;
  17613. /**
  17614. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  17615. */
  17616. color1: Color4;
  17617. /**
  17618. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  17619. */
  17620. color2: Color4;
  17621. /**
  17622. * Color the particle will have at the end of its lifetime.
  17623. */
  17624. colorDead: Color4;
  17625. /**
  17626. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  17627. */
  17628. emitRate: number;
  17629. /**
  17630. * You can use gravity if you want to give an orientation to your particles.
  17631. */
  17632. gravity: Vector3;
  17633. /**
  17634. * Minimum power of emitting particles.
  17635. */
  17636. minEmitPower: number;
  17637. /**
  17638. * Maximum power of emitting particles.
  17639. */
  17640. maxEmitPower: number;
  17641. /**
  17642. * The particle emitter type defines the emitter used by the particle system.
  17643. * It can be for example box, sphere, or cone...
  17644. */
  17645. particleEmitterType: Nullable<IParticleEmitterType>;
  17646. /**
  17647. * Gets the maximum number of particles active at the same time.
  17648. * @returns The max number of active particles.
  17649. */
  17650. getCapacity(): number;
  17651. /**
  17652. * Gets Wether the system has been started.
  17653. * @returns True if it has been started, otherwise false.
  17654. */
  17655. isStarted(): boolean;
  17656. /**
  17657. * Gets if the particle system has been started.
  17658. * @return true if the system has been started, otherwise false.
  17659. */
  17660. isStarted(): boolean;
  17661. /**
  17662. * Animates the particle system for this frame.
  17663. */
  17664. animate(): void;
  17665. /**
  17666. * Renders the particle system in its current state.
  17667. * @returns the current number of particles
  17668. */
  17669. render(): number;
  17670. /**
  17671. * Dispose the particle system and frees its associated resources.
  17672. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  17673. */
  17674. dispose(disposeTexture?: boolean): void;
  17675. /**
  17676. * Clones the particle system.
  17677. * @param name The name of the cloned object
  17678. * @param newEmitter The new emitter to use
  17679. * @returns the cloned particle system
  17680. */
  17681. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  17682. /**
  17683. * Serializes the particle system to a JSON object.
  17684. * @returns the JSON object
  17685. */
  17686. serialize(): any;
  17687. /**
  17688. * Rebuild the particle system
  17689. */
  17690. rebuild(): void;
  17691. /**
  17692. * Starts the particle system and begins to emit.
  17693. */
  17694. start(): void;
  17695. /**
  17696. * Stops the particle system.
  17697. */
  17698. stop(): void;
  17699. /**
  17700. * Remove all active particles
  17701. */
  17702. reset(): void;
  17703. }
  17704. }
  17705. declare module BABYLON {
  17706. /**
  17707. * A particle represents one of the element emitted by a particle system.
  17708. * This is mainly define by its coordinates, direction, velocity and age.
  17709. */
  17710. class Particle {
  17711. private particleSystem;
  17712. /**
  17713. * The world position of the particle in the scene.
  17714. */
  17715. position: Vector3;
  17716. /**
  17717. * The world direction of the particle in the scene.
  17718. */
  17719. direction: Vector3;
  17720. /**
  17721. * The color of the particle.
  17722. */
  17723. color: Color4;
  17724. /**
  17725. * The color change of the particle per step.
  17726. */
  17727. colorStep: Color4;
  17728. /**
  17729. * Defines how long will the life of the particle be.
  17730. */
  17731. lifeTime: number;
  17732. /**
  17733. * The current age of the particle.
  17734. */
  17735. age: number;
  17736. /**
  17737. * The current size of the particle.
  17738. */
  17739. size: number;
  17740. /**
  17741. * The current angle of the particle.
  17742. */
  17743. angle: number;
  17744. /**
  17745. * Defines how fast is the angle changing.
  17746. */
  17747. angularSpeed: number;
  17748. /**
  17749. * Defines the cell index used by the particle to be rendered from a sprite.
  17750. */
  17751. cellIndex: number;
  17752. private _currentFrameCounter;
  17753. /**
  17754. * Creates a new instance of @see Particle
  17755. * @param particleSystem the particle system the particle belongs to
  17756. */
  17757. constructor(particleSystem: ParticleSystem);
  17758. /**
  17759. * Defines how the sprite cell index is updated for the particle. This is
  17760. * defined as a callback.
  17761. */
  17762. updateCellIndex: (scaledUpdateSpeed: number) => void;
  17763. private updateCellIndexWithSpeedCalculated(scaledUpdateSpeed);
  17764. private updateCellIndexWithCustomSpeed();
  17765. /**
  17766. * Copy the properties of particle to another one.
  17767. * @param other the particle to copy the information to.
  17768. */
  17769. copyTo(other: Particle): void;
  17770. }
  17771. }
  17772. declare module BABYLON {
  17773. /**
  17774. * This represents a particle system in Babylon.
  17775. * 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.
  17776. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  17777. * @example https://doc.babylonjs.com/babylon101/particles
  17778. */
  17779. class ParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  17780. /**
  17781. * Source color is added to the destination color without alpha affecting the result.
  17782. */
  17783. static BLENDMODE_ONEONE: number;
  17784. /**
  17785. * Blend current color and particle color using particle’s alpha.
  17786. */
  17787. static BLENDMODE_STANDARD: number;
  17788. /**
  17789. * List of animations used by the particle system.
  17790. */
  17791. animations: Animation[];
  17792. /**
  17793. * The id of the Particle system.
  17794. */
  17795. id: string;
  17796. /**
  17797. * The friendly name of the Particle system.
  17798. */
  17799. name: string;
  17800. /**
  17801. * The rendering group used by the Particle system to chose when to render.
  17802. */
  17803. renderingGroupId: number;
  17804. /**
  17805. * The emitter represents the Mesh or position we are attaching the particle system to.
  17806. */
  17807. emitter: Nullable<AbstractMesh | Vector3>;
  17808. /**
  17809. * The maximum number of particles to emit per frame
  17810. */
  17811. emitRate: number;
  17812. /**
  17813. * If you want to launch only a few particles at once, that can be done, as well.
  17814. */
  17815. manualEmitCount: number;
  17816. /**
  17817. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  17818. */
  17819. updateSpeed: number;
  17820. /**
  17821. * The amount of time the particle system is running (depends of the overall update speed).
  17822. */
  17823. targetStopDuration: number;
  17824. /**
  17825. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  17826. */
  17827. disposeOnStop: boolean;
  17828. /**
  17829. * Minimum power of emitting particles.
  17830. */
  17831. minEmitPower: number;
  17832. /**
  17833. * Maximum power of emitting particles.
  17834. */
  17835. maxEmitPower: number;
  17836. /**
  17837. * Minimum life time of emitting particles.
  17838. */
  17839. minLifeTime: number;
  17840. /**
  17841. * Maximum life time of emitting particles.
  17842. */
  17843. maxLifeTime: number;
  17844. /**
  17845. * Minimum Size of emitting particles.
  17846. */
  17847. minSize: number;
  17848. /**
  17849. * Maximum Size of emitting particles.
  17850. */
  17851. maxSize: number;
  17852. /**
  17853. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  17854. */
  17855. minAngularSpeed: number;
  17856. /**
  17857. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  17858. */
  17859. maxAngularSpeed: number;
  17860. /**
  17861. * The texture used to render each particle. (this can be a spritesheet)
  17862. */
  17863. particleTexture: Nullable<Texture>;
  17864. /**
  17865. * The layer mask we are rendering the particles through.
  17866. */
  17867. layerMask: number;
  17868. /**
  17869. * This can help using your own shader to render the particle system.
  17870. * The according effect will be created
  17871. */
  17872. customShader: any;
  17873. /**
  17874. * By default particle system starts as soon as they are created. This prevents the
  17875. * automatic start to happen and let you decide when to start emitting particles.
  17876. */
  17877. preventAutoStart: boolean;
  17878. /**
  17879. * This function can be defined to provide custom update for active particles.
  17880. * This function will be called instead of regular update (age, position, color, etc.).
  17881. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  17882. */
  17883. updateFunction: (particles: Particle[]) => void;
  17884. /**
  17885. * Callback triggered when the particle animation is ending.
  17886. */
  17887. onAnimationEnd: Nullable<() => void>;
  17888. /**
  17889. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  17890. */
  17891. blendMode: number;
  17892. /**
  17893. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  17894. * to override the particles.
  17895. */
  17896. forceDepthWrite: boolean;
  17897. /**
  17898. * You can use gravity if you want to give an orientation to your particles.
  17899. */
  17900. gravity: Vector3;
  17901. /**
  17902. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17903. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17904. */
  17905. direction1: Vector3;
  17906. /**
  17907. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17908. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17909. */
  17910. direction2: Vector3;
  17911. /**
  17912. * 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.
  17913. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17914. */
  17915. minEmitBox: Vector3;
  17916. /**
  17917. * 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.
  17918. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17919. */
  17920. maxEmitBox: Vector3;
  17921. /**
  17922. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  17923. */
  17924. color1: Color4;
  17925. /**
  17926. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  17927. */
  17928. color2: Color4;
  17929. /**
  17930. * Color the particle will have at the end of its lifetime.
  17931. */
  17932. colorDead: Color4;
  17933. /**
  17934. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel.
  17935. */
  17936. textureMask: Color4;
  17937. /**
  17938. * The particle emitter type defines the emitter used by the particle system.
  17939. * It can be for example box, sphere, or cone...
  17940. */
  17941. particleEmitterType: IParticleEmitterType;
  17942. /**
  17943. * This function can be defined to specify initial direction for every new particle.
  17944. * It by default use the emitterType defined function.
  17945. */
  17946. startDirectionFunction: (emitPower: number, worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  17947. /**
  17948. * This function can be defined to specify initial position for every new particle.
  17949. * It by default use the emitterType defined function.
  17950. */
  17951. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  17952. /**
  17953. * If using a spritesheet (isAnimationSheetEnabled), defines if the sprite animation should loop between startSpriteCellID and endSpriteCellID or not.
  17954. */
  17955. spriteCellLoop: boolean;
  17956. /**
  17957. * If using a spritesheet (isAnimationSheetEnabled) and spriteCellLoop defines the speed of the sprite loop.
  17958. */
  17959. spriteCellChangeSpeed: number;
  17960. /**
  17961. * If using a spritesheet (isAnimationSheetEnabled) and spriteCellLoop defines the first sprite cell to display.
  17962. */
  17963. startSpriteCellID: number;
  17964. /**
  17965. * If using a spritesheet (isAnimationSheetEnabled) and spriteCellLoop defines the last sprite cell to display.
  17966. */
  17967. endSpriteCellID: number;
  17968. /**
  17969. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use.
  17970. */
  17971. spriteCellWidth: number;
  17972. /**
  17973. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use.
  17974. */
  17975. spriteCellHeight: number;
  17976. /**
  17977. * An event triggered when the system is disposed.
  17978. */
  17979. onDisposeObservable: Observable<ParticleSystem>;
  17980. private _onDisposeObserver;
  17981. /**
  17982. * Sets a callback that will be triggered when the system is disposed.
  17983. */
  17984. onDispose: () => void;
  17985. /**
  17986. * Gets wether an animation sprite sheet is enabled or not on the particle system.
  17987. */
  17988. readonly isAnimationSheetEnabled: Boolean;
  17989. private _particles;
  17990. private _epsilon;
  17991. private _capacity;
  17992. private _scene;
  17993. private _stockParticles;
  17994. private _newPartsExcess;
  17995. private _vertexData;
  17996. private _vertexBuffer;
  17997. private _vertexBuffers;
  17998. private _indexBuffer;
  17999. private _effect;
  18000. private _customEffect;
  18001. private _cachedDefines;
  18002. private _scaledColorStep;
  18003. private _colorDiff;
  18004. private _scaledDirection;
  18005. private _scaledGravity;
  18006. private _currentRenderId;
  18007. private _alive;
  18008. private _started;
  18009. private _stopped;
  18010. private _actualFrame;
  18011. private _scaledUpdateSpeed;
  18012. private _vertexBufferSize;
  18013. private _isAnimationSheetEnabled;
  18014. /**
  18015. * Gets the current list of active particles
  18016. */
  18017. readonly particles: Particle[];
  18018. /**
  18019. * Returns the string "ParticleSystem"
  18020. * @returns a string containing the class name
  18021. */
  18022. getClassName(): string;
  18023. /**
  18024. * Instantiates a particle system.
  18025. * 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.
  18026. * @param name The name of the particle system
  18027. * @param capacity The max number of particles alive at the same time
  18028. * @param scene The scene the particle system belongs to
  18029. * @param customEffect a custom effect used to change the way particles are rendered by default
  18030. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  18031. * @param epsilon Offset used to render the particles
  18032. */
  18033. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  18034. private _createIndexBuffer();
  18035. /**
  18036. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  18037. * Its lifetime will start back at 0.
  18038. * @param particle The particle to recycle
  18039. */
  18040. recycleParticle(particle: Particle): void;
  18041. /**
  18042. * Gets the maximum number of particles active at the same time.
  18043. * @returns The max number of active particles.
  18044. */
  18045. getCapacity(): number;
  18046. /**
  18047. * Gets Wether there are still active particles in the system.
  18048. * @returns True if it is alive, otherwise false.
  18049. */
  18050. isAlive(): boolean;
  18051. /**
  18052. * Gets Wether the system has been started.
  18053. * @returns True if it has been started, otherwise false.
  18054. */
  18055. isStarted(): boolean;
  18056. /**
  18057. * Starts the particle system and begins to emit.
  18058. */
  18059. start(): void;
  18060. /**
  18061. * Stops the particle system.
  18062. */
  18063. stop(): void;
  18064. /**
  18065. * Remove all active particles
  18066. */
  18067. reset(): void;
  18068. /**
  18069. * @ignore (for internal use only)
  18070. */
  18071. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  18072. /**
  18073. * @ignore (for internal use only)
  18074. */
  18075. _appendParticleVertexWithAnimation(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  18076. private _update(newParticles);
  18077. private _getEffect();
  18078. /**
  18079. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  18080. */
  18081. animate(): void;
  18082. private _appendParticleVertexes;
  18083. private _appenedParticleVertexesWithSheet(offset, particle);
  18084. private _appenedParticleVertexesNoSheet(offset, particle);
  18085. /**
  18086. * Rebuilds the particle system.
  18087. */
  18088. rebuild(): void;
  18089. /**
  18090. * Renders the particle system in its current state.
  18091. * @returns the current number of particles
  18092. */
  18093. render(): number;
  18094. /**
  18095. * Disposes the particle system and free the associated resources
  18096. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  18097. */
  18098. dispose(disposeTexture?: boolean): void;
  18099. /**
  18100. * Creates a Sphere Emitter for the particle system. (emits along the sphere radius)
  18101. * @param radius The radius of the sphere to emit from
  18102. * @returns the emitter
  18103. */
  18104. createSphereEmitter(radius?: number): SphereParticleEmitter;
  18105. /**
  18106. * Creates a Directed Sphere Emitter for the particle system. (emits between direction1 and direction2)
  18107. * @param radius The radius of the sphere to emit from
  18108. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  18109. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  18110. * @returns the emitter
  18111. */
  18112. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  18113. /**
  18114. * Creates a Cone Emitter for the particle system. (emits from the cone to the particle position)
  18115. * @param radius The radius of the cone to emit from
  18116. * @param angle The base angle of the cone
  18117. * @returns the emitter
  18118. */
  18119. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  18120. /**
  18121. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  18122. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  18123. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  18124. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  18125. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  18126. * @returns the emitter
  18127. */
  18128. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  18129. /**
  18130. * Clones the particle system.
  18131. * @param name The name of the cloned object
  18132. * @param newEmitter The new emitter to use
  18133. * @returns the cloned particle system
  18134. */
  18135. clone(name: string, newEmitter: any): ParticleSystem;
  18136. /**
  18137. * Serializes the particle system to a JSON object.
  18138. * @returns the JSON object
  18139. */
  18140. serialize(): any;
  18141. /**
  18142. * Parses a JSON object to create a particle system.
  18143. * @param parsedParticleSystem The JSON object to parse
  18144. * @param scene The scene to create the particle system in
  18145. * @param rootUrl The root url to use to load external dependencies like texture
  18146. * @returns the Parsed particle system
  18147. */
  18148. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string): ParticleSystem;
  18149. }
  18150. }
  18151. declare module BABYLON {
  18152. /**
  18153. * Represents one particle of a solid particle system.
  18154. * @see SolidParticleSystem
  18155. */
  18156. class SolidParticle {
  18157. /**
  18158. * particle global index
  18159. */
  18160. idx: number;
  18161. /**
  18162. * The color of the particle
  18163. */
  18164. color: Nullable<Color4>;
  18165. /**
  18166. * The world space position of the particle.
  18167. */
  18168. position: Vector3;
  18169. /**
  18170. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  18171. */
  18172. rotation: Vector3;
  18173. /**
  18174. * The world space rotation quaternion of the particle.
  18175. */
  18176. rotationQuaternion: Nullable<Quaternion>;
  18177. /**
  18178. * The scaling of the particle.
  18179. */
  18180. scaling: Vector3;
  18181. /**
  18182. * The uvs of the particle.
  18183. */
  18184. uvs: Vector4;
  18185. /**
  18186. * The current speed of the particle.
  18187. */
  18188. velocity: Vector3;
  18189. /**
  18190. * The pivot point in the particle local space.
  18191. */
  18192. pivot: Vector3;
  18193. /**
  18194. * Must the particle be translated from its pivot point in its local space ?
  18195. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  18196. * Default : false
  18197. */
  18198. translateFromPivot: boolean;
  18199. /**
  18200. * Is the particle active or not ?
  18201. */
  18202. alive: boolean;
  18203. /**
  18204. * Is the particle visible or not ?
  18205. */
  18206. isVisible: boolean;
  18207. /**
  18208. * Index of this particle in the global "positions" array (Internal use)
  18209. */
  18210. _pos: number;
  18211. /**
  18212. * Index of this particle in the global "indices" array (Internal use)
  18213. */
  18214. _ind: number;
  18215. /**
  18216. * ModelShape of this particle (Internal use)
  18217. */
  18218. _model: ModelShape;
  18219. /**
  18220. * ModelShape id of this particle
  18221. */
  18222. shapeId: number;
  18223. /**
  18224. * Index of the particle in its shape id (Internal use)
  18225. */
  18226. idxInShape: number;
  18227. /**
  18228. * Reference to the shape model BoundingInfo object (Internal use)
  18229. */
  18230. _modelBoundingInfo: BoundingInfo;
  18231. /**
  18232. * Particle BoundingInfo object (Internal use)
  18233. */
  18234. _boundingInfo: BoundingInfo;
  18235. /**
  18236. * Reference to the SPS what the particle belongs to (Internal use)
  18237. */
  18238. _sps: SolidParticleSystem;
  18239. /**
  18240. * Still set as invisible in order to skip useless computations (Internal use)
  18241. */
  18242. _stillInvisible: boolean;
  18243. /**
  18244. * Last computed particle rotation matrix
  18245. */
  18246. _rotationMatrix: number[];
  18247. /**
  18248. * Parent particle Id, if any.
  18249. * Default null.
  18250. */
  18251. parentId: Nullable<number>;
  18252. /**
  18253. * Internal global position in the SPS.
  18254. */
  18255. _globalPosition: Vector3;
  18256. /**
  18257. * Creates a Solid Particle object.
  18258. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  18259. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  18260. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  18261. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  18262. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  18263. * @param shapeId (integer) is the model shape identifier in the SPS.
  18264. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  18265. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  18266. */
  18267. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  18268. /**
  18269. * Legacy support, changed scale to scaling
  18270. */
  18271. /**
  18272. * Legacy support, changed scale to scaling
  18273. */
  18274. scale: Vector3;
  18275. /**
  18276. * Legacy support, changed quaternion to rotationQuaternion
  18277. */
  18278. /**
  18279. * Legacy support, changed quaternion to rotationQuaternion
  18280. */
  18281. quaternion: Nullable<Quaternion>;
  18282. /**
  18283. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  18284. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  18285. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  18286. * @returns true if it intersects
  18287. */
  18288. intersectsMesh(target: Mesh | SolidParticle): boolean;
  18289. }
  18290. /**
  18291. * Represents the shape of the model used by one particle of a solid particle system.
  18292. * SPS internal tool, don't use it manually.
  18293. * @see SolidParticleSystem
  18294. */
  18295. class ModelShape {
  18296. /**
  18297. * The shape id.
  18298. */
  18299. shapeID: number;
  18300. /**
  18301. * flat array of model positions (internal use)
  18302. */
  18303. _shape: Vector3[];
  18304. /**
  18305. * flat array of model UVs (internal use)
  18306. */
  18307. _shapeUV: number[];
  18308. /**
  18309. * length of the shape in the model indices array (internal use)
  18310. */
  18311. _indicesLength: number;
  18312. /**
  18313. * Custom position function (internal use)
  18314. */
  18315. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  18316. /**
  18317. * Custom vertex function (internal use)
  18318. */
  18319. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  18320. /**
  18321. * 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.
  18322. * SPS internal tool, don't use it manually.
  18323. * @ignore
  18324. */
  18325. 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>);
  18326. }
  18327. /**
  18328. * Represents a Depth Sorted Particle in the solid particle system.
  18329. * @see SolidParticleSystem
  18330. */
  18331. class DepthSortedParticle {
  18332. /**
  18333. * Index of the particle in the "indices" array
  18334. */
  18335. ind: number;
  18336. /**
  18337. * Length of the particle shape in the "indices" array
  18338. */
  18339. indicesLength: number;
  18340. /**
  18341. * Squared distance from the particle to the camera
  18342. */
  18343. sqDistance: number;
  18344. }
  18345. }
  18346. declare module BABYLON {
  18347. /**
  18348. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  18349. *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.
  18350. * The SPS is also a particle system. It provides some methods to manage the particles.
  18351. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  18352. *
  18353. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  18354. */
  18355. class SolidParticleSystem implements IDisposable {
  18356. /**
  18357. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  18358. * Example : var p = SPS.particles[i];
  18359. */
  18360. particles: SolidParticle[];
  18361. /**
  18362. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  18363. */
  18364. nbParticles: number;
  18365. /**
  18366. * If the particles must ever face the camera (default false). Useful for planar particles.
  18367. */
  18368. billboard: boolean;
  18369. /**
  18370. * Recompute normals when adding a shape
  18371. */
  18372. recomputeNormals: boolean;
  18373. /**
  18374. * This a counter ofr your own usage. It's not set by any SPS functions.
  18375. */
  18376. counter: number;
  18377. /**
  18378. * The SPS name. This name is also given to the underlying mesh.
  18379. */
  18380. name: string;
  18381. /**
  18382. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  18383. */
  18384. mesh: Mesh;
  18385. /**
  18386. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  18387. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  18388. */
  18389. vars: any;
  18390. /**
  18391. * This array is populated when the SPS is set as 'pickable'.
  18392. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  18393. * Each element of this array is an object `{idx: int, faceId: int}`.
  18394. * `idx` is the picked particle index in the `SPS.particles` array
  18395. * `faceId` is the picked face index counted within this particle.
  18396. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  18397. */
  18398. pickedParticles: {
  18399. idx: number;
  18400. faceId: number;
  18401. }[];
  18402. /**
  18403. * This array is populated when `enableDepthSort` is set to true.
  18404. * Each element of this array is an instance of the class DepthSortedParticle.
  18405. */
  18406. depthSortedParticles: DepthSortedParticle[];
  18407. /**
  18408. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  18409. */
  18410. _bSphereOnly: boolean;
  18411. /**
  18412. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  18413. */
  18414. _bSphereRadiusFactor: number;
  18415. private _scene;
  18416. private _positions;
  18417. private _indices;
  18418. private _normals;
  18419. private _colors;
  18420. private _uvs;
  18421. private _indices32;
  18422. private _positions32;
  18423. private _normals32;
  18424. private _fixedNormal32;
  18425. private _colors32;
  18426. private _uvs32;
  18427. private _index;
  18428. private _updatable;
  18429. private _pickable;
  18430. private _isVisibilityBoxLocked;
  18431. private _alwaysVisible;
  18432. private _depthSort;
  18433. private _shapeCounter;
  18434. private _copy;
  18435. private _shape;
  18436. private _shapeUV;
  18437. private _color;
  18438. private _computeParticleColor;
  18439. private _computeParticleTexture;
  18440. private _computeParticleRotation;
  18441. private _computeParticleVertex;
  18442. private _computeBoundingBox;
  18443. private _depthSortParticles;
  18444. private _cam_axisZ;
  18445. private _cam_axisY;
  18446. private _cam_axisX;
  18447. private _axisZ;
  18448. private _camera;
  18449. private _particle;
  18450. private _camDir;
  18451. private _camInvertedPosition;
  18452. private _rotMatrix;
  18453. private _invertMatrix;
  18454. private _rotated;
  18455. private _quaternion;
  18456. private _vertex;
  18457. private _normal;
  18458. private _yaw;
  18459. private _pitch;
  18460. private _roll;
  18461. private _halfroll;
  18462. private _halfpitch;
  18463. private _halfyaw;
  18464. private _sinRoll;
  18465. private _cosRoll;
  18466. private _sinPitch;
  18467. private _cosPitch;
  18468. private _sinYaw;
  18469. private _cosYaw;
  18470. private _mustUnrotateFixedNormals;
  18471. private _minimum;
  18472. private _maximum;
  18473. private _minBbox;
  18474. private _maxBbox;
  18475. private _particlesIntersect;
  18476. private _depthSortFunction;
  18477. private _needs32Bits;
  18478. private _pivotBackTranslation;
  18479. private _scaledPivot;
  18480. private _particleHasParent;
  18481. private _parent;
  18482. /**
  18483. * Creates a SPS (Solid Particle System) object.
  18484. * @param name (String) is the SPS name, this will be the underlying mesh name.
  18485. * @param scene (Scene) is the scene in which the SPS is added.
  18486. * @param updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  18487. * @param isPickable (optional boolean, default false) : if the solid particles must be pickable.
  18488. * @param enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  18489. * @param particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  18490. * @param boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  18491. * @param bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  18492. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  18493. */
  18494. constructor(name: string, scene: Scene, options?: {
  18495. updatable?: boolean;
  18496. isPickable?: boolean;
  18497. enableDepthSort?: boolean;
  18498. particleIntersection?: boolean;
  18499. boundingSphereOnly?: boolean;
  18500. bSphereRadiusFactor?: number;
  18501. });
  18502. /**
  18503. * Builds the SPS underlying mesh. Returns a standard Mesh.
  18504. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  18505. * @returns the created mesh
  18506. */
  18507. buildMesh(): Mesh;
  18508. /**
  18509. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  18510. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  18511. * Thus the particles generated from `digest()` have their property `position` set yet.
  18512. * @param mesh ( Mesh ) is the mesh to be digested
  18513. * @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
  18514. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  18515. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  18516. * @returns the current SPS
  18517. */
  18518. digest(mesh: Mesh, options?: {
  18519. facetNb?: number;
  18520. number?: number;
  18521. delta?: number;
  18522. }): SolidParticleSystem;
  18523. private _unrotateFixedNormals();
  18524. private _resetCopy();
  18525. private _meshBuilder(p, shape, positions, meshInd, indices, meshUV, uvs, meshCol, colors, meshNor, normals, idx, idxInShape, options);
  18526. private _posToShape(positions);
  18527. private _uvsToShapeUV(uvs);
  18528. private _addParticle(idx, idxpos, idxind, model, shapeId, idxInShape, bInfo?);
  18529. /**
  18530. * Adds some particles to the SPS from the model shape. Returns the shape id.
  18531. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  18532. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  18533. * @param nb (positive integer) the number of particles to be created from this model
  18534. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  18535. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  18536. * @returns the number of shapes in the system
  18537. */
  18538. addShape(mesh: Mesh, nb: number, options?: {
  18539. positionFunction?: any;
  18540. vertexFunction?: any;
  18541. }): number;
  18542. private _rebuildParticle(particle);
  18543. /**
  18544. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  18545. * @returns the SPS.
  18546. */
  18547. rebuildMesh(): SolidParticleSystem;
  18548. /**
  18549. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  18550. * This method calls `updateParticle()` for each particle of the SPS.
  18551. * For an animated SPS, it is usually called within the render loop.
  18552. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  18553. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  18554. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  18555. * @returns the SPS.
  18556. */
  18557. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  18558. private _quaternionRotationYPR();
  18559. private _quaternionToRotationMatrix();
  18560. /**
  18561. * Disposes the SPS.
  18562. */
  18563. dispose(): void;
  18564. /**
  18565. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  18566. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  18567. * @returns the SPS.
  18568. */
  18569. refreshVisibleSize(): SolidParticleSystem;
  18570. /**
  18571. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  18572. * @param size the size (float) of the visibility box
  18573. * note : this doesn't lock the SPS mesh bounding box.
  18574. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  18575. */
  18576. setVisibilityBox(size: number): void;
  18577. /**
  18578. * Gets whether the SPS as always visible or not
  18579. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  18580. */
  18581. /**
  18582. * Sets the SPS as always visible or not
  18583. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  18584. */
  18585. isAlwaysVisible: boolean;
  18586. /**
  18587. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  18588. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  18589. */
  18590. /**
  18591. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  18592. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  18593. */
  18594. isVisibilityBoxLocked: boolean;
  18595. /**
  18596. * Gets if `setParticles()` computes the particle rotations or not.
  18597. * Default value : true. The SPS is faster when it's set to false.
  18598. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  18599. */
  18600. /**
  18601. * Tells to `setParticles()` to compute the particle rotations or not.
  18602. * Default value : true. The SPS is faster when it's set to false.
  18603. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  18604. */
  18605. computeParticleRotation: boolean;
  18606. /**
  18607. * Gets if `setParticles()` computes the particle colors or not.
  18608. * Default value : true. The SPS is faster when it's set to false.
  18609. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  18610. */
  18611. /**
  18612. * Tells to `setParticles()` to compute the particle colors or not.
  18613. * Default value : true. The SPS is faster when it's set to false.
  18614. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  18615. */
  18616. computeParticleColor: boolean;
  18617. /**
  18618. * Gets if `setParticles()` computes the particle textures or not.
  18619. * Default value : true. The SPS is faster when it's set to false.
  18620. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  18621. */
  18622. computeParticleTexture: boolean;
  18623. /**
  18624. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  18625. * Default value : false. The SPS is faster when it's set to false.
  18626. * Note : the particle custom vertex positions aren't stored values.
  18627. */
  18628. /**
  18629. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  18630. * Default value : false. The SPS is faster when it's set to false.
  18631. * Note : the particle custom vertex positions aren't stored values.
  18632. */
  18633. computeParticleVertex: boolean;
  18634. /**
  18635. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  18636. */
  18637. /**
  18638. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  18639. */
  18640. computeBoundingBox: boolean;
  18641. /**
  18642. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  18643. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  18644. * Default : `true`
  18645. */
  18646. /**
  18647. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  18648. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  18649. * Default : `true`
  18650. */
  18651. depthSortParticles: boolean;
  18652. /**
  18653. * This function does nothing. It may be overwritten to set all the particle first values.
  18654. * The SPS doesn't call this function, you may have to call it by your own.
  18655. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  18656. */
  18657. initParticles(): void;
  18658. /**
  18659. * This function does nothing. It may be overwritten to recycle a particle.
  18660. * The SPS doesn't call this function, you may have to call it by your own.
  18661. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  18662. * @param particle The particle to recycle
  18663. * @returns the recycled particle
  18664. */
  18665. recycleParticle(particle: SolidParticle): SolidParticle;
  18666. /**
  18667. * Updates a particle : this function should be overwritten by the user.
  18668. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  18669. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  18670. * @example : just set a particle position or velocity and recycle conditions
  18671. * @param particle The particle to update
  18672. * @returns the updated particle
  18673. */
  18674. updateParticle(particle: SolidParticle): SolidParticle;
  18675. /**
  18676. * Updates a vertex of a particle : it can be overwritten by the user.
  18677. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  18678. * @param particle the current particle
  18679. * @param vertex the current index of the current particle
  18680. * @param pt the index of the current vertex in the particle shape
  18681. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  18682. * @example : just set a vertex particle position
  18683. * @returns the updated vertex
  18684. */
  18685. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  18686. /**
  18687. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  18688. * This does nothing and may be overwritten by the user.
  18689. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  18690. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  18691. * @param update the boolean update value actually passed to setParticles()
  18692. */
  18693. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  18694. /**
  18695. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  18696. * This will be passed three parameters.
  18697. * This does nothing and may be overwritten by the user.
  18698. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  18699. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  18700. * @param update the boolean update value actually passed to setParticles()
  18701. */
  18702. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  18703. }
  18704. }
  18705. declare module BABYLON {
  18706. interface PhysicsImpostorJoint {
  18707. mainImpostor: PhysicsImpostor;
  18708. connectedImpostor: PhysicsImpostor;
  18709. joint: PhysicsJoint;
  18710. }
  18711. class PhysicsEngine {
  18712. private _physicsPlugin;
  18713. gravity: Vector3;
  18714. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  18715. setGravity(gravity: Vector3): void;
  18716. /**
  18717. * Set the time step of the physics engine.
  18718. * default is 1/60.
  18719. * To slow it down, enter 1/600 for example.
  18720. * To speed it up, 1/30
  18721. * @param {number} newTimeStep the new timestep to apply to this world.
  18722. */
  18723. setTimeStep(newTimeStep?: number): void;
  18724. /**
  18725. * Get the time step of the physics engine.
  18726. */
  18727. getTimeStep(): number;
  18728. dispose(): void;
  18729. getPhysicsPluginName(): string;
  18730. static Epsilon: number;
  18731. private _impostors;
  18732. private _joints;
  18733. /**
  18734. * Adding a new impostor for the impostor tracking.
  18735. * This will be done by the impostor itself.
  18736. * @param {PhysicsImpostor} impostor the impostor to add
  18737. */
  18738. addImpostor(impostor: PhysicsImpostor): void;
  18739. /**
  18740. * Remove an impostor from the engine.
  18741. * This impostor and its mesh will not longer be updated by the physics engine.
  18742. * @param {PhysicsImpostor} impostor the impostor to remove
  18743. */
  18744. removeImpostor(impostor: PhysicsImpostor): void;
  18745. /**
  18746. * Add a joint to the physics engine
  18747. * @param {PhysicsImpostor} mainImpostor the main impostor to which the joint is added.
  18748. * @param {PhysicsImpostor} connectedImpostor the impostor that is connected to the main impostor using this joint
  18749. * @param {PhysicsJoint} the joint that will connect both impostors.
  18750. */
  18751. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  18752. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  18753. /**
  18754. * Called by the scene. no need to call it.
  18755. */
  18756. _step(delta: number): void;
  18757. getPhysicsPlugin(): IPhysicsEnginePlugin;
  18758. getImpostors(): Array<PhysicsImpostor>;
  18759. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  18760. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  18761. }
  18762. interface IPhysicsEnginePlugin {
  18763. world: any;
  18764. name: string;
  18765. setGravity(gravity: Vector3): void;
  18766. setTimeStep(timeStep: number): void;
  18767. getTimeStep(): number;
  18768. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  18769. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  18770. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  18771. generatePhysicsBody(impostor: PhysicsImpostor): void;
  18772. removePhysicsBody(impostor: PhysicsImpostor): void;
  18773. generateJoint(joint: PhysicsImpostorJoint): void;
  18774. removeJoint(joint: PhysicsImpostorJoint): void;
  18775. isSupported(): boolean;
  18776. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  18777. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  18778. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  18779. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  18780. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  18781. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  18782. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  18783. getBodyMass(impostor: PhysicsImpostor): number;
  18784. getBodyFriction(impostor: PhysicsImpostor): number;
  18785. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  18786. getBodyRestitution(impostor: PhysicsImpostor): number;
  18787. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  18788. sleepBody(impostor: PhysicsImpostor): void;
  18789. wakeUpBody(impostor: PhysicsImpostor): void;
  18790. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  18791. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  18792. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  18793. getRadius(impostor: PhysicsImpostor): number;
  18794. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  18795. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  18796. dispose(): void;
  18797. }
  18798. }
  18799. declare module BABYLON {
  18800. class PhysicsHelper {
  18801. private _scene;
  18802. private _physicsEngine;
  18803. constructor(scene: Scene);
  18804. /**
  18805. * @param {Vector3} origin the origin of the explosion
  18806. * @param {number} radius the explosion radius
  18807. * @param {number} strength the explosion strength
  18808. * @param {PhysicsRadialImpulseFalloff} falloff possible options: Constant & Linear. Defaults to Constant
  18809. */
  18810. applyRadialExplosionImpulse(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  18811. /**
  18812. * @param {Vector3} origin the origin of the explosion
  18813. * @param {number} radius the explosion radius
  18814. * @param {number} strength the explosion strength
  18815. * @param {PhysicsRadialImpulseFalloff} falloff possible options: Constant & Linear. Defaults to Constant
  18816. */
  18817. applyRadialExplosionForce(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  18818. /**
  18819. * @param {Vector3} origin the origin of the explosion
  18820. * @param {number} radius the explosion radius
  18821. * @param {number} strength the explosion strength
  18822. * @param {PhysicsRadialImpulseFalloff} falloff possible options: Constant & Linear. Defaults to Constant
  18823. */
  18824. gravitationalField(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  18825. /**
  18826. * @param {Vector3} origin the origin of the updraft
  18827. * @param {number} radius the radius of the updraft
  18828. * @param {number} strength the strength of the updraft
  18829. * @param {number} height the height of the updraft
  18830. * @param {PhysicsUpdraftMode} updraftMode possible options: Center & Perpendicular. Defaults to Center
  18831. */
  18832. updraft(origin: Vector3, radius: number, strength: number, height: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  18833. /**
  18834. * @param {Vector3} origin the of the vortex
  18835. * @param {number} radius the radius of the vortex
  18836. * @param {number} strength the strength of the vortex
  18837. * @param {number} height the height of the vortex
  18838. */
  18839. vortex(origin: Vector3, radius: number, strength: number, height: number): Nullable<PhysicsVortexEvent>;
  18840. }
  18841. /***** Radial explosion *****/
  18842. class PhysicsRadialExplosionEvent {
  18843. private _scene;
  18844. private _sphere;
  18845. private _sphereOptions;
  18846. private _rays;
  18847. private _dataFetched;
  18848. constructor(scene: Scene);
  18849. /**
  18850. * Returns the data related to the radial explosion event (sphere & rays).
  18851. * @returns {PhysicsRadialExplosionEventData}
  18852. */
  18853. getData(): PhysicsRadialExplosionEventData;
  18854. /**
  18855. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  18856. * @param impostor
  18857. * @param {Vector3} origin the origin of the explosion
  18858. * @param {number} radius the explosion radius
  18859. * @param {number} strength the explosion strength
  18860. * @param {PhysicsRadialImpulseFalloff} falloff possible options: Constant & Linear
  18861. * @returns {Nullable<PhysicsForceAndContactPoint>}
  18862. */
  18863. getImpostorForceAndContactPoint(impostor: PhysicsImpostor, origin: Vector3, radius: number, strength: number, falloff: PhysicsRadialImpulseFalloff): Nullable<PhysicsForceAndContactPoint>;
  18864. /**
  18865. * Disposes the sphere.
  18866. * @param {bolean} force
  18867. */
  18868. dispose(force?: boolean): void;
  18869. /*** Helpers ***/
  18870. private _prepareSphere();
  18871. private _intersectsWithSphere(impostor, origin, radius);
  18872. }
  18873. /***** Gravitational Field *****/
  18874. class PhysicsGravitationalFieldEvent {
  18875. private _physicsHelper;
  18876. private _scene;
  18877. private _origin;
  18878. private _radius;
  18879. private _strength;
  18880. private _falloff;
  18881. private _tickCallback;
  18882. private _sphere;
  18883. private _dataFetched;
  18884. constructor(physicsHelper: PhysicsHelper, scene: Scene, origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff);
  18885. /**
  18886. * Returns the data related to the gravitational field event (sphere).
  18887. * @returns {PhysicsGravitationalFieldEventData}
  18888. */
  18889. getData(): PhysicsGravitationalFieldEventData;
  18890. /**
  18891. * Enables the gravitational field.
  18892. */
  18893. enable(): void;
  18894. /**
  18895. * Disables the gravitational field.
  18896. */
  18897. disable(): void;
  18898. /**
  18899. * Disposes the sphere.
  18900. * @param {bolean} force
  18901. */
  18902. dispose(force?: boolean): void;
  18903. private _tick();
  18904. }
  18905. /***** Updraft *****/
  18906. class PhysicsUpdraftEvent {
  18907. private _scene;
  18908. private _origin;
  18909. private _radius;
  18910. private _strength;
  18911. private _height;
  18912. private _updraftMode;
  18913. private _physicsEngine;
  18914. private _originTop;
  18915. private _originDirection;
  18916. private _tickCallback;
  18917. private _cylinder;
  18918. private _cylinderPosition;
  18919. private _dataFetched;
  18920. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number, _updraftMode: PhysicsUpdraftMode);
  18921. /**
  18922. * Returns the data related to the updraft event (cylinder).
  18923. * @returns {PhysicsUpdraftEventData}
  18924. */
  18925. getData(): PhysicsUpdraftEventData;
  18926. /**
  18927. * Enables the updraft.
  18928. */
  18929. enable(): void;
  18930. /**
  18931. * Disables the cortex.
  18932. */
  18933. disable(): void;
  18934. /**
  18935. * Disposes the sphere.
  18936. * @param {bolean} force
  18937. */
  18938. dispose(force?: boolean): void;
  18939. private getImpostorForceAndContactPoint(impostor);
  18940. private _tick();
  18941. /*** Helpers ***/
  18942. private _prepareCylinder();
  18943. private _intersectsWithCylinder(impostor);
  18944. }
  18945. /***** Vortex *****/
  18946. class PhysicsVortexEvent {
  18947. private _scene;
  18948. private _origin;
  18949. private _radius;
  18950. private _strength;
  18951. private _height;
  18952. private _physicsEngine;
  18953. private _originTop;
  18954. private _centripetalForceThreshold;
  18955. private _updraftMultiplier;
  18956. private _tickCallback;
  18957. private _cylinder;
  18958. private _cylinderPosition;
  18959. private _dataFetched;
  18960. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number);
  18961. /**
  18962. * Returns the data related to the vortex event (cylinder).
  18963. * @returns {PhysicsVortexEventData}
  18964. */
  18965. getData(): PhysicsVortexEventData;
  18966. /**
  18967. * Enables the vortex.
  18968. */
  18969. enable(): void;
  18970. /**
  18971. * Disables the cortex.
  18972. */
  18973. disable(): void;
  18974. /**
  18975. * Disposes the sphere.
  18976. * @param {bolean} force
  18977. */
  18978. dispose(force?: boolean): void;
  18979. private getImpostorForceAndContactPoint(impostor);
  18980. private _tick();
  18981. /*** Helpers ***/
  18982. private _prepareCylinder();
  18983. private _intersectsWithCylinder(impostor);
  18984. }
  18985. /***** Enums *****/
  18986. /**
  18987. * The strenght of the force in correspondence to the distance of the affected object
  18988. */
  18989. enum PhysicsRadialImpulseFalloff {
  18990. Constant = 0,
  18991. Linear = 1,
  18992. }
  18993. /**
  18994. * The strenght of the force in correspondence to the distance of the affected object
  18995. */
  18996. enum PhysicsUpdraftMode {
  18997. Center = 0,
  18998. Perpendicular = 1,
  18999. }
  19000. /***** Data interfaces *****/
  19001. interface PhysicsForceAndContactPoint {
  19002. force: Vector3;
  19003. contactPoint: Vector3;
  19004. }
  19005. interface PhysicsRadialExplosionEventData {
  19006. sphere: Mesh;
  19007. rays: Array<Ray>;
  19008. }
  19009. interface PhysicsGravitationalFieldEventData {
  19010. sphere: Mesh;
  19011. }
  19012. interface PhysicsUpdraftEventData {
  19013. cylinder: Mesh;
  19014. }
  19015. interface PhysicsVortexEventData {
  19016. cylinder: Mesh;
  19017. }
  19018. }
  19019. declare module BABYLON {
  19020. interface PhysicsImpostorParameters {
  19021. mass: number;
  19022. friction?: number;
  19023. restitution?: number;
  19024. nativeOptions?: any;
  19025. ignoreParent?: boolean;
  19026. disableBidirectionalTransformation?: boolean;
  19027. }
  19028. interface IPhysicsEnabledObject {
  19029. position: Vector3;
  19030. rotationQuaternion: Nullable<Quaternion>;
  19031. scaling: Vector3;
  19032. rotation?: Vector3;
  19033. parent?: any;
  19034. getBoundingInfo(): BoundingInfo;
  19035. computeWorldMatrix(force: boolean): Matrix;
  19036. getWorldMatrix?(): Matrix;
  19037. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  19038. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  19039. getIndices?(): Nullable<IndicesArray>;
  19040. getScene?(): Scene;
  19041. getAbsolutePosition(): Vector3;
  19042. getAbsolutePivotPoint(): Vector3;
  19043. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  19044. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  19045. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  19046. getClassName(): string;
  19047. }
  19048. class PhysicsImpostor {
  19049. object: IPhysicsEnabledObject;
  19050. type: number;
  19051. private _options;
  19052. private _scene;
  19053. static DEFAULT_OBJECT_SIZE: Vector3;
  19054. static IDENTITY_QUATERNION: Quaternion;
  19055. private _physicsEngine;
  19056. private _physicsBody;
  19057. private _bodyUpdateRequired;
  19058. private _onBeforePhysicsStepCallbacks;
  19059. private _onAfterPhysicsStepCallbacks;
  19060. private _onPhysicsCollideCallbacks;
  19061. private _deltaPosition;
  19062. private _deltaRotation;
  19063. private _deltaRotationConjugated;
  19064. private _parent;
  19065. private _isDisposed;
  19066. private static _tmpVecs;
  19067. private static _tmpQuat;
  19068. readonly isDisposed: boolean;
  19069. mass: number;
  19070. friction: number;
  19071. restitution: number;
  19072. uniqueId: number;
  19073. private _joints;
  19074. constructor(object: IPhysicsEnabledObject, type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  19075. /**
  19076. * This function will completly initialize this impostor.
  19077. * It will create a new body - but only if this mesh has no parent.
  19078. * If it has, this impostor will not be used other than to define the impostor
  19079. * of the child mesh.
  19080. */
  19081. _init(): void;
  19082. private _getPhysicsParent();
  19083. /**
  19084. * Should a new body be generated.
  19085. */
  19086. isBodyInitRequired(): boolean;
  19087. setScalingUpdated(updated: boolean): void;
  19088. /**
  19089. * Force a regeneration of this or the parent's impostor's body.
  19090. * Use under cautious - This will remove all joints already implemented.
  19091. */
  19092. forceUpdate(): void;
  19093. /**
  19094. * Gets the body that holds this impostor. Either its own, or its parent.
  19095. */
  19096. /**
  19097. * Set the physics body. Used mainly by the physics engine/plugin
  19098. */
  19099. physicsBody: any;
  19100. parent: Nullable<PhysicsImpostor>;
  19101. resetUpdateFlags(): void;
  19102. getObjectExtendSize(): Vector3;
  19103. getObjectCenter(): Vector3;
  19104. /**
  19105. * Get a specific parametes from the options parameter.
  19106. */
  19107. getParam(paramName: string): any;
  19108. /**
  19109. * Sets a specific parameter in the options given to the physics plugin
  19110. */
  19111. setParam(paramName: string, value: number): void;
  19112. /**
  19113. * Specifically change the body's mass option. Won't recreate the physics body object
  19114. */
  19115. setMass(mass: number): void;
  19116. getLinearVelocity(): Nullable<Vector3>;
  19117. setLinearVelocity(velocity: Nullable<Vector3>): void;
  19118. getAngularVelocity(): Nullable<Vector3>;
  19119. setAngularVelocity(velocity: Nullable<Vector3>): void;
  19120. /**
  19121. * Execute a function with the physics plugin native code.
  19122. * Provide a function the will have two variables - the world object and the physics body object.
  19123. */
  19124. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  19125. /**
  19126. * Register a function that will be executed before the physics world is stepping forward.
  19127. */
  19128. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  19129. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  19130. /**
  19131. * Register a function that will be executed after the physics step
  19132. */
  19133. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  19134. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  19135. /**
  19136. * register a function that will be executed when this impostor collides against a different body.
  19137. */
  19138. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  19139. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  19140. private _tmpQuat;
  19141. private _tmpQuat2;
  19142. getParentsRotation(): Quaternion;
  19143. /**
  19144. * this function is executed by the physics engine.
  19145. */
  19146. beforeStep: () => void;
  19147. /**
  19148. * this function is executed by the physics engine.
  19149. */
  19150. afterStep: () => void;
  19151. /**
  19152. * Legacy collision detection event support
  19153. */
  19154. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  19155. onCollide: (e: {
  19156. body: any;
  19157. }) => void;
  19158. /**
  19159. * Apply a force
  19160. */
  19161. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  19162. /**
  19163. * Apply an impulse
  19164. */
  19165. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  19166. /**
  19167. * A help function to create a joint.
  19168. */
  19169. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  19170. /**
  19171. * Add a joint to this impostor with a different impostor.
  19172. */
  19173. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  19174. /**
  19175. * Will keep this body still, in a sleep mode.
  19176. */
  19177. sleep(): PhysicsImpostor;
  19178. /**
  19179. * Wake the body up.
  19180. */
  19181. wakeUp(): PhysicsImpostor;
  19182. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  19183. dispose(): void;
  19184. setDeltaPosition(position: Vector3): void;
  19185. setDeltaRotation(rotation: Quaternion): void;
  19186. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  19187. getRadius(): number;
  19188. /**
  19189. * Sync a bone with this impostor
  19190. * @param bone The bone to sync to the impostor.
  19191. * @param boneMesh The mesh that the bone is influencing.
  19192. * @param jointPivot The pivot of the joint / bone in local space.
  19193. * @param distToJoint Optional distance from the impostor to the joint.
  19194. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  19195. */
  19196. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  19197. /**
  19198. * Sync impostor to a bone
  19199. * @param bone The bone that the impostor will be synced to.
  19200. * @param boneMesh The mesh that the bone is influencing.
  19201. * @param jointPivot The pivot of the joint / bone in local space.
  19202. * @param distToJoint Optional distance from the impostor to the joint.
  19203. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  19204. * @param boneAxis Optional vector3 axis the bone is aligned with
  19205. */
  19206. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  19207. static NoImpostor: number;
  19208. static SphereImpostor: number;
  19209. static BoxImpostor: number;
  19210. static PlaneImpostor: number;
  19211. static MeshImpostor: number;
  19212. static CylinderImpostor: number;
  19213. static ParticleImpostor: number;
  19214. static HeightmapImpostor: number;
  19215. }
  19216. }
  19217. declare module BABYLON {
  19218. interface PhysicsJointData {
  19219. mainPivot?: Vector3;
  19220. connectedPivot?: Vector3;
  19221. mainAxis?: Vector3;
  19222. connectedAxis?: Vector3;
  19223. collision?: boolean;
  19224. nativeParams?: any;
  19225. }
  19226. /**
  19227. * This is a holder class for the physics joint created by the physics plugin.
  19228. * It holds a set of functions to control the underlying joint.
  19229. */
  19230. class PhysicsJoint {
  19231. type: number;
  19232. jointData: PhysicsJointData;
  19233. private _physicsJoint;
  19234. protected _physicsPlugin: IPhysicsEnginePlugin;
  19235. constructor(type: number, jointData: PhysicsJointData);
  19236. physicsJoint: any;
  19237. physicsPlugin: IPhysicsEnginePlugin;
  19238. /**
  19239. * Execute a function that is physics-plugin specific.
  19240. * @param {Function} func the function that will be executed.
  19241. * It accepts two parameters: the physics world and the physics joint.
  19242. */
  19243. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  19244. static DistanceJoint: number;
  19245. static HingeJoint: number;
  19246. static BallAndSocketJoint: number;
  19247. static WheelJoint: number;
  19248. static SliderJoint: number;
  19249. static PrismaticJoint: number;
  19250. static UniversalJoint: number;
  19251. static Hinge2Joint: number;
  19252. static PointToPointJoint: number;
  19253. static SpringJoint: number;
  19254. static LockJoint: number;
  19255. }
  19256. /**
  19257. * A class representing a physics distance joint.
  19258. */
  19259. class DistanceJoint extends PhysicsJoint {
  19260. constructor(jointData: DistanceJointData);
  19261. /**
  19262. * Update the predefined distance.
  19263. */
  19264. updateDistance(maxDistance: number, minDistance?: number): void;
  19265. }
  19266. class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  19267. constructor(type: number, jointData: PhysicsJointData);
  19268. /**
  19269. * Set the motor values.
  19270. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19271. * @param {number} force the force to apply
  19272. * @param {number} maxForce max force for this motor.
  19273. */
  19274. setMotor(force?: number, maxForce?: number): void;
  19275. /**
  19276. * Set the motor's limits.
  19277. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19278. */
  19279. setLimit(upperLimit: number, lowerLimit?: number): void;
  19280. }
  19281. /**
  19282. * This class represents a single hinge physics joint
  19283. */
  19284. class HingeJoint extends MotorEnabledJoint {
  19285. constructor(jointData: PhysicsJointData);
  19286. /**
  19287. * Set the motor values.
  19288. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19289. * @param {number} force the force to apply
  19290. * @param {number} maxForce max force for this motor.
  19291. */
  19292. setMotor(force?: number, maxForce?: number): void;
  19293. /**
  19294. * Set the motor's limits.
  19295. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19296. */
  19297. setLimit(upperLimit: number, lowerLimit?: number): void;
  19298. }
  19299. /**
  19300. * This class represents a dual hinge physics joint (same as wheel joint)
  19301. */
  19302. class Hinge2Joint extends MotorEnabledJoint {
  19303. constructor(jointData: PhysicsJointData);
  19304. /**
  19305. * Set the motor values.
  19306. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19307. * @param {number} force the force to apply
  19308. * @param {number} maxForce max force for this motor.
  19309. * @param {motorIndex} the motor's index, 0 or 1.
  19310. */
  19311. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  19312. /**
  19313. * Set the motor limits.
  19314. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19315. * @param {number} upperLimit the upper limit
  19316. * @param {number} lowerLimit lower limit
  19317. * @param {motorIndex} the motor's index, 0 or 1.
  19318. */
  19319. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  19320. }
  19321. interface IMotorEnabledJoint {
  19322. physicsJoint: any;
  19323. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  19324. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  19325. }
  19326. interface DistanceJointData extends PhysicsJointData {
  19327. maxDistance: number;
  19328. }
  19329. interface SpringJointData extends PhysicsJointData {
  19330. length: number;
  19331. stiffness: number;
  19332. damping: number;
  19333. }
  19334. }
  19335. declare module BABYLON {
  19336. class ReflectionProbe {
  19337. name: string;
  19338. private _scene;
  19339. private _renderTargetTexture;
  19340. private _projectionMatrix;
  19341. private _viewMatrix;
  19342. private _target;
  19343. private _add;
  19344. private _attachedMesh;
  19345. private _invertYAxis;
  19346. position: Vector3;
  19347. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  19348. samples: number;
  19349. refreshRate: number;
  19350. getScene(): Scene;
  19351. readonly cubeTexture: RenderTargetTexture;
  19352. readonly renderList: Nullable<AbstractMesh[]>;
  19353. attachToMesh(mesh: AbstractMesh): void;
  19354. /**
  19355. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  19356. *
  19357. * @param renderingGroupId The rendering group id corresponding to its index
  19358. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  19359. */
  19360. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  19361. dispose(): void;
  19362. }
  19363. }
  19364. declare module BABYLON {
  19365. class BoundingBoxRenderer {
  19366. frontColor: Color3;
  19367. backColor: Color3;
  19368. showBackLines: boolean;
  19369. renderList: SmartArray<BoundingBox>;
  19370. private _scene;
  19371. private _colorShader;
  19372. private _vertexBuffers;
  19373. private _indexBuffer;
  19374. constructor(scene: Scene);
  19375. private _prepareRessources();
  19376. private _createIndexBuffer();
  19377. _rebuild(): void;
  19378. reset(): void;
  19379. render(): void;
  19380. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  19381. dispose(): void;
  19382. }
  19383. }
  19384. declare module BABYLON {
  19385. /**
  19386. * This represents a depth renderer in Babylon.
  19387. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  19388. */
  19389. class DepthRenderer {
  19390. private _scene;
  19391. private _depthMap;
  19392. private _effect;
  19393. private _cachedDefines;
  19394. private _camera;
  19395. /**
  19396. * Instantiates a depth renderer
  19397. * @param scene The scene the renderer belongs to
  19398. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  19399. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  19400. */
  19401. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  19402. /**
  19403. * Creates the depth rendering effect and checks if the effect is ready.
  19404. * @param subMesh The submesh to be used to render the depth map of
  19405. * @param useInstances If multiple world instances should be used
  19406. * @returns if the depth renderer is ready to render the depth map
  19407. */
  19408. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  19409. /**
  19410. * Gets the texture which the depth map will be written to.
  19411. * @returns The depth map texture
  19412. */
  19413. getDepthMap(): RenderTargetTexture;
  19414. /**
  19415. * Disposes of the depth renderer.
  19416. */
  19417. dispose(): void;
  19418. }
  19419. }
  19420. declare module BABYLON {
  19421. class EdgesRenderer {
  19422. edgesWidthScalerForOrthographic: number;
  19423. edgesWidthScalerForPerspective: number;
  19424. private _source;
  19425. private _linesPositions;
  19426. private _linesNormals;
  19427. private _linesIndices;
  19428. private _epsilon;
  19429. private _indicesCount;
  19430. private _lineShader;
  19431. private _ib;
  19432. private _buffers;
  19433. private _checkVerticesInsteadOfIndices;
  19434. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  19435. private _prepareRessources();
  19436. _rebuild(): void;
  19437. dispose(): void;
  19438. private _processEdgeForAdjacencies(pa, pb, p0, p1, p2);
  19439. private _processEdgeForAdjacenciesWithVertices(pa, pb, p0, p1, p2);
  19440. private _checkEdge(faceIndex, edge, faceNormals, p0, p1);
  19441. _generateEdgesLines(): void;
  19442. render(): void;
  19443. }
  19444. }
  19445. declare module BABYLON {
  19446. /**
  19447. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  19448. */
  19449. class GeometryBufferRenderer {
  19450. private _scene;
  19451. private _multiRenderTarget;
  19452. private _ratio;
  19453. private _enablePosition;
  19454. protected _effect: Effect;
  19455. protected _cachedDefines: string;
  19456. /**
  19457. * Set the render list (meshes to be rendered) used in the G buffer.
  19458. */
  19459. renderList: Mesh[];
  19460. /**
  19461. * Gets wether or not G buffer are supported by the running hardware.
  19462. * This requires draw buffer supports
  19463. */
  19464. readonly isSupported: boolean;
  19465. /**
  19466. * Gets wether or not position are enabled for the G buffer.
  19467. */
  19468. /**
  19469. * Sets wether or not position are enabled for the G buffer.
  19470. */
  19471. enablePosition: boolean;
  19472. /**
  19473. * Gets the scene associated with the buffer.
  19474. */
  19475. readonly scene: Scene;
  19476. /**
  19477. * Gets the ratio used by the buffer during its creation.
  19478. * How big is the buffer related to the main canvas.
  19479. */
  19480. readonly ratio: number;
  19481. /**
  19482. * Creates a new G Buffer for the scene. @see GeometryBufferRenderer
  19483. * @param scene The scene the buffer belongs to
  19484. * @param ratio How big is the buffer related to the main canvas.
  19485. */
  19486. constructor(scene: Scene, ratio?: number);
  19487. /**
  19488. * Checks wether everything is ready to render a submesh to the G buffer.
  19489. * @param subMesh the submesh to check readiness for
  19490. * @param useInstances is the mesh drawn using instance or not
  19491. * @returns true if ready otherwise false
  19492. */
  19493. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  19494. /**
  19495. * Gets the current underlying G Buffer.
  19496. * @returns the buffer
  19497. */
  19498. getGBuffer(): MultiRenderTarget;
  19499. /**
  19500. * Gets the number of samples used to render the buffer (anti aliasing).
  19501. */
  19502. /**
  19503. * Sets the number of samples used to render the buffer (anti aliasing).
  19504. */
  19505. samples: number;
  19506. /**
  19507. * Disposes the renderer and frees up associated resources.
  19508. */
  19509. dispose(): void;
  19510. protected _createRenderTargets(): void;
  19511. }
  19512. }
  19513. declare module BABYLON {
  19514. class OutlineRenderer {
  19515. private _scene;
  19516. private _effect;
  19517. private _cachedDefines;
  19518. zOffset: number;
  19519. constructor(scene: Scene);
  19520. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  19521. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  19522. }
  19523. }
  19524. declare module BABYLON {
  19525. class RenderingGroup {
  19526. index: number;
  19527. private _scene;
  19528. private _opaqueSubMeshes;
  19529. private _transparentSubMeshes;
  19530. private _alphaTestSubMeshes;
  19531. private _depthOnlySubMeshes;
  19532. private _particleSystems;
  19533. private _spriteManagers;
  19534. private _opaqueSortCompareFn;
  19535. private _alphaTestSortCompareFn;
  19536. private _transparentSortCompareFn;
  19537. private _renderOpaque;
  19538. private _renderAlphaTest;
  19539. private _renderTransparent;
  19540. private _edgesRenderers;
  19541. onBeforeTransparentRendering: () => void;
  19542. /**
  19543. * Set the opaque sort comparison function.
  19544. * If null the sub meshes will be render in the order they were created
  19545. */
  19546. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  19547. /**
  19548. * Set the alpha test sort comparison function.
  19549. * If null the sub meshes will be render in the order they were created
  19550. */
  19551. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  19552. /**
  19553. * Set the transparent sort comparison function.
  19554. * If null the sub meshes will be render in the order they were created
  19555. */
  19556. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  19557. /**
  19558. * Creates a new rendering group.
  19559. * @param index The rendering group index
  19560. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  19561. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  19562. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  19563. */
  19564. 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>);
  19565. /**
  19566. * Render all the sub meshes contained in the group.
  19567. * @param customRenderFunction Used to override the default render behaviour of the group.
  19568. * @returns true if rendered some submeshes.
  19569. */
  19570. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  19571. /**
  19572. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  19573. * @param subMeshes The submeshes to render
  19574. */
  19575. private renderOpaqueSorted(subMeshes);
  19576. /**
  19577. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  19578. * @param subMeshes The submeshes to render
  19579. */
  19580. private renderAlphaTestSorted(subMeshes);
  19581. /**
  19582. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  19583. * @param subMeshes The submeshes to render
  19584. */
  19585. private renderTransparentSorted(subMeshes);
  19586. /**
  19587. * Renders the submeshes in a specified order.
  19588. * @param subMeshes The submeshes to sort before render
  19589. * @param sortCompareFn The comparison function use to sort
  19590. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  19591. * @param transparent Specifies to activate blending if true
  19592. */
  19593. private static renderSorted(subMeshes, sortCompareFn, camera, transparent);
  19594. /**
  19595. * Renders the submeshes in the order they were dispatched (no sort applied).
  19596. * @param subMeshes The submeshes to render
  19597. */
  19598. private static renderUnsorted(subMeshes);
  19599. /**
  19600. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  19601. * are rendered back to front if in the same alpha index.
  19602. *
  19603. * @param a The first submesh
  19604. * @param b The second submesh
  19605. * @returns The result of the comparison
  19606. */
  19607. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  19608. /**
  19609. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  19610. * are rendered back to front.
  19611. *
  19612. * @param a The first submesh
  19613. * @param b The second submesh
  19614. * @returns The result of the comparison
  19615. */
  19616. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  19617. /**
  19618. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  19619. * are rendered front to back (prevent overdraw).
  19620. *
  19621. * @param a The first submesh
  19622. * @param b The second submesh
  19623. * @returns The result of the comparison
  19624. */
  19625. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  19626. /**
  19627. * Resets the different lists of submeshes to prepare a new frame.
  19628. */
  19629. prepare(): void;
  19630. dispose(): void;
  19631. /**
  19632. * Inserts the submesh in its correct queue depending on its material.
  19633. * @param subMesh The submesh to dispatch
  19634. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  19635. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  19636. */
  19637. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  19638. dispatchSprites(spriteManager: SpriteManager): void;
  19639. dispatchParticles(particleSystem: IParticleSystem): void;
  19640. private _renderParticles(activeMeshes);
  19641. private _renderSprites();
  19642. }
  19643. }
  19644. declare module BABYLON {
  19645. class RenderingManager {
  19646. /**
  19647. * The max id used for rendering groups (not included)
  19648. */
  19649. static MAX_RENDERINGGROUPS: number;
  19650. /**
  19651. * The min id used for rendering groups (included)
  19652. */
  19653. static MIN_RENDERINGGROUPS: number;
  19654. /**
  19655. * Used to globally prevent autoclearing scenes.
  19656. */
  19657. static AUTOCLEAR: boolean;
  19658. private _scene;
  19659. private _renderingGroups;
  19660. private _depthStencilBufferAlreadyCleaned;
  19661. private _autoClearDepthStencil;
  19662. private _customOpaqueSortCompareFn;
  19663. private _customAlphaTestSortCompareFn;
  19664. private _customTransparentSortCompareFn;
  19665. private _renderinGroupInfo;
  19666. constructor(scene: Scene);
  19667. private _clearDepthStencilBuffer(depth?, stencil?);
  19668. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  19669. reset(): void;
  19670. dispose(): void;
  19671. private _prepareRenderingGroup(renderingGroupId);
  19672. dispatchSprites(spriteManager: SpriteManager): void;
  19673. dispatchParticles(particleSystem: IParticleSystem): void;
  19674. /**
  19675. * @param subMesh The submesh to dispatch
  19676. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  19677. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  19678. */
  19679. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  19680. /**
  19681. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  19682. * This allowed control for front to back rendering or reversly depending of the special needs.
  19683. *
  19684. * @param renderingGroupId The rendering group id corresponding to its index
  19685. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  19686. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  19687. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  19688. */
  19689. 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;
  19690. /**
  19691. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  19692. *
  19693. * @param renderingGroupId The rendering group id corresponding to its index
  19694. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  19695. * @param depth Automatically clears depth between groups if true and autoClear is true.
  19696. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  19697. */
  19698. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  19699. }
  19700. }
  19701. declare module BABYLON {
  19702. class AnaglyphPostProcess extends PostProcess {
  19703. private _passedProcess;
  19704. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  19705. }
  19706. }
  19707. declare module BABYLON {
  19708. class BlackAndWhitePostProcess extends PostProcess {
  19709. degree: number;
  19710. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  19711. }
  19712. }
  19713. declare module BABYLON {
  19714. /**
  19715. * The Blur Post Process which blurs an image based on a kernel and direction.
  19716. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  19717. */
  19718. class BlurPostProcess extends PostProcess {
  19719. /** The direction in which to blur the image. */ direction: Vector2;
  19720. protected _kernel: number;
  19721. protected _idealKernel: number;
  19722. protected _packedFloat: boolean;
  19723. private _staticDefines;
  19724. /**
  19725. * Gets the length in pixels of the blur sample region
  19726. */
  19727. /**
  19728. * Sets the length in pixels of the blur sample region
  19729. */
  19730. kernel: number;
  19731. /**
  19732. * Gets wether or not the blur is unpacking/repacking floats
  19733. */
  19734. /**
  19735. * Sets wether or not the blur needs to unpack/repack floats
  19736. */
  19737. packedFloat: boolean;
  19738. /**
  19739. * Creates a new instance of @see BlurPostProcess
  19740. * @param name The name of the effect.
  19741. * @param direction The direction in which to blur the image.
  19742. * @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.
  19743. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  19744. * @param camera The camera to apply the render pass to.
  19745. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  19746. * @param engine The engine which the post process will be applied. (default: current engine)
  19747. * @param reusable If the post process can be reused on the same frame. (default: false)
  19748. * @param textureType Type of textures used when performing the post process. (default: 0)
  19749. */
  19750. 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);
  19751. protected _updateParameters(): void;
  19752. /**
  19753. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  19754. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  19755. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  19756. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  19757. * The gaps between physical kernels are compensated for in the weighting of the samples
  19758. * @param idealKernel Ideal blur kernel.
  19759. * @return Nearest best kernel.
  19760. */
  19761. protected _nearestBestKernel(idealKernel: number): number;
  19762. /**
  19763. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  19764. * @param x The point on the Gaussian distribution to sample.
  19765. * @return the value of the Gaussian function at x.
  19766. */
  19767. protected _gaussianWeight(x: number): number;
  19768. /**
  19769. * Generates a string that can be used as a floating point number in GLSL.
  19770. * @param x Value to print.
  19771. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  19772. * @return GLSL float string.
  19773. */
  19774. protected _glslFloat(x: number, decimalFigures?: number): string;
  19775. }
  19776. }
  19777. declare module BABYLON {
  19778. /**
  19779. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  19780. */
  19781. class CircleOfConfusionPostProcess extends PostProcess {
  19782. /**
  19783. * 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.
  19784. */
  19785. lensSize: number;
  19786. /**
  19787. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  19788. */
  19789. fStop: number;
  19790. /**
  19791. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  19792. */
  19793. focusDistance: number;
  19794. /**
  19795. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  19796. */
  19797. focalLength: number;
  19798. /**
  19799. * Creates a new instance of @see CircleOfConfusionPostProcess
  19800. * @param name The name of the effect.
  19801. * @param depthTexture The depth texture of the scene to compute the circle of confusion.
  19802. * @param options The required width/height ratio to downsize to before computing the render pass.
  19803. * @param camera The camera to apply the render pass to.
  19804. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  19805. * @param engine The engine which the post process will be applied. (default: current engine)
  19806. * @param reusable If the post process can be reused on the same frame. (default: false)
  19807. * @param textureType Type of textures used when performing the post process. (default: 0)
  19808. */
  19809. constructor(name: string, depthTexture: RenderTargetTexture, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  19810. }
  19811. }
  19812. declare module BABYLON {
  19813. class ColorCorrectionPostProcess extends PostProcess {
  19814. private _colorTableTexture;
  19815. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  19816. }
  19817. }
  19818. declare module BABYLON {
  19819. class ConvolutionPostProcess extends PostProcess {
  19820. kernel: number[];
  19821. constructor(name: string, kernel: number[], options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  19822. static EdgeDetect0Kernel: number[];
  19823. static EdgeDetect1Kernel: number[];
  19824. static EdgeDetect2Kernel: number[];
  19825. static SharpenKernel: number[];
  19826. static EmbossKernel: number[];
  19827. static GaussianKernel: number[];
  19828. }
  19829. }
  19830. declare module BABYLON {
  19831. /**
  19832. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  19833. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  19834. * based on samples that have a large difference in distance than the center pixel.
  19835. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  19836. */
  19837. class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  19838. direction: Vector2;
  19839. /**
  19840. * Creates a new instance of @see CircleOfConfusionPostProcess
  19841. * @param name The name of the effect.
  19842. * @param scene The scene the effect belongs to.
  19843. * @param direction The direction the blur should be applied.
  19844. * @param kernel The size of the kernel used to blur.
  19845. * @param options The required width/height ratio to downsize to before computing the render pass.
  19846. * @param camera The camera to apply the render pass to.
  19847. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  19848. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  19849. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  19850. * @param engine The engine which the post process will be applied. (default: current engine)
  19851. * @param reusable If the post process can be reused on the same frame. (default: false)
  19852. * @param textureType Type of textures used when performing the post process. (default: 0)
  19853. */
  19854. 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);
  19855. }
  19856. }
  19857. declare module BABYLON {
  19858. /**
  19859. * Specifies the level of max blur that should be applied when using the depth of field effect
  19860. */
  19861. enum DepthOfFieldEffectBlurLevel {
  19862. /**
  19863. * Subtle blur
  19864. */
  19865. Low = 0,
  19866. /**
  19867. * Medium blur
  19868. */
  19869. Medium = 1,
  19870. /**
  19871. * Large blur
  19872. */
  19873. High = 2,
  19874. }
  19875. /**
  19876. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  19877. */
  19878. class DepthOfFieldEffect extends PostProcessRenderEffect {
  19879. private _depthOfFieldPass;
  19880. private _circleOfConfusion;
  19881. private _depthOfFieldBlurX;
  19882. private _depthOfFieldBlurY;
  19883. private _depthOfFieldMerge;
  19884. /**
  19885. * The focal the length of the camera used in the effect
  19886. */
  19887. focalLength: number;
  19888. /**
  19889. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  19890. */
  19891. fStop: number;
  19892. /**
  19893. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  19894. */
  19895. focusDistance: number;
  19896. /**
  19897. * 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.
  19898. */
  19899. lensSize: number;
  19900. /**
  19901. * Creates a new instance of @see DepthOfFieldEffect
  19902. * @param scene The scene the effect belongs to.
  19903. * @param depthTexture The depth texture of the scene to compute the circle of confusion.
  19904. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  19905. */
  19906. constructor(scene: Scene, depthTexture: RenderTargetTexture, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number);
  19907. /**
  19908. * Disposes each of the internal effects for a given camera.
  19909. * @param camera The camera to dispose the effect on.
  19910. */
  19911. disposeEffects(camera: Camera): void;
  19912. }
  19913. }
  19914. declare module BABYLON {
  19915. /**
  19916. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  19917. */
  19918. class DepthOfFieldMergePostProcess extends PostProcess {
  19919. /**
  19920. * Creates a new instance of @see CircleOfConfusionPostProcess
  19921. * @param name The name of the effect.
  19922. * @param original The non-blurred image to be modified
  19923. * @param circleOfConfusion The circle of confusion post process that will determine how blurred each pixel should become.
  19924. * @param blurSteps Incrimental bluring post processes.
  19925. * @param options The required width/height ratio to downsize to before computing the render pass.
  19926. * @param camera The camera to apply the render pass to.
  19927. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  19928. * @param engine The engine which the post process will be applied. (default: current engine)
  19929. * @param reusable If the post process can be reused on the same frame. (default: false)
  19930. * @param textureType Type of textures used when performing the post process. (default: 0)
  19931. */
  19932. constructor(name: string, original: PostProcess, circleOfConfusion: PostProcess, blurSteps: Array<PostProcess>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  19933. }
  19934. }
  19935. declare module BABYLON {
  19936. class DisplayPassPostProcess extends PostProcess {
  19937. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  19938. }
  19939. }
  19940. declare module BABYLON {
  19941. class FilterPostProcess extends PostProcess {
  19942. kernelMatrix: Matrix;
  19943. constructor(name: string, kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  19944. }
  19945. }
  19946. declare module BABYLON {
  19947. class FxaaPostProcess extends PostProcess {
  19948. texelWidth: number;
  19949. texelHeight: number;
  19950. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  19951. }
  19952. }
  19953. declare module BABYLON {
  19954. class HighlightsPostProcess extends PostProcess {
  19955. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  19956. }
  19957. }
  19958. declare module BABYLON {
  19959. class ImageProcessingPostProcess extends PostProcess {
  19960. /**
  19961. * Default configuration related to image processing available in the PBR Material.
  19962. */
  19963. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  19964. /**
  19965. * Gets the image processing configuration used either in this material.
  19966. */
  19967. /**
  19968. * Sets the Default image processing configuration used either in the this material.
  19969. *
  19970. * If sets to null, the scene one is in use.
  19971. */
  19972. imageProcessingConfiguration: ImageProcessingConfiguration;
  19973. /**
  19974. * Keep track of the image processing observer to allow dispose and replace.
  19975. */
  19976. private _imageProcessingObserver;
  19977. /**
  19978. * Attaches a new image processing configuration to the PBR Material.
  19979. * @param configuration
  19980. */
  19981. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  19982. /**
  19983. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  19984. */
  19985. /**
  19986. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  19987. */
  19988. colorCurves: Nullable<ColorCurves>;
  19989. /**
  19990. * Gets wether the color curves effect is enabled.
  19991. */
  19992. /**
  19993. * Sets wether the color curves effect is enabled.
  19994. */
  19995. colorCurvesEnabled: boolean;
  19996. /**
  19997. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  19998. */
  19999. /**
  20000. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  20001. */
  20002. colorGradingTexture: Nullable<BaseTexture>;
  20003. /**
  20004. * Gets wether the color grading effect is enabled.
  20005. */
  20006. /**
  20007. * Gets wether the color grading effect is enabled.
  20008. */
  20009. colorGradingEnabled: boolean;
  20010. /**
  20011. * Gets exposure used in the effect.
  20012. */
  20013. /**
  20014. * Sets exposure used in the effect.
  20015. */
  20016. exposure: number;
  20017. /**
  20018. * Gets wether tonemapping is enabled or not.
  20019. */
  20020. /**
  20021. * Sets wether tonemapping is enabled or not
  20022. */
  20023. toneMappingEnabled: boolean;
  20024. /**
  20025. * Gets contrast used in the effect.
  20026. */
  20027. /**
  20028. * Sets contrast used in the effect.
  20029. */
  20030. contrast: number;
  20031. /**
  20032. * Gets Vignette stretch size.
  20033. */
  20034. /**
  20035. * Sets Vignette stretch size.
  20036. */
  20037. vignetteStretch: number;
  20038. /**
  20039. * Gets Vignette centre X Offset.
  20040. */
  20041. /**
  20042. * Sets Vignette centre X Offset.
  20043. */
  20044. vignetteCentreX: number;
  20045. /**
  20046. * Gets Vignette centre Y Offset.
  20047. */
  20048. /**
  20049. * Sets Vignette centre Y Offset.
  20050. */
  20051. vignetteCentreY: number;
  20052. /**
  20053. * Gets Vignette weight or intensity of the vignette effect.
  20054. */
  20055. /**
  20056. * Sets Vignette weight or intensity of the vignette effect.
  20057. */
  20058. vignetteWeight: number;
  20059. /**
  20060. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  20061. * if vignetteEnabled is set to true.
  20062. */
  20063. /**
  20064. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  20065. * if vignetteEnabled is set to true.
  20066. */
  20067. vignetteColor: Color4;
  20068. /**
  20069. * Gets Camera field of view used by the Vignette effect.
  20070. */
  20071. /**
  20072. * Sets Camera field of view used by the Vignette effect.
  20073. */
  20074. vignetteCameraFov: number;
  20075. /**
  20076. * Gets the vignette blend mode allowing different kind of effect.
  20077. */
  20078. /**
  20079. * Sets the vignette blend mode allowing different kind of effect.
  20080. */
  20081. vignetteBlendMode: number;
  20082. /**
  20083. * Gets wether the vignette effect is enabled.
  20084. */
  20085. /**
  20086. * Sets wether the vignette effect is enabled.
  20087. */
  20088. vignetteEnabled: boolean;
  20089. private _fromLinearSpace;
  20090. /**
  20091. * Gets wether the input of the processing is in Gamma or Linear Space.
  20092. */
  20093. /**
  20094. * Sets wether the input of the processing is in Gamma or Linear Space.
  20095. */
  20096. fromLinearSpace: boolean;
  20097. /**
  20098. * Defines cache preventing GC.
  20099. */
  20100. private _defines;
  20101. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  20102. getClassName(): string;
  20103. protected _updateParameters(): void;
  20104. dispose(camera?: Camera): void;
  20105. }
  20106. }
  20107. declare module BABYLON {
  20108. class PassPostProcess extends PostProcess {
  20109. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  20110. }
  20111. }
  20112. declare module BABYLON {
  20113. type PostProcessOptions = {
  20114. width: number;
  20115. height: number;
  20116. };
  20117. /**
  20118. * PostProcess can be used to apply a shader to a texture after it has been rendered
  20119. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  20120. */
  20121. class PostProcess {
  20122. /** Name of the PostProcess. */ name: string;
  20123. /**
  20124. * Width of the texture to apply the post process on
  20125. */
  20126. width: number;
  20127. /**
  20128. * Height of the texture to apply the post process on
  20129. */
  20130. height: number;
  20131. /**
  20132. * Sampling mode used by the shader
  20133. * See https://doc.babylonjs.com/classes/3.1/texture
  20134. */
  20135. renderTargetSamplingMode: number;
  20136. /**
  20137. * Clear color to use when screen clearing
  20138. */
  20139. clearColor: Color4;
  20140. /**
  20141. * If the buffer needs to be cleared before applying the post process. (default: true)
  20142. * Should be set to false if shader will overwrite all previous pixels.
  20143. */
  20144. autoClear: boolean;
  20145. /**
  20146. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  20147. */
  20148. alphaMode: number;
  20149. /**
  20150. * Sets the setAlphaBlendConstants of the babylon engine
  20151. */
  20152. alphaConstants: Color4;
  20153. /**
  20154. * Animations to be used for the post processing
  20155. */
  20156. animations: Animation[];
  20157. /**
  20158. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  20159. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  20160. */
  20161. enablePixelPerfectMode: boolean;
  20162. /**
  20163. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  20164. */
  20165. scaleMode: number;
  20166. /**
  20167. * Force textures to be a power of two (default: false)
  20168. */
  20169. alwaysForcePOT: boolean;
  20170. /**
  20171. * Number of sample textures (default: 1)
  20172. */
  20173. samples: number;
  20174. /**
  20175. * Modify the scale of the post process to be the same as the viewport (default: false)
  20176. */
  20177. adaptScaleToCurrentViewport: boolean;
  20178. private _camera;
  20179. private _scene;
  20180. private _engine;
  20181. private _options;
  20182. private _reusable;
  20183. private _textureType;
  20184. /**
  20185. * Smart array of input and output textures for the post process.
  20186. */
  20187. _textures: SmartArray<InternalTexture>;
  20188. /**
  20189. * The index in _textures that corresponds to the output texture.
  20190. */
  20191. _currentRenderTextureInd: number;
  20192. private _effect;
  20193. private _samplers;
  20194. private _fragmentUrl;
  20195. private _vertexUrl;
  20196. private _parameters;
  20197. private _scaleRatio;
  20198. protected _indexParameters: any;
  20199. private _shareOutputWithPostProcess;
  20200. private _texelSize;
  20201. private _forcedOutputTexture;
  20202. /**
  20203. * An event triggered when the postprocess is activated.
  20204. * @type {BABYLON.Observable}
  20205. */
  20206. onActivateObservable: Observable<Camera>;
  20207. private _onActivateObserver;
  20208. /**
  20209. * A function that is added to the onActivateObservable
  20210. */
  20211. onActivate: Nullable<(camera: Camera) => void>;
  20212. /**
  20213. * An event triggered when the postprocess changes its size.
  20214. * @type {BABYLON.Observable}
  20215. */
  20216. onSizeChangedObservable: Observable<PostProcess>;
  20217. private _onSizeChangedObserver;
  20218. /**
  20219. * A function that is added to the onSizeChangedObservable
  20220. */
  20221. onSizeChanged: (postProcess: PostProcess) => void;
  20222. /**
  20223. * An event triggered when the postprocess applies its effect.
  20224. * @type {BABYLON.Observable}
  20225. */
  20226. onApplyObservable: Observable<Effect>;
  20227. private _onApplyObserver;
  20228. /**
  20229. * A function that is added to the onApplyObservable
  20230. */
  20231. onApply: (effect: Effect) => void;
  20232. /**
  20233. * An event triggered before rendering the postprocess
  20234. * @type {BABYLON.Observable}
  20235. */
  20236. onBeforeRenderObservable: Observable<Effect>;
  20237. private _onBeforeRenderObserver;
  20238. /**
  20239. * A function that is added to the onBeforeRenderObservable
  20240. */
  20241. onBeforeRender: (effect: Effect) => void;
  20242. /**
  20243. * An event triggered after rendering the postprocess
  20244. * @type {BABYLON.Observable}
  20245. */
  20246. onAfterRenderObservable: Observable<Effect>;
  20247. private _onAfterRenderObserver;
  20248. /**
  20249. * A function that is added to the onAfterRenderObservable
  20250. */
  20251. onAfterRender: (efect: Effect) => void;
  20252. /**
  20253. * 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
  20254. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  20255. */
  20256. inputTexture: InternalTexture;
  20257. /**
  20258. * Gets the camera which post process is applied to.
  20259. * @returns The camera the post process is applied to.
  20260. */
  20261. getCamera(): Camera;
  20262. /**
  20263. * Gets the texel size of the postprocess.
  20264. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  20265. */
  20266. readonly texelSize: Vector2;
  20267. /**
  20268. * Creates a new instance of @see PostProcess
  20269. * @param name The name of the PostProcess.
  20270. * @param fragmentUrl The url of the fragment shader to be used.
  20271. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  20272. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  20273. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  20274. * @param camera The camera to apply the render pass to.
  20275. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  20276. * @param engine The engine which the post process will be applied. (default: current engine)
  20277. * @param reusable If the post process can be reused on the same frame. (default: false)
  20278. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  20279. * @param textureType Type of textures used when performing the post process. (default: 0)
  20280. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  20281. * @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
  20282. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  20283. */
  20284. 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);
  20285. /**
  20286. * Gets the engine which this post process belongs to.
  20287. * @returns The engine the post process was enabled with.
  20288. */
  20289. getEngine(): Engine;
  20290. /**
  20291. * The effect that is created when initializing the post process.
  20292. * @returns The created effect corrisponding the the postprocess.
  20293. */
  20294. getEffect(): Effect;
  20295. /**
  20296. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  20297. * @param postProcess The post process to share the output with.
  20298. * @returns This post process.
  20299. */
  20300. shareOutputWith(postProcess: PostProcess): PostProcess;
  20301. /**
  20302. * Updates the effect with the current post process compile time values and recompiles the shader.
  20303. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  20304. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  20305. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  20306. * @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
  20307. * @param onCompiled Called when the shader has been compiled.
  20308. * @param onError Called if there is an error when compiling a shader.
  20309. */
  20310. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  20311. /**
  20312. * The post process is reusable if it can be used multiple times within one frame.
  20313. * @returns If the post process is reusable
  20314. */
  20315. isReusable(): boolean;
  20316. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  20317. markTextureDirty(): void;
  20318. /**
  20319. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  20320. * 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.
  20321. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  20322. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  20323. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  20324. */
  20325. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): void;
  20326. /**
  20327. * If the post process is supported.
  20328. */
  20329. readonly isSupported: boolean;
  20330. /**
  20331. * The aspect ratio of the output texture.
  20332. */
  20333. readonly aspectRatio: number;
  20334. /**
  20335. * Get a value indicating if the post-process is ready to be used
  20336. * @returns true if the post-process is ready (shader is compiled)
  20337. */
  20338. isReady(): boolean;
  20339. /**
  20340. * Binds all textures and uniforms to the shader, this will be run on every pass.
  20341. * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
  20342. */
  20343. apply(): Nullable<Effect>;
  20344. private _disposeTextures();
  20345. /**
  20346. * Disposes the post process.
  20347. * @param camera The camera to dispose the post process on.
  20348. */
  20349. dispose(camera?: Camera): void;
  20350. }
  20351. }
  20352. declare module BABYLON {
  20353. /**
  20354. * PostProcessManager is used to manage one or more post processes or post process pipelines
  20355. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  20356. */
  20357. class PostProcessManager {
  20358. private _scene;
  20359. private _indexBuffer;
  20360. private _vertexBuffers;
  20361. /**
  20362. * Creates a new instance of @see PostProcess
  20363. * @param scene The scene that the post process is associated with.
  20364. */
  20365. constructor(scene: Scene);
  20366. private _prepareBuffers();
  20367. private _buildIndexBuffer();
  20368. /**
  20369. * Rebuilds the vertex buffers of the manager.
  20370. */
  20371. _rebuild(): void;
  20372. /**
  20373. * Prepares a frame to be run through a post process.
  20374. * @param sourceTexture The input texture to the post procesess. (default: null)
  20375. * @param postProcesses An array of post processes to be run. (default: null)
  20376. * @returns True if the post processes were able to be run.
  20377. */
  20378. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  20379. /**
  20380. * Manually render a set of post processes to a texture.
  20381. * @param postProcesses An array of post processes to be run.
  20382. * @param targetTexture The target texture to render to.
  20383. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  20384. */
  20385. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean): void;
  20386. /**
  20387. * Finalize the result of the output of the postprocesses.
  20388. * @param doNotPresent If true the result will not be displayed to the screen.
  20389. * @param targetTexture The target texture to render to.
  20390. * @param faceIndex The index of the face to bind the target texture to.
  20391. * @param postProcesses The array of post processes to render.
  20392. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  20393. */
  20394. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: PostProcess[], forceFullscreenViewport?: boolean): void;
  20395. /**
  20396. * Disposes of the post process manager.
  20397. */
  20398. dispose(): void;
  20399. }
  20400. }
  20401. declare module BABYLON {
  20402. class RefractionPostProcess extends PostProcess {
  20403. color: Color3;
  20404. depth: number;
  20405. colorLevel: number;
  20406. private _refTexture;
  20407. private _ownRefractionTexture;
  20408. /**
  20409. * Gets or sets the refraction texture
  20410. * Please note that you are responsible for disposing the texture if you set it manually
  20411. */
  20412. refractionTexture: Texture;
  20413. constructor(name: string, refractionTextureUrl: string, color: Color3, depth: number, colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  20414. dispose(camera: Camera): void;
  20415. }
  20416. }
  20417. declare module BABYLON {
  20418. class StereoscopicInterlacePostProcess extends PostProcess {
  20419. private _stepSize;
  20420. private _passedProcess;
  20421. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  20422. }
  20423. }
  20424. declare module BABYLON {
  20425. enum TonemappingOperator {
  20426. Hable = 0,
  20427. Reinhard = 1,
  20428. HejiDawson = 2,
  20429. Photographic = 3,
  20430. }
  20431. class TonemapPostProcess extends PostProcess {
  20432. private _operator;
  20433. exposureAdjustment: number;
  20434. constructor(name: string, _operator: TonemappingOperator, exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  20435. }
  20436. }
  20437. declare module BABYLON {
  20438. class VolumetricLightScatteringPostProcess extends PostProcess {
  20439. private _volumetricLightScatteringPass;
  20440. private _volumetricLightScatteringRTT;
  20441. private _viewPort;
  20442. private _screenCoordinates;
  20443. private _cachedDefines;
  20444. /**
  20445. * If not undefined, the mesh position is computed from the attached node position
  20446. * @type {{position: Vector3}}
  20447. */
  20448. attachedNode: {
  20449. position: Vector3;
  20450. };
  20451. /**
  20452. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  20453. * @type {Vector3}
  20454. */
  20455. customMeshPosition: Vector3;
  20456. /**
  20457. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  20458. * @type {boolean}
  20459. */
  20460. useCustomMeshPosition: boolean;
  20461. /**
  20462. * If the post-process should inverse the light scattering direction
  20463. * @type {boolean}
  20464. */
  20465. invert: boolean;
  20466. /**
  20467. * The internal mesh used by the post-process
  20468. * @type {boolean}
  20469. */
  20470. mesh: Mesh;
  20471. useDiffuseColor: boolean;
  20472. /**
  20473. * Array containing the excluded meshes not rendered in the internal pass
  20474. */
  20475. excludedMeshes: AbstractMesh[];
  20476. /**
  20477. * Controls the overall intensity of the post-process
  20478. * @type {number}
  20479. */
  20480. exposure: number;
  20481. /**
  20482. * Dissipates each sample's contribution in range [0, 1]
  20483. * @type {number}
  20484. */
  20485. decay: number;
  20486. /**
  20487. * Controls the overall intensity of each sample
  20488. * @type {number}
  20489. */
  20490. weight: number;
  20491. /**
  20492. * Controls the density of each sample
  20493. * @type {number}
  20494. */
  20495. density: number;
  20496. /**
  20497. * @constructor
  20498. * @param {string} name - The post-process name
  20499. * @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)
  20500. * @param {BABYLON.Camera} camera - The camera that the post-process will be attached to
  20501. * @param {BABYLON.Mesh} mesh - The mesh used to create the light scattering
  20502. * @param {number} samples - The post-process quality, default 100
  20503. * @param {number} samplingMode - The post-process filtering mode
  20504. * @param {BABYLON.Engine} engine - The babylon engine
  20505. * @param {boolean} reusable - If the post-process is reusable
  20506. * @param {BABYLON.Scene} scene - The constructor needs a scene reference to initialize internal components. If "camera" is null (RenderPipelineà, "scene" must be provided
  20507. */
  20508. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  20509. getClassName(): string;
  20510. private _isReady(subMesh, useInstances);
  20511. /**
  20512. * Sets the new light position for light scattering effect
  20513. * @param {BABYLON.Vector3} The new custom light position
  20514. */
  20515. setCustomMeshPosition(position: Vector3): void;
  20516. /**
  20517. * Returns the light position for light scattering effect
  20518. * @return {BABYLON.Vector3} The custom light position
  20519. */
  20520. getCustomMeshPosition(): Vector3;
  20521. /**
  20522. * Disposes the internal assets and detaches the post-process from the camera
  20523. */
  20524. dispose(camera: Camera): void;
  20525. /**
  20526. * Returns the render target texture used by the post-process
  20527. * @return {BABYLON.RenderTargetTexture} The render target texture used by the post-process
  20528. */
  20529. getPass(): RenderTargetTexture;
  20530. private _meshExcluded(mesh);
  20531. private _createPass(scene, ratio);
  20532. private _updateMeshScreenCoordinates(scene);
  20533. /**
  20534. * Creates a default mesh for the Volumeric Light Scattering post-process
  20535. * @param {string} The mesh name
  20536. * @param {BABYLON.Scene} The scene where to create the mesh
  20537. * @return {BABYLON.Mesh} the default mesh
  20538. */
  20539. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  20540. }
  20541. }
  20542. declare module BABYLON {
  20543. class VRDistortionCorrectionPostProcess extends PostProcess {
  20544. aspectRatio: number;
  20545. private _isRightEye;
  20546. private _distortionFactors;
  20547. private _postProcessScaleFactor;
  20548. private _lensCenterOffset;
  20549. private _scaleIn;
  20550. private _scaleFactor;
  20551. private _lensCenter;
  20552. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  20553. }
  20554. }
  20555. declare module BABYLON {
  20556. class Sprite {
  20557. name: string;
  20558. position: Vector3;
  20559. color: Color4;
  20560. width: number;
  20561. height: number;
  20562. angle: number;
  20563. cellIndex: number;
  20564. invertU: number;
  20565. invertV: number;
  20566. disposeWhenFinishedAnimating: boolean;
  20567. animations: Animation[];
  20568. isPickable: boolean;
  20569. actionManager: ActionManager;
  20570. private _animationStarted;
  20571. private _loopAnimation;
  20572. private _fromIndex;
  20573. private _toIndex;
  20574. private _delay;
  20575. private _direction;
  20576. private _manager;
  20577. private _time;
  20578. private _onAnimationEnd;
  20579. size: number;
  20580. constructor(name: string, manager: SpriteManager);
  20581. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  20582. stopAnimation(): void;
  20583. _animate(deltaTime: number): void;
  20584. dispose(): void;
  20585. }
  20586. }
  20587. declare module BABYLON {
  20588. class SpriteManager {
  20589. name: string;
  20590. sprites: Sprite[];
  20591. renderingGroupId: number;
  20592. layerMask: number;
  20593. fogEnabled: boolean;
  20594. isPickable: boolean;
  20595. cellWidth: number;
  20596. cellHeight: number;
  20597. /**
  20598. * An event triggered when the manager is disposed.
  20599. * @type {BABYLON.Observable}
  20600. */
  20601. onDisposeObservable: Observable<SpriteManager>;
  20602. private _onDisposeObserver;
  20603. onDispose: () => void;
  20604. private _capacity;
  20605. private _spriteTexture;
  20606. private _epsilon;
  20607. private _scene;
  20608. private _vertexData;
  20609. private _buffer;
  20610. private _vertexBuffers;
  20611. private _indexBuffer;
  20612. private _effectBase;
  20613. private _effectFog;
  20614. texture: Texture;
  20615. constructor(name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  20616. private _appendSpriteVertex(index, sprite, offsetX, offsetY, rowSize);
  20617. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  20618. render(): void;
  20619. dispose(): void;
  20620. }
  20621. }
  20622. declare module BABYLON {
  20623. class _AlphaState {
  20624. private _isAlphaBlendDirty;
  20625. private _isBlendFunctionParametersDirty;
  20626. private _isBlendEquationParametersDirty;
  20627. private _isBlendConstantsDirty;
  20628. private _alphaBlend;
  20629. private _blendFunctionParameters;
  20630. private _blendEquationParameters;
  20631. private _blendConstants;
  20632. /**
  20633. * Initializes the state.
  20634. */
  20635. constructor();
  20636. readonly isDirty: boolean;
  20637. alphaBlend: boolean;
  20638. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  20639. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  20640. setAlphaEquationParameters(rgb: number, alpha: number): void;
  20641. reset(): void;
  20642. apply(gl: WebGLRenderingContext): void;
  20643. }
  20644. }
  20645. declare module BABYLON {
  20646. class _DepthCullingState {
  20647. private _isDepthTestDirty;
  20648. private _isDepthMaskDirty;
  20649. private _isDepthFuncDirty;
  20650. private _isCullFaceDirty;
  20651. private _isCullDirty;
  20652. private _isZOffsetDirty;
  20653. private _isFrontFaceDirty;
  20654. private _depthTest;
  20655. private _depthMask;
  20656. private _depthFunc;
  20657. private _cull;
  20658. private _cullFace;
  20659. private _zOffset;
  20660. private _frontFace;
  20661. /**
  20662. * Initializes the state.
  20663. */
  20664. constructor();
  20665. readonly isDirty: boolean;
  20666. zOffset: number;
  20667. cullFace: Nullable<number>;
  20668. cull: Nullable<boolean>;
  20669. depthFunc: Nullable<number>;
  20670. depthMask: boolean;
  20671. depthTest: boolean;
  20672. frontFace: Nullable<number>;
  20673. reset(): void;
  20674. apply(gl: WebGLRenderingContext): void;
  20675. }
  20676. }
  20677. declare module BABYLON {
  20678. class _StencilState {
  20679. private _isStencilTestDirty;
  20680. private _isStencilMaskDirty;
  20681. private _isStencilFuncDirty;
  20682. private _isStencilOpDirty;
  20683. private _stencilTest;
  20684. private _stencilMask;
  20685. private _stencilFunc;
  20686. private _stencilFuncRef;
  20687. private _stencilFuncMask;
  20688. private _stencilOpStencilFail;
  20689. private _stencilOpDepthFail;
  20690. private _stencilOpStencilDepthPass;
  20691. readonly isDirty: boolean;
  20692. stencilFunc: number;
  20693. stencilFuncRef: number;
  20694. stencilFuncMask: number;
  20695. stencilOpStencilFail: number;
  20696. stencilOpDepthFail: number;
  20697. stencilOpStencilDepthPass: number;
  20698. stencilMask: number;
  20699. stencilTest: boolean;
  20700. constructor();
  20701. reset(): void;
  20702. apply(gl: WebGLRenderingContext): void;
  20703. }
  20704. }
  20705. declare module BABYLON {
  20706. class AndOrNotEvaluator {
  20707. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  20708. private static _HandleParenthesisContent(parenthesisContent, evaluateCallback);
  20709. private static _SimplifyNegation(booleanString);
  20710. }
  20711. }
  20712. declare module BABYLON {
  20713. /**
  20714. * Defines the list of states available for a task inside a {BABYLON.AssetsManager}
  20715. */
  20716. enum AssetTaskState {
  20717. /**
  20718. * Initialization
  20719. */
  20720. INIT = 0,
  20721. /**
  20722. * Running
  20723. */
  20724. RUNNING = 1,
  20725. /**
  20726. * Done
  20727. */
  20728. DONE = 2,
  20729. /**
  20730. * Error
  20731. */
  20732. ERROR = 3,
  20733. }
  20734. /**
  20735. * Define an abstract asset task used with a {BABYLON.AssetsManager} class to load assets into a scene
  20736. */
  20737. abstract class AbstractAssetTask {
  20738. /**
  20739. * Task name
  20740. */ name: string;
  20741. /**
  20742. * Callback called when the task is successful
  20743. */
  20744. onSuccess: (task: any) => void;
  20745. /**
  20746. * Callback called when the task is successful
  20747. */
  20748. onError: (task: any, message?: string, exception?: any) => void;
  20749. /**
  20750. * Creates a new {BABYLON.AssetsManager}
  20751. * @param name defines the name of the task
  20752. */
  20753. constructor(
  20754. /**
  20755. * Task name
  20756. */ name: string);
  20757. private _isCompleted;
  20758. private _taskState;
  20759. private _errorObject;
  20760. /**
  20761. * Get if the task is completed
  20762. */
  20763. readonly isCompleted: boolean;
  20764. /**
  20765. * Gets the current state of the task
  20766. */
  20767. readonly taskState: AssetTaskState;
  20768. /**
  20769. * Gets the current error object (if task is in error)
  20770. */
  20771. readonly errorObject: {
  20772. message?: string;
  20773. exception?: any;
  20774. };
  20775. /**
  20776. * Internal only
  20777. * @ignore
  20778. */
  20779. _setErrorObject(message?: string, exception?: any): void;
  20780. /**
  20781. * Execute the current task
  20782. * @param scene defines the scene where you want your assets to be loaded
  20783. * @param onSuccess is a callback called when the task is successfully executed
  20784. * @param onError is a callback called if an error occurs
  20785. */
  20786. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  20787. /**
  20788. * Execute the current task
  20789. * @param scene defines the scene where you want your assets to be loaded
  20790. * @param onSuccess is a callback called when the task is successfully executed
  20791. * @param onError is a callback called if an error occurs
  20792. */
  20793. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  20794. private onErrorCallback(onError, message?, exception?);
  20795. private onDoneCallback(onSuccess, onError);
  20796. }
  20797. /**
  20798. * Define the interface used by progress events raised during assets loading
  20799. */
  20800. interface IAssetsProgressEvent {
  20801. /**
  20802. * Defines the number of remaining tasks to process
  20803. */
  20804. remainingCount: number;
  20805. /**
  20806. * Defines the total number of tasks
  20807. */
  20808. totalCount: number;
  20809. /**
  20810. * Defines the task that was just processed
  20811. */
  20812. task: AbstractAssetTask;
  20813. }
  20814. /**
  20815. * Class used to share progress information about assets loading
  20816. */
  20817. class AssetsProgressEvent implements IAssetsProgressEvent {
  20818. /**
  20819. * Defines the number of remaining tasks to process
  20820. */
  20821. remainingCount: number;
  20822. /**
  20823. * Defines the total number of tasks
  20824. */
  20825. totalCount: number;
  20826. /**
  20827. * Defines the task that was just processed
  20828. */
  20829. task: AbstractAssetTask;
  20830. /**
  20831. * Creates a {BABYLON.AssetsProgressEvent}
  20832. * @param remainingCount defines the number of remaining tasks to process
  20833. * @param totalCount defines the total number of tasks
  20834. * @param task defines the task that was just processed
  20835. */
  20836. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  20837. }
  20838. /**
  20839. * Define a task used by {BABYLON.AssetsManager} to load meshes
  20840. */
  20841. class MeshAssetTask extends AbstractAssetTask {
  20842. /**
  20843. * Defines the name of the task
  20844. */
  20845. name: string;
  20846. /**
  20847. * Defines the list of mesh's names you want to load
  20848. */
  20849. meshesNames: any;
  20850. /**
  20851. * Defines the root url to use as a base to load your meshes and associated resources
  20852. */
  20853. rootUrl: string;
  20854. /**
  20855. * Defines the filename of the scene to load from
  20856. */
  20857. sceneFilename: string;
  20858. /**
  20859. * Gets the list of loaded meshes
  20860. */
  20861. loadedMeshes: Array<AbstractMesh>;
  20862. /**
  20863. * Gets the list of loaded particle systems
  20864. */
  20865. loadedParticleSystems: Array<ParticleSystem>;
  20866. /**
  20867. * Gets the list of loaded skeletons
  20868. */
  20869. loadedSkeletons: Array<Skeleton>;
  20870. /**
  20871. * Callback called when the task is successful
  20872. */
  20873. onSuccess: (task: MeshAssetTask) => void;
  20874. /**
  20875. * Callback called when the task is successful
  20876. */
  20877. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  20878. /**
  20879. * Creates a new {BABYLON.MeshAssetTask}
  20880. * @param name defines the name of the task
  20881. * @param meshesNames defines the list of mesh's names you want to load
  20882. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  20883. * @param sceneFilename defines the filename of the scene to load from
  20884. */
  20885. constructor(
  20886. /**
  20887. * Defines the name of the task
  20888. */
  20889. name: string,
  20890. /**
  20891. * Defines the list of mesh's names you want to load
  20892. */
  20893. meshesNames: any,
  20894. /**
  20895. * Defines the root url to use as a base to load your meshes and associated resources
  20896. */
  20897. rootUrl: string,
  20898. /**
  20899. * Defines the filename of the scene to load from
  20900. */
  20901. sceneFilename: string);
  20902. /**
  20903. * Execute the current task
  20904. * @param scene defines the scene where you want your assets to be loaded
  20905. * @param onSuccess is a callback called when the task is successfully executed
  20906. * @param onError is a callback called if an error occurs
  20907. */
  20908. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  20909. }
  20910. /**
  20911. * Define a task used by {BABYLON.AssetsManager} to load text content
  20912. */
  20913. class TextFileAssetTask extends AbstractAssetTask {
  20914. /**
  20915. * Defines the name of the task
  20916. */
  20917. name: string;
  20918. /**
  20919. * Defines the location of the file to load
  20920. */
  20921. url: string;
  20922. /**
  20923. * Gets the loaded text string
  20924. */
  20925. text: string;
  20926. /**
  20927. * Callback called when the task is successful
  20928. */
  20929. onSuccess: (task: TextFileAssetTask) => void;
  20930. /**
  20931. * Callback called when the task is successful
  20932. */
  20933. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  20934. /**
  20935. * Creates a new TextFileAssetTask object
  20936. * @param name defines the name of the task
  20937. * @param url defines the location of the file to load
  20938. */
  20939. constructor(
  20940. /**
  20941. * Defines the name of the task
  20942. */
  20943. name: string,
  20944. /**
  20945. * Defines the location of the file to load
  20946. */
  20947. url: string);
  20948. /**
  20949. * Execute the current task
  20950. * @param scene defines the scene where you want your assets to be loaded
  20951. * @param onSuccess is a callback called when the task is successfully executed
  20952. * @param onError is a callback called if an error occurs
  20953. */
  20954. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  20955. }
  20956. /**
  20957. * Define a task used by {BABYLON.AssetsManager} to load binary data
  20958. */
  20959. class BinaryFileAssetTask extends AbstractAssetTask {
  20960. /**
  20961. * Defines the name of the task
  20962. */
  20963. name: string;
  20964. /**
  20965. * Defines the location of the file to load
  20966. */
  20967. url: string;
  20968. /**
  20969. * Gets the lodaded data (as an array buffer)
  20970. */
  20971. data: ArrayBuffer;
  20972. /**
  20973. * Callback called when the task is successful
  20974. */
  20975. onSuccess: (task: BinaryFileAssetTask) => void;
  20976. /**
  20977. * Callback called when the task is successful
  20978. */
  20979. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  20980. /**
  20981. * Creates a new BinaryFileAssetTask object
  20982. * @param name defines the name of the new task
  20983. * @param url defines the location of the file to load
  20984. */
  20985. constructor(
  20986. /**
  20987. * Defines the name of the task
  20988. */
  20989. name: string,
  20990. /**
  20991. * Defines the location of the file to load
  20992. */
  20993. url: string);
  20994. /**
  20995. * Execute the current task
  20996. * @param scene defines the scene where you want your assets to be loaded
  20997. * @param onSuccess is a callback called when the task is successfully executed
  20998. * @param onError is a callback called if an error occurs
  20999. */
  21000. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  21001. }
  21002. /**
  21003. * Define a task used by {BABYLON.AssetsManager} to load images
  21004. */
  21005. class ImageAssetTask extends AbstractAssetTask {
  21006. /**
  21007. * Defines the name of the task
  21008. */
  21009. name: string;
  21010. /**
  21011. * Defines the location of the image to load
  21012. */
  21013. url: string;
  21014. /**
  21015. * Gets the loaded images
  21016. */
  21017. image: HTMLImageElement;
  21018. /**
  21019. * Callback called when the task is successful
  21020. */
  21021. onSuccess: (task: ImageAssetTask) => void;
  21022. /**
  21023. * Callback called when the task is successful
  21024. */
  21025. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  21026. /**
  21027. * Creates a new ImageAssetTask
  21028. * @param name defines the name of the task
  21029. * @param url defines the location of the image to load
  21030. */
  21031. constructor(
  21032. /**
  21033. * Defines the name of the task
  21034. */
  21035. name: string,
  21036. /**
  21037. * Defines the location of the image to load
  21038. */
  21039. url: string);
  21040. /**
  21041. * Execute the current task
  21042. * @param scene defines the scene where you want your assets to be loaded
  21043. * @param onSuccess is a callback called when the task is successfully executed
  21044. * @param onError is a callback called if an error occurs
  21045. */
  21046. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  21047. }
  21048. /**
  21049. * Defines the interface used by texture loading tasks
  21050. */
  21051. interface ITextureAssetTask<TEX extends BaseTexture> {
  21052. /**
  21053. * Gets the loaded texture
  21054. */
  21055. texture: TEX;
  21056. }
  21057. /**
  21058. * Define a task used by {BABYLON.AssetsManager} to load 2D textures
  21059. */
  21060. class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  21061. /**
  21062. * Defines the name of the task
  21063. */
  21064. name: string;
  21065. /**
  21066. * Defines the location of the file to load
  21067. */
  21068. url: string;
  21069. /**
  21070. * Defines if mipmap should not be generated (default is false)
  21071. */
  21072. noMipmap: boolean | undefined;
  21073. /**
  21074. * Defines if texture must be inverted on Y axis (default is false)
  21075. */
  21076. invertY: boolean | undefined;
  21077. /**
  21078. * Defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  21079. */
  21080. samplingMode: number;
  21081. /**
  21082. * Gets the loaded texture
  21083. */
  21084. texture: Texture;
  21085. /**
  21086. * Callback called when the task is successful
  21087. */
  21088. onSuccess: (task: TextureAssetTask) => void;
  21089. /**
  21090. * Callback called when the task is successful
  21091. */
  21092. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  21093. /**
  21094. * Creates a new TextureAssetTask object
  21095. * @param name defines the name of the task
  21096. * @param url defines the location of the file to load
  21097. * @param noMipmap defines if mipmap should not be generated (default is false)
  21098. * @param invertY defines if texture must be inverted on Y axis (default is false)
  21099. * @param samplingMode defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  21100. */
  21101. constructor(
  21102. /**
  21103. * Defines the name of the task
  21104. */
  21105. name: string,
  21106. /**
  21107. * Defines the location of the file to load
  21108. */
  21109. url: string,
  21110. /**
  21111. * Defines if mipmap should not be generated (default is false)
  21112. */
  21113. noMipmap?: boolean | undefined,
  21114. /**
  21115. * Defines if texture must be inverted on Y axis (default is false)
  21116. */
  21117. invertY?: boolean | undefined,
  21118. /**
  21119. * Defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  21120. */
  21121. samplingMode?: number);
  21122. /**
  21123. * Execute the current task
  21124. * @param scene defines the scene where you want your assets to be loaded
  21125. * @param onSuccess is a callback called when the task is successfully executed
  21126. * @param onError is a callback called if an error occurs
  21127. */
  21128. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  21129. }
  21130. /**
  21131. * Define a task used by {BABYLON.AssetsManager} to load cube textures
  21132. */
  21133. class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  21134. /**
  21135. * Defines the name of the task
  21136. */
  21137. name: string;
  21138. /**
  21139. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  21140. */
  21141. url: string;
  21142. /**
  21143. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  21144. */
  21145. extensions: string[] | undefined;
  21146. /**
  21147. * Defines if mipmaps should not be generated (default is false)
  21148. */
  21149. noMipmap: boolean | undefined;
  21150. /**
  21151. * Defines the explicit list of files (undefined by default)
  21152. */
  21153. files: string[] | undefined;
  21154. /**
  21155. * Gets the loaded texture
  21156. */
  21157. texture: CubeTexture;
  21158. /**
  21159. * Callback called when the task is successful
  21160. */
  21161. onSuccess: (task: CubeTextureAssetTask) => void;
  21162. /**
  21163. * Callback called when the task is successful
  21164. */
  21165. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  21166. /**
  21167. * Creates a new CubeTextureAssetTask
  21168. * @param name defines the name of the task
  21169. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  21170. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  21171. * @param noMipmap defines if mipmaps should not be generated (default is false)
  21172. * @param files defines the explicit list of files (undefined by default)
  21173. */
  21174. constructor(
  21175. /**
  21176. * Defines the name of the task
  21177. */
  21178. name: string,
  21179. /**
  21180. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  21181. */
  21182. url: string,
  21183. /**
  21184. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  21185. */
  21186. extensions?: string[] | undefined,
  21187. /**
  21188. * Defines if mipmaps should not be generated (default is false)
  21189. */
  21190. noMipmap?: boolean | undefined,
  21191. /**
  21192. * Defines the explicit list of files (undefined by default)
  21193. */
  21194. files?: string[] | undefined);
  21195. /**
  21196. * Execute the current task
  21197. * @param scene defines the scene where you want your assets to be loaded
  21198. * @param onSuccess is a callback called when the task is successfully executed
  21199. * @param onError is a callback called if an error occurs
  21200. */
  21201. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  21202. }
  21203. /**
  21204. * Define a task used by {BABYLON.AssetsManager} to load HDR cube textures
  21205. */
  21206. class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  21207. /**
  21208. * Defines the name of the task
  21209. */
  21210. name: string;
  21211. /**
  21212. * Defines the location of the file to load
  21213. */
  21214. url: string;
  21215. /**
  21216. * 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.
  21217. */
  21218. size: number | undefined;
  21219. /**
  21220. * Defines if mipmaps should not be generated (default is false)
  21221. */
  21222. noMipmap: boolean;
  21223. /**
  21224. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  21225. */
  21226. generateHarmonics: boolean;
  21227. /**
  21228. * 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)
  21229. */
  21230. useInGammaSpace: boolean;
  21231. /**
  21232. * Specifies whether or not to generate the CubeMap through CubeMapGen to avoid seams issue at run time (default is false)
  21233. */
  21234. usePMREMGenerator: boolean;
  21235. /**
  21236. * Gets the loaded texture
  21237. */
  21238. texture: HDRCubeTexture;
  21239. /**
  21240. * Callback called when the task is successful
  21241. */
  21242. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  21243. /**
  21244. * Callback called when the task is successful
  21245. */
  21246. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  21247. /**
  21248. * Creates a new HDRCubeTextureAssetTask object
  21249. * @param name defines the name of the task
  21250. * @param url defines the location of the file to load
  21251. * @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.
  21252. * @param noMipmap defines if mipmaps should not be generated (default is false)
  21253. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  21254. * @param useInGammaSpace 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)
  21255. * @param usePMREMGenerator specifies whether or not to generate the CubeMap through CubeMapGen to avoid seams issue at run time (default is false)
  21256. */
  21257. constructor(
  21258. /**
  21259. * Defines the name of the task
  21260. */
  21261. name: string,
  21262. /**
  21263. * Defines the location of the file to load
  21264. */
  21265. url: string,
  21266. /**
  21267. * 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.
  21268. */
  21269. size?: number | undefined,
  21270. /**
  21271. * Defines if mipmaps should not be generated (default is false)
  21272. */
  21273. noMipmap?: boolean,
  21274. /**
  21275. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  21276. */
  21277. generateHarmonics?: boolean,
  21278. /**
  21279. * 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)
  21280. */
  21281. useInGammaSpace?: boolean,
  21282. /**
  21283. * Specifies whether or not to generate the CubeMap through CubeMapGen to avoid seams issue at run time (default is false)
  21284. */
  21285. usePMREMGenerator?: boolean);
  21286. /**
  21287. * Execute the current task
  21288. * @param scene defines the scene where you want your assets to be loaded
  21289. * @param onSuccess is a callback called when the task is successfully executed
  21290. * @param onError is a callback called if an error occurs
  21291. */
  21292. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  21293. }
  21294. /**
  21295. * This class can be used to easily import assets into a scene
  21296. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  21297. */
  21298. class AssetsManager {
  21299. private _scene;
  21300. private _isLoading;
  21301. protected _tasks: AbstractAssetTask[];
  21302. protected _waitingTasksCount: number;
  21303. protected _totalTasksCount: number;
  21304. /**
  21305. * Callback called when all tasks are processed
  21306. */
  21307. onFinish: (tasks: AbstractAssetTask[]) => void;
  21308. /**
  21309. * Callback called when a task is successful
  21310. */
  21311. onTaskSuccess: (task: AbstractAssetTask) => void;
  21312. /**
  21313. * Callback called when a task had an error
  21314. */
  21315. onTaskError: (task: AbstractAssetTask) => void;
  21316. /**
  21317. * Callback called when a task is done (whatever the result is)
  21318. */
  21319. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  21320. /**
  21321. * Observable called when all tasks are processed
  21322. */
  21323. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  21324. /**
  21325. * Observable called when a task had an error
  21326. */
  21327. onTaskErrorObservable: Observable<AbstractAssetTask>;
  21328. /**
  21329. * Observable called when a task is successful
  21330. */
  21331. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  21332. /**
  21333. * Observable called when a task is done (whatever the result is)
  21334. */
  21335. onProgressObservable: Observable<IAssetsProgressEvent>;
  21336. /**
  21337. * Gets or sets a boolean defining if the {BABYLON.AssetsManager} should use the default loading screen
  21338. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  21339. */
  21340. useDefaultLoadingScreen: boolean;
  21341. /**
  21342. * Creates a new AssetsManager
  21343. * @param scene defines the scene to work on
  21344. */
  21345. constructor(scene: Scene);
  21346. /**
  21347. * Add a {BABYLON.MeshAssetTask} to the list of active tasks
  21348. * @param taskName defines the name of the new task
  21349. * @param meshesNames defines the name of meshes to load
  21350. * @param rootUrl defines the root url to use to locate files
  21351. * @param sceneFilename defines the filename of the scene file
  21352. * @returns a new {BABYLON.MeshAssetTask} object
  21353. */
  21354. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  21355. /**
  21356. * Add a {BABYLON.TextFileAssetTask} to the list of active tasks
  21357. * @param taskName defines the name of the new task
  21358. * @param url defines the url of the file to load
  21359. * @returns a new {BABYLON.TextFileAssetTask} object
  21360. */
  21361. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  21362. /**
  21363. * Add a {BABYLON.BinaryFileAssetTask} to the list of active tasks
  21364. * @param taskName defines the name of the new task
  21365. * @param url defines the url of the file to load
  21366. * @returns a new {BABYLON.BinaryFileAssetTask} object
  21367. */
  21368. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  21369. /**
  21370. * Add a {BABYLON.ImageAssetTask} to the list of active tasks
  21371. * @param taskName defines the name of the new task
  21372. * @param url defines the url of the file to load
  21373. * @returns a new {BABYLON.ImageAssetTask} object
  21374. */
  21375. addImageTask(taskName: string, url: string): ImageAssetTask;
  21376. /**
  21377. * Add a {BABYLON.TextureAssetTask} to the list of active tasks
  21378. * @param taskName defines the name of the new task
  21379. * @param url defines the url of the file to load
  21380. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  21381. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  21382. * @param samplingMode defines the sampling mode to use (BABYLON.Texture.TRILINEAR_SAMPLINGMODE by default)
  21383. * @returns a new {BABYLON.TextureAssetTask} object
  21384. */
  21385. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  21386. /**
  21387. * Add a {BABYLON.CubeTextureAssetTask} to the list of active tasks
  21388. * @param taskName defines the name of the new task
  21389. * @param url defines the url of the file to load
  21390. * @param extensions defines the extension to use to load the cube map (can be null)
  21391. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  21392. * @param files defines the list of files to load (can be null)
  21393. * @returns a new {BABYLON.CubeTextureAssetTask} object
  21394. */
  21395. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  21396. /**
  21397. *
  21398. * Add a {BABYLON.HDRCubeTextureAssetTask} to the list of active tasks
  21399. * @param taskName defines the name of the new task
  21400. * @param url defines the url of the file to load
  21401. * @param size defines the size you want for the cubemap (can be null)
  21402. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  21403. * @param generateHarmonics defines if you want to automatically generate (true by default)
  21404. * @param useInGammaSpace defines if the texture must be considered in gamma space (false by default)
  21405. * @param usePMREMGenerator is a reserved parameter and must be set to false or ignored
  21406. * @returns a new {BABYLON.HDRCubeTextureAssetTask} object
  21407. */
  21408. addHDRCubeTextureTask(taskName: string, url: string, size?: number, noMipmap?: boolean, generateHarmonics?: boolean, useInGammaSpace?: boolean, usePMREMGenerator?: boolean): HDRCubeTextureAssetTask;
  21409. private _decreaseWaitingTasksCount(task);
  21410. private _runTask(task);
  21411. /**
  21412. * Reset the {BABYLON.AssetsManager} and remove all tasks
  21413. * @return the current instance of the {BABYLON.AssetsManager}
  21414. */
  21415. reset(): AssetsManager;
  21416. /**
  21417. * Start the loading process
  21418. * @return the current instance of the {BABYLON.AssetsManager}
  21419. */
  21420. load(): AssetsManager;
  21421. }
  21422. }
  21423. declare module BABYLON {
  21424. class Database {
  21425. private callbackManifestChecked;
  21426. private currentSceneUrl;
  21427. private db;
  21428. private _enableSceneOffline;
  21429. private _enableTexturesOffline;
  21430. private manifestVersionFound;
  21431. private mustUpdateRessources;
  21432. private hasReachedQuota;
  21433. private isSupported;
  21434. private idbFactory;
  21435. static IsUASupportingBlobStorage: boolean;
  21436. static IDBStorageEnabled: boolean;
  21437. readonly enableSceneOffline: boolean;
  21438. readonly enableTexturesOffline: boolean;
  21439. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any);
  21440. static parseURL: (url: string) => string;
  21441. static ReturnFullUrlLocation: (url: string) => string;
  21442. checkManifestFile(): void;
  21443. openAsync(successCallback: () => void, errorCallback: () => void): void;
  21444. loadImageFromDB(url: string, image: HTMLImageElement): void;
  21445. private _loadImageFromDBAsync(url, image, notInDBCallback);
  21446. private _saveImageIntoDBAsync(url, image);
  21447. private _checkVersionFromDB(url, versionLoaded);
  21448. private _loadVersionFromDBAsync(url, callback, updateInDBCallback);
  21449. private _saveVersionIntoDBAsync(url, callback);
  21450. loadFileFromDB(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  21451. private _loadFileFromDBAsync(url, callback, notInDBCallback, useArrayBuffer?);
  21452. private _saveFileIntoDBAsync(url, callback, progressCallback?, useArrayBuffer?);
  21453. }
  21454. }
  21455. declare module BABYLON {
  21456. interface DDSInfo {
  21457. width: number;
  21458. height: number;
  21459. mipmapCount: number;
  21460. isFourCC: boolean;
  21461. isRGB: boolean;
  21462. isLuminance: boolean;
  21463. isCube: boolean;
  21464. isCompressed: boolean;
  21465. dxgiFormat: number;
  21466. textureType: number;
  21467. }
  21468. class DDSTools {
  21469. static StoreLODInAlphaChannel: boolean;
  21470. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  21471. private static _FloatView;
  21472. private static _Int32View;
  21473. private static _ToHalfFloat(value);
  21474. private static _FromHalfFloat(value);
  21475. private static _GetHalfFloatAsFloatRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, lod);
  21476. private static _GetHalfFloatRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, lod);
  21477. private static _GetFloatRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, lod);
  21478. private static _GetFloatAsUIntRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, lod);
  21479. private static _GetHalfFloatAsUIntRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, lod);
  21480. private static _GetRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, rOffset, gOffset, bOffset, aOffset);
  21481. private static _ExtractLongWordOrder(value);
  21482. private static _GetRGBArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, rOffset, gOffset, bOffset);
  21483. private static _GetLuminanceArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer);
  21484. static UploadDDSLevels(engine: Engine, gl: WebGLRenderingContext, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  21485. }
  21486. }
  21487. declare module BABYLON {
  21488. function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  21489. function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  21490. function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  21491. function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  21492. function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  21493. function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  21494. function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  21495. function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  21496. function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  21497. function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  21498. function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  21499. function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  21500. class SerializationHelper {
  21501. static Serialize<T>(entity: T, serializationObject?: any): any;
  21502. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  21503. static Clone<T>(creationFunction: () => T, source: T): T;
  21504. static Instanciate<T>(creationFunction: () => T, source: T): T;
  21505. }
  21506. }
  21507. declare module BABYLON {
  21508. /**
  21509. * Wrapper class for promise with external resolve and reject.
  21510. */
  21511. class Deferred<T> {
  21512. /**
  21513. * The promise associated with this deferred object.
  21514. */
  21515. readonly promise: Promise<T>;
  21516. private _resolve;
  21517. private _reject;
  21518. /**
  21519. * The resolve method of the promise associated with this deferred object.
  21520. */
  21521. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  21522. /**
  21523. * The reject method of the promise associated with this deferred object.
  21524. */
  21525. readonly reject: (reason?: any) => void;
  21526. /**
  21527. * Constructor for this deferred object.
  21528. */
  21529. constructor();
  21530. }
  21531. }
  21532. declare module Earcut {
  21533. /**
  21534. * The fastest and smallest JavaScript polygon triangulation library for your WebGL apps
  21535. * @param data is a flat array of vertice coordinates like [x0, y0, x1, y1, x2, y2, ...].
  21536. * @param holeIndices is an array of hole indices if any (e.g. [5, 8] for a 12- vertice input would mean one hole with vertices 5–7 and another with 8–11).
  21537. * @param dim is the number of coordinates per vertice in the input array (2 by default).
  21538. */
  21539. function earcut(data: number[], holeIndices: number[], dim: number): Array<number>;
  21540. /**
  21541. * return a percentage difference between the polygon area and its triangulation area;
  21542. * used to verify correctness of triangulation
  21543. */
  21544. function deviation(data: number[], holeIndices: number[], dim: number, triangles: number[]): number;
  21545. /**
  21546. * turn a polygon in a multi-dimensional array form (e.g. as in GeoJSON) into a form Earcut accepts
  21547. */
  21548. function flatten(data: number[][][]): {
  21549. vertices: number[];
  21550. holes: number[];
  21551. dimensions: number;
  21552. };
  21553. }
  21554. declare module BABYLON {
  21555. class FilesInput {
  21556. static FilesToLoad: {
  21557. [key: string]: File;
  21558. };
  21559. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  21560. private _engine;
  21561. private _currentScene;
  21562. private _sceneLoadedCallback;
  21563. private _progressCallback;
  21564. private _additionalRenderLoopLogicCallback;
  21565. private _textureLoadingCallback;
  21566. private _startingProcessingFilesCallback;
  21567. private _onReloadCallback;
  21568. private _errorCallback;
  21569. private _elementToMonitor;
  21570. private _sceneFileToLoad;
  21571. private _filesToLoad;
  21572. 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);
  21573. private _dragEnterHandler;
  21574. private _dragOverHandler;
  21575. private _dropHandler;
  21576. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  21577. dispose(): void;
  21578. private renderFunction();
  21579. private drag(e);
  21580. private drop(eventDrop);
  21581. private _traverseFolder(folder, files, remaining, callback);
  21582. private _processFiles(files);
  21583. loadFiles(event: any): void;
  21584. private _processReload();
  21585. reload(): void;
  21586. }
  21587. }
  21588. declare module BABYLON {
  21589. /**
  21590. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  21591. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  21592. */
  21593. class KhronosTextureContainer {
  21594. arrayBuffer: any;
  21595. static HEADER_LEN: number;
  21596. static COMPRESSED_2D: number;
  21597. static COMPRESSED_3D: number;
  21598. static TEX_2D: number;
  21599. static TEX_3D: number;
  21600. glType: number;
  21601. glTypeSize: number;
  21602. glFormat: number;
  21603. glInternalFormat: number;
  21604. glBaseInternalFormat: number;
  21605. pixelWidth: number;
  21606. pixelHeight: number;
  21607. pixelDepth: number;
  21608. numberOfArrayElements: number;
  21609. numberOfFaces: number;
  21610. numberOfMipmapLevels: number;
  21611. bytesOfKeyValueData: number;
  21612. loadType: number;
  21613. /**
  21614. * @param {ArrayBuffer} arrayBuffer- contents of the KTX container file
  21615. * @param {number} facesExpected- should be either 1 or 6, based whether a cube texture or or
  21616. * @param {boolean} threeDExpected- provision for indicating that data should be a 3D texture, not implemented
  21617. * @param {boolean} textureArrayExpected- provision for indicating that data should be a texture array, not implemented
  21618. */
  21619. constructor(arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  21620. switchEndainness(val: number): number;
  21621. /**
  21622. * It is assumed that the texture has already been created & is currently bound
  21623. */
  21624. uploadLevels(gl: WebGLRenderingContext, loadMipmaps: boolean): void;
  21625. private _upload2DCompressedLevels(gl, loadMipmaps);
  21626. }
  21627. }
  21628. declare module BABYLON {
  21629. /**
  21630. * A class serves as a medium between the observable and its observers
  21631. */
  21632. class EventState {
  21633. /**
  21634. * Create a new EventState
  21635. * @param mask defines the mask associated with this state
  21636. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  21637. * @param target defines the original target of the state
  21638. * @param currentTarget defines the current target of the state
  21639. */
  21640. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  21641. /**
  21642. * Initialize the current event state
  21643. * @param mask defines the mask associated with this state
  21644. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  21645. * @param target defines the original target of the state
  21646. * @param currentTarget defines the current target of the state
  21647. * @returns the current event state
  21648. */
  21649. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  21650. /**
  21651. * An Observer can set this property to true to prevent subsequent observers of being notified
  21652. */
  21653. skipNextObservers: boolean;
  21654. /**
  21655. * Get the mask value that were used to trigger the event corresponding to this EventState object
  21656. */
  21657. mask: number;
  21658. /**
  21659. * The object that originally notified the event
  21660. */
  21661. target?: any;
  21662. /**
  21663. * The current object in the bubbling phase
  21664. */
  21665. currentTarget?: any;
  21666. /**
  21667. * This will be populated with the return value of the last function that was executed.
  21668. * If it is the first function in the callback chain it will be the event data.
  21669. */
  21670. lastReturnValue?: any;
  21671. }
  21672. /**
  21673. * Represent an Observer registered to a given Observable object.
  21674. */
  21675. class Observer<T> {
  21676. /**
  21677. * Defines the callback to call when the observer is notified
  21678. */
  21679. callback: (eventData: T, eventState: EventState) => void;
  21680. /**
  21681. * Defines the mask of the observer (used to filter notifications)
  21682. */
  21683. mask: number;
  21684. /**
  21685. * Defines the current scope used to restore the JS context
  21686. */
  21687. scope: any;
  21688. /** @ignore */
  21689. _willBeUnregistered: boolean;
  21690. /**
  21691. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  21692. */
  21693. unregisterOnNextCall: boolean;
  21694. /**
  21695. * Creates a new observer
  21696. * @param callback defines the callback to call when the observer is notified
  21697. * @param mask defines the mask of the observer (used to filter notifications)
  21698. * @param scope defines the current scope used to restore the JS context
  21699. */
  21700. constructor(
  21701. /**
  21702. * Defines the callback to call when the observer is notified
  21703. */
  21704. callback: (eventData: T, eventState: EventState) => void,
  21705. /**
  21706. * Defines the mask of the observer (used to filter notifications)
  21707. */
  21708. mask: number,
  21709. /**
  21710. * Defines the current scope used to restore the JS context
  21711. */
  21712. scope?: any);
  21713. }
  21714. /**
  21715. * Represent a list of observers registered to multiple Observables object.
  21716. */
  21717. class MultiObserver<T> {
  21718. private _observers;
  21719. private _observables;
  21720. /**
  21721. * Release associated resources
  21722. */
  21723. dispose(): void;
  21724. /**
  21725. * Raise a callback when one of the observable will notify
  21726. * @param observables defines a list of observables to watch
  21727. * @param callback defines the callback to call on notification
  21728. * @param mask defines the mask used to filter notifications
  21729. * @param scope defines the current scope used to restore the JS context
  21730. * @returns the new MultiObserver
  21731. */
  21732. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  21733. }
  21734. /**
  21735. * The Observable class is a simple implementation of the Observable pattern.
  21736. * 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.
  21737. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  21738. * 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).
  21739. * 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.
  21740. */
  21741. class Observable<T> {
  21742. private _observers;
  21743. private _eventState;
  21744. private _onObserverAdded;
  21745. /**
  21746. * Creates a new observable
  21747. * @param onObserverAdded defines a callback to call when a new observer is added
  21748. */
  21749. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  21750. /**
  21751. * Create a new Observer with the specified callback
  21752. * @param callback the callback that will be executed for that Observer
  21753. * @param mask the mask used to filter observers
  21754. * @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.
  21755. * @param scope optional scope for the callback to be called from
  21756. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  21757. * @returns the new observer created for the callback
  21758. */
  21759. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  21760. /**
  21761. * Remove an Observer from the Observable object
  21762. * @param observer the instance of the Observer to remove
  21763. * @returns false if it doesn't belong to this Observable
  21764. */
  21765. remove(observer: Nullable<Observer<T>>): boolean;
  21766. /**
  21767. * Remove a callback from the Observable object
  21768. * @param callback the callback to remove
  21769. * @param scope optional scope. If used only the callbacks with this scope will be removed
  21770. * @returns false if it doesn't belong to this Observable
  21771. */
  21772. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  21773. private _deferUnregister(observer);
  21774. /**
  21775. * Notify all Observers by calling their respective callback with the given data
  21776. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  21777. * @param eventData defines the data to send to all observers
  21778. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  21779. * @param target defines the original target of the state
  21780. * @param currentTarget defines the current target of the state
  21781. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  21782. */
  21783. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  21784. /**
  21785. * Calling this will execute each callback, expecting it to be a promise or return a value.
  21786. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  21787. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  21788. * and it is crucial that all callbacks will be executed.
  21789. * The order of the callbacks is kept, callbacks are not executed parallel.
  21790. *
  21791. * @param eventData The data to be sent to each callback
  21792. * @param mask is used to filter observers defaults to -1
  21793. * @param target defines the callback target (see EventState)
  21794. * @param currentTarget defines he current object in the bubbling phase
  21795. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  21796. */
  21797. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  21798. /**
  21799. * Notify a specific observer
  21800. * @param observer defines the observer to notify
  21801. * @param eventData defines the data to be sent to each callback
  21802. * @param mask is used to filter observers defaults to -1
  21803. */
  21804. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  21805. /**
  21806. * Gets a boolean indicating if the observable has at least one observer
  21807. * @returns true is the Observable has at least one Observer registered
  21808. */
  21809. hasObservers(): boolean;
  21810. /**
  21811. * Clear the list of observers
  21812. */
  21813. clear(): void;
  21814. /**
  21815. * Clone the current observable
  21816. * @returns a new observable
  21817. */
  21818. clone(): Observable<T>;
  21819. /**
  21820. * Does this observable handles observer registered with a given mask
  21821. * @param mask defines the mask to be tested
  21822. * @return whether or not one observer registered with the given mask is handeled
  21823. **/
  21824. hasSpecificMask(mask?: number): boolean;
  21825. }
  21826. }
  21827. declare module BABYLON {
  21828. /**
  21829. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  21830. */
  21831. class PerformanceMonitor {
  21832. private _enabled;
  21833. private _rollingFrameTime;
  21834. private _lastFrameTimeMs;
  21835. /**
  21836. * constructor
  21837. * @param frameSampleSize The number of samples required to saturate the sliding window
  21838. */
  21839. constructor(frameSampleSize?: number);
  21840. /**
  21841. * Samples current frame
  21842. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  21843. */
  21844. sampleFrame(timeMs?: number): void;
  21845. /**
  21846. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  21847. * @return Average frame time in milliseconds
  21848. */
  21849. readonly averageFrameTime: number;
  21850. /**
  21851. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  21852. * @return Frame time variance in milliseconds squared
  21853. */
  21854. readonly averageFrameTimeVariance: number;
  21855. /**
  21856. * Returns the frame time of the most recent frame
  21857. * @return Frame time in milliseconds
  21858. */
  21859. readonly instantaneousFrameTime: number;
  21860. /**
  21861. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  21862. * @return Framerate in frames per second
  21863. */
  21864. readonly averageFPS: number;
  21865. /**
  21866. * Returns the average framerate in frames per second using the most recent frame time
  21867. * @return Framerate in frames per second
  21868. */
  21869. readonly instantaneousFPS: number;
  21870. /**
  21871. * Returns true if enough samples have been taken to completely fill the sliding window
  21872. * @return true if saturated
  21873. */
  21874. readonly isSaturated: boolean;
  21875. /**
  21876. * Enables contributions to the sliding window sample set
  21877. */
  21878. enable(): void;
  21879. /**
  21880. * Disables contributions to the sliding window sample set
  21881. * Samples will not be interpolated over the disabled period
  21882. */
  21883. disable(): void;
  21884. /**
  21885. * Returns true if sampling is enabled
  21886. * @return true if enabled
  21887. */
  21888. readonly isEnabled: boolean;
  21889. /**
  21890. * Resets performance monitor
  21891. */
  21892. reset(): void;
  21893. }
  21894. /**
  21895. * RollingAverage
  21896. *
  21897. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  21898. */
  21899. class RollingAverage {
  21900. /**
  21901. * Current average
  21902. */
  21903. average: number;
  21904. /**
  21905. * Current variance
  21906. */
  21907. variance: number;
  21908. protected _samples: Array<number>;
  21909. protected _sampleCount: number;
  21910. protected _pos: number;
  21911. protected _m2: number;
  21912. /**
  21913. * constructor
  21914. * @param length The number of samples required to saturate the sliding window
  21915. */
  21916. constructor(length: number);
  21917. /**
  21918. * Adds a sample to the sample set
  21919. * @param v The sample value
  21920. */
  21921. add(v: number): void;
  21922. /**
  21923. * Returns previously added values or null if outside of history or outside the sliding window domain
  21924. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  21925. * @return Value previously recorded with add() or null if outside of range
  21926. */
  21927. history(i: number): number;
  21928. /**
  21929. * Returns true if enough samples have been taken to completely fill the sliding window
  21930. * @return true if sample-set saturated
  21931. */
  21932. isSaturated(): boolean;
  21933. /**
  21934. * Resets the rolling average (equivalent to 0 samples taken so far)
  21935. */
  21936. reset(): void;
  21937. /**
  21938. * Wraps a value around the sample range boundaries
  21939. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  21940. * @return Wrapped position in sample range
  21941. */
  21942. protected _wrapPosition(i: number): number;
  21943. }
  21944. }
  21945. declare module BABYLON {
  21946. /**
  21947. * Helper class that provides a small promise polyfill
  21948. */
  21949. class PromisePolyfill {
  21950. /**
  21951. * Static function used to check if the polyfill is required
  21952. * If this is the case then the function will inject the polyfill to window.Promise
  21953. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  21954. */
  21955. static Apply(force?: boolean): void;
  21956. }
  21957. }
  21958. declare module BABYLON {
  21959. /**
  21960. * Defines the root class used to create scene optimization to use with SceneOptimizer
  21961. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  21962. */
  21963. class SceneOptimization {
  21964. /**
  21965. * Defines the priority of this optimization (0 by default which means first in the list)
  21966. */
  21967. priority: number;
  21968. /**
  21969. * Gets a string describing the action executed by the current optimization
  21970. * @returns description string
  21971. */
  21972. getDescription(): string;
  21973. /**
  21974. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  21975. * @param scene defines the current scene where to apply this optimization
  21976. * @param optimizer defines the current optimizer
  21977. * @returns true if everything that can be done was applied
  21978. */
  21979. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  21980. /**
  21981. * Creates the SceneOptimization object
  21982. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  21983. * @param desc defines the description associated with the optimization
  21984. */
  21985. constructor(
  21986. /**
  21987. * Defines the priority of this optimization (0 by default which means first in the list)
  21988. */
  21989. priority?: number);
  21990. }
  21991. /**
  21992. * Defines an optimization used to reduce the size of render target textures
  21993. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  21994. */
  21995. class TextureOptimization extends SceneOptimization {
  21996. /**
  21997. * Defines the priority of this optimization (0 by default which means first in the list)
  21998. */
  21999. priority: number;
  22000. /**
  22001. * 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
  22002. */
  22003. maximumSize: number;
  22004. /**
  22005. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  22006. */
  22007. step: number;
  22008. /**
  22009. * Gets a string describing the action executed by the current optimization
  22010. * @returns description string
  22011. */
  22012. getDescription(): string;
  22013. /**
  22014. * Creates the TextureOptimization object
  22015. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  22016. * @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
  22017. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  22018. */
  22019. constructor(
  22020. /**
  22021. * Defines the priority of this optimization (0 by default which means first in the list)
  22022. */
  22023. priority?: number,
  22024. /**
  22025. * 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
  22026. */
  22027. maximumSize?: number,
  22028. /**
  22029. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  22030. */
  22031. step?: number);
  22032. /**
  22033. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  22034. * @param scene defines the current scene where to apply this optimization
  22035. * @param optimizer defines the current optimizer
  22036. * @returns true if everything that can be done was applied
  22037. */
  22038. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  22039. }
  22040. /**
  22041. * Defines an optimization used to increase or decrease the rendering resolution
  22042. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  22043. */
  22044. class HardwareScalingOptimization extends SceneOptimization {
  22045. /**
  22046. * Defines the priority of this optimization (0 by default which means first in the list)
  22047. */
  22048. priority: number;
  22049. /**
  22050. * Defines the maximum scale to use (2 by default)
  22051. */
  22052. maximumScale: number;
  22053. /**
  22054. * Defines the step to use between two passes (0.5 by default)
  22055. */
  22056. step: number;
  22057. private _currentScale;
  22058. private _directionOffset;
  22059. /**
  22060. * Gets a string describing the action executed by the current optimization
  22061. * @return description string
  22062. */
  22063. getDescription(): string;
  22064. /**
  22065. * Creates the HardwareScalingOptimization object
  22066. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  22067. * @param maximumScale defines the maximum scale to use (2 by default)
  22068. * @param step defines the step to use between two passes (0.5 by default)
  22069. */
  22070. constructor(
  22071. /**
  22072. * Defines the priority of this optimization (0 by default which means first in the list)
  22073. */
  22074. priority?: number,
  22075. /**
  22076. * Defines the maximum scale to use (2 by default)
  22077. */
  22078. maximumScale?: number,
  22079. /**
  22080. * Defines the step to use between two passes (0.5 by default)
  22081. */
  22082. step?: number);
  22083. /**
  22084. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  22085. * @param scene defines the current scene where to apply this optimization
  22086. * @param optimizer defines the current optimizer
  22087. * @returns true if everything that can be done was applied
  22088. */
  22089. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  22090. }
  22091. /**
  22092. * Defines an optimization used to remove shadows
  22093. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  22094. */
  22095. class ShadowsOptimization extends SceneOptimization {
  22096. /**
  22097. * Gets a string describing the action executed by the current optimization
  22098. * @return description string
  22099. */
  22100. getDescription(): string;
  22101. /**
  22102. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  22103. * @param scene defines the current scene where to apply this optimization
  22104. * @param optimizer defines the current optimizer
  22105. * @returns true if everything that can be done was applied
  22106. */
  22107. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  22108. }
  22109. /**
  22110. * Defines an optimization used to turn post-processes off
  22111. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  22112. */
  22113. class PostProcessesOptimization extends SceneOptimization {
  22114. /**
  22115. * Gets a string describing the action executed by the current optimization
  22116. * @return description string
  22117. */
  22118. getDescription(): string;
  22119. /**
  22120. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  22121. * @param scene defines the current scene where to apply this optimization
  22122. * @param optimizer defines the current optimizer
  22123. * @returns true if everything that can be done was applied
  22124. */
  22125. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  22126. }
  22127. /**
  22128. * Defines an optimization used to turn lens flares off
  22129. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  22130. */
  22131. class LensFlaresOptimization extends SceneOptimization {
  22132. /**
  22133. * Gets a string describing the action executed by the current optimization
  22134. * @return description string
  22135. */
  22136. getDescription(): string;
  22137. /**
  22138. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  22139. * @param scene defines the current scene where to apply this optimization
  22140. * @param optimizer defines the current optimizer
  22141. * @returns true if everything that can be done was applied
  22142. */
  22143. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  22144. }
  22145. /**
  22146. * Defines an optimization based on user defined callback.
  22147. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  22148. */
  22149. class CustomOptimization extends SceneOptimization {
  22150. /**
  22151. * Callback called to apply the custom optimization.
  22152. */
  22153. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  22154. /**
  22155. * Callback called to get custom description
  22156. */
  22157. onGetDescription: () => string;
  22158. /**
  22159. * Gets a string describing the action executed by the current optimization
  22160. * @returns description string
  22161. */
  22162. getDescription(): string;
  22163. /**
  22164. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  22165. * @param scene defines the current scene where to apply this optimization
  22166. * @param optimizer defines the current optimizer
  22167. * @returns true if everything that can be done was applied
  22168. */
  22169. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  22170. }
  22171. /**
  22172. * Defines an optimization used to turn particles off
  22173. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  22174. */
  22175. class ParticlesOptimization extends SceneOptimization {
  22176. /**
  22177. * Gets a string describing the action executed by the current optimization
  22178. * @return description string
  22179. */
  22180. getDescription(): string;
  22181. /**
  22182. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  22183. * @param scene defines the current scene where to apply this optimization
  22184. * @param optimizer defines the current optimizer
  22185. * @returns true if everything that can be done was applied
  22186. */
  22187. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  22188. }
  22189. /**
  22190. * Defines an optimization used to turn render targets off
  22191. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  22192. */
  22193. class RenderTargetsOptimization extends SceneOptimization {
  22194. /**
  22195. * Gets a string describing the action executed by the current optimization
  22196. * @return description string
  22197. */
  22198. getDescription(): string;
  22199. /**
  22200. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  22201. * @param scene defines the current scene where to apply this optimization
  22202. * @param optimizer defines the current optimizer
  22203. * @returns true if everything that can be done was applied
  22204. */
  22205. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  22206. }
  22207. /**
  22208. * Defines an optimization used to merge meshes with compatible materials
  22209. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  22210. */
  22211. class MergeMeshesOptimization extends SceneOptimization {
  22212. private static _UpdateSelectionTree;
  22213. /**
  22214. * Gets or sets a boolean which defines if optimization octree has to be updated
  22215. */
  22216. /**
  22217. * Gets or sets a boolean which defines if optimization octree has to be updated
  22218. */
  22219. static UpdateSelectionTree: boolean;
  22220. /**
  22221. * Gets a string describing the action executed by the current optimization
  22222. * @return description string
  22223. */
  22224. getDescription(): string;
  22225. private _canBeMerged;
  22226. /**
  22227. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  22228. * @param scene defines the current scene where to apply this optimization
  22229. * @param optimizer defines the current optimizer
  22230. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  22231. * @returns true if everything that can be done was applied
  22232. */
  22233. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  22234. }
  22235. /**
  22236. * Defines a list of options used by SceneOptimizer
  22237. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  22238. */
  22239. class SceneOptimizerOptions {
  22240. /**
  22241. * Defines the target frame rate to reach (60 by default)
  22242. */
  22243. targetFrameRate: number;
  22244. /**
  22245. * Defines the interval between two checkes (2000ms by default)
  22246. */
  22247. trackerDuration: number;
  22248. /**
  22249. * Gets the list of optimizations to apply
  22250. */
  22251. optimizations: SceneOptimization[];
  22252. /**
  22253. * Creates a new list of options used by SceneOptimizer
  22254. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  22255. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  22256. */
  22257. constructor(
  22258. /**
  22259. * Defines the target frame rate to reach (60 by default)
  22260. */
  22261. targetFrameRate?: number,
  22262. /**
  22263. * Defines the interval between two checkes (2000ms by default)
  22264. */
  22265. trackerDuration?: number);
  22266. /**
  22267. * Add a new optimization
  22268. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  22269. * @returns the current SceneOptimizerOptions
  22270. */
  22271. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  22272. /**
  22273. * Add a new custom optimization
  22274. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  22275. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  22276. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  22277. * @returns the current SceneOptimizerOptions
  22278. */
  22279. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  22280. /**
  22281. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  22282. * @param targetFrameRate defines the target frame rate (60 by default)
  22283. * @returns a SceneOptimizerOptions object
  22284. */
  22285. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  22286. /**
  22287. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  22288. * @param targetFrameRate defines the target frame rate (60 by default)
  22289. * @returns a SceneOptimizerOptions object
  22290. */
  22291. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  22292. /**
  22293. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  22294. * @param targetFrameRate defines the target frame rate (60 by default)
  22295. * @returns a SceneOptimizerOptions object
  22296. */
  22297. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  22298. }
  22299. /**
  22300. * Class used to run optimizations in order to reach a target frame rate
  22301. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  22302. */
  22303. class SceneOptimizer implements IDisposable {
  22304. private _isRunning;
  22305. private _options;
  22306. private _scene;
  22307. private _currentPriorityLevel;
  22308. private _targetFrameRate;
  22309. private _trackerDuration;
  22310. private _currentFrameRate;
  22311. private _sceneDisposeObserver;
  22312. private _improvementMode;
  22313. /**
  22314. * Defines an observable called when the optimizer reaches the target frame rate
  22315. */
  22316. onSuccessObservable: Observable<SceneOptimizer>;
  22317. /**
  22318. * Defines an observable called when the optimizer enables an optimization
  22319. */
  22320. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  22321. /**
  22322. * Defines an observable called when the optimizer is not able to reach the target frame rate
  22323. */
  22324. onFailureObservable: Observable<SceneOptimizer>;
  22325. /**
  22326. * Gets a boolean indicating if the optimizer is in improvement mode
  22327. */
  22328. readonly isInImprovementMode: boolean;
  22329. /**
  22330. * Gets the current priority level (0 at start)
  22331. */
  22332. readonly currentPriorityLevel: number;
  22333. /**
  22334. * Gets the current frame rate checked by the SceneOptimizer
  22335. */
  22336. readonly currentFrameRate: number;
  22337. /**
  22338. * Gets or sets the current target frame rate (60 by default)
  22339. */
  22340. /**
  22341. * Gets or sets the current target frame rate (60 by default)
  22342. */
  22343. targetFrameRate: number;
  22344. /**
  22345. * Gets or sets the current interval between two checks (every 2000ms by default)
  22346. */
  22347. /**
  22348. * Gets or sets the current interval between two checks (every 2000ms by default)
  22349. */
  22350. trackerDuration: number;
  22351. /**
  22352. * Gets the list of active optimizations
  22353. */
  22354. readonly optimizations: SceneOptimization[];
  22355. /**
  22356. * Creates a new SceneOptimizer
  22357. * @param scene defines the scene to work on
  22358. * @param options defines the options to use with the SceneOptimizer
  22359. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  22360. * @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)
  22361. */
  22362. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  22363. /**
  22364. * Stops the current optimizer
  22365. */
  22366. stop(): void;
  22367. /**
  22368. * Reset the optimizer to initial step (current priority level = 0)
  22369. */
  22370. reset(): void;
  22371. /**
  22372. * Start the optimizer. By default it will try to reach a specific framerate
  22373. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  22374. */
  22375. start(): void;
  22376. private _checkCurrentState();
  22377. /**
  22378. * Release all resources
  22379. */
  22380. dispose(): void;
  22381. /**
  22382. * Helper function to create a SceneOptimizer with one single line of code
  22383. * @param scene defines the scene to work on
  22384. * @param options defines the options to use with the SceneOptimizer
  22385. * @param onSuccess defines a callback to call on success
  22386. * @param onFailure defines a callback to call on failure
  22387. * @returns the new SceneOptimizer object
  22388. */
  22389. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  22390. }
  22391. }
  22392. declare module BABYLON {
  22393. class SceneSerializer {
  22394. static ClearCache(): void;
  22395. static Serialize(scene: Scene): any;
  22396. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  22397. }
  22398. }
  22399. declare module BABYLON {
  22400. class SmartArray<T> {
  22401. data: Array<T>;
  22402. length: number;
  22403. protected _id: number;
  22404. [index: number]: T;
  22405. constructor(capacity: number);
  22406. push(value: T): void;
  22407. forEach(func: (content: T) => void): void;
  22408. sort(compareFn: (a: T, b: T) => number): void;
  22409. reset(): void;
  22410. dispose(): void;
  22411. concat(array: any): void;
  22412. indexOf(value: T): number;
  22413. contains(value: T): boolean;
  22414. private static _GlobalId;
  22415. }
  22416. class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  22417. private _duplicateId;
  22418. [index: number]: T;
  22419. push(value: T): void;
  22420. pushNoDuplicate(value: T): boolean;
  22421. reset(): void;
  22422. concatWithNoDuplicate(array: any): void;
  22423. }
  22424. }
  22425. declare module BABYLON {
  22426. /**
  22427. * This class implement a typical dictionary using a string as key and the generic type T as value.
  22428. * The underlying implementation relies on an associative array to ensure the best performances.
  22429. * The value can be anything including 'null' but except 'undefined'
  22430. */
  22431. class StringDictionary<T> {
  22432. /**
  22433. * This will clear this dictionary and copy the content from the 'source' one.
  22434. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  22435. * @param source the dictionary to take the content from and copy to this dictionary
  22436. */
  22437. copyFrom(source: StringDictionary<T>): void;
  22438. /**
  22439. * Get a value based from its key
  22440. * @param key the given key to get the matching value from
  22441. * @return the value if found, otherwise undefined is returned
  22442. */
  22443. get(key: string): T | undefined;
  22444. /**
  22445. * Get a value from its key or add it if it doesn't exist.
  22446. * This method will ensure you that a given key/data will be present in the dictionary.
  22447. * @param key the given key to get the matching value from
  22448. * @param factory the factory that will create the value if the key is not present in the dictionary.
  22449. * The factory will only be invoked if there's no data for the given key.
  22450. * @return the value corresponding to the key.
  22451. */
  22452. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  22453. /**
  22454. * Get a value from its key if present in the dictionary otherwise add it
  22455. * @param key the key to get the value from
  22456. * @param val if there's no such key/value pair in the dictionary add it with this value
  22457. * @return the value corresponding to the key
  22458. */
  22459. getOrAdd(key: string, val: T): T;
  22460. /**
  22461. * Check if there's a given key in the dictionary
  22462. * @param key the key to check for
  22463. * @return true if the key is present, false otherwise
  22464. */
  22465. contains(key: string): boolean;
  22466. /**
  22467. * Add a new key and its corresponding value
  22468. * @param key the key to add
  22469. * @param value the value corresponding to the key
  22470. * @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
  22471. */
  22472. add(key: string, value: T): boolean;
  22473. set(key: string, value: T): boolean;
  22474. /**
  22475. * Get the element of the given key and remove it from the dictionary
  22476. * @param key
  22477. */
  22478. getAndRemove(key: string): Nullable<T>;
  22479. /**
  22480. * Remove a key/value from the dictionary.
  22481. * @param key the key to remove
  22482. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  22483. */
  22484. remove(key: string): boolean;
  22485. /**
  22486. * Clear the whole content of the dictionary
  22487. */
  22488. clear(): void;
  22489. readonly count: number;
  22490. /**
  22491. * Execute a callback on each key/val of the dictionary.
  22492. * Note that you can remove any element in this dictionary in the callback implementation
  22493. * @param callback the callback to execute on a given key/value pair
  22494. */
  22495. forEach(callback: (key: string, val: T) => void): void;
  22496. /**
  22497. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  22498. * If the callback returns null or undefined the method will iterate to the next key/value pair
  22499. * Note that you can remove any element in this dictionary in the callback implementation
  22500. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  22501. */
  22502. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  22503. private _count;
  22504. private _data;
  22505. }
  22506. }
  22507. declare module BABYLON {
  22508. class Tags {
  22509. static EnableFor(obj: any): void;
  22510. static DisableFor(obj: any): void;
  22511. static HasTags(obj: any): boolean;
  22512. static GetTags(obj: any, asString?: boolean): any;
  22513. static AddTagsTo(obj: any, tagsString: string): void;
  22514. static _AddTagTo(obj: any, tag: string): void;
  22515. static RemoveTagsFrom(obj: any, tagsString: string): void;
  22516. static _RemoveTagFrom(obj: any, tag: string): void;
  22517. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  22518. }
  22519. }
  22520. declare module BABYLON {
  22521. class TextureTools {
  22522. /**
  22523. * Uses the GPU to create a copy texture rescaled at a given size
  22524. * @param texture Texture to copy from
  22525. * @param width Desired width
  22526. * @param height Desired height
  22527. * @return Generated texture
  22528. */
  22529. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  22530. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  22531. private static _environmentBRDFBase64Texture;
  22532. }
  22533. }
  22534. declare module BABYLON {
  22535. class TGATools {
  22536. private static _TYPE_INDEXED;
  22537. private static _TYPE_RGB;
  22538. private static _TYPE_GREY;
  22539. private static _TYPE_RLE_INDEXED;
  22540. private static _TYPE_RLE_RGB;
  22541. private static _TYPE_RLE_GREY;
  22542. private static _ORIGIN_MASK;
  22543. private static _ORIGIN_SHIFT;
  22544. private static _ORIGIN_BL;
  22545. private static _ORIGIN_BR;
  22546. private static _ORIGIN_UL;
  22547. private static _ORIGIN_UR;
  22548. static GetTGAHeader(data: Uint8Array): any;
  22549. static UploadContent(gl: WebGLRenderingContext, data: Uint8Array): void;
  22550. 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;
  22551. 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;
  22552. 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;
  22553. 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;
  22554. 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;
  22555. 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;
  22556. }
  22557. }
  22558. declare module BABYLON {
  22559. interface IAnimatable {
  22560. animations: Array<Animation>;
  22561. }
  22562. class LoadFileError extends Error {
  22563. request: XMLHttpRequest | undefined;
  22564. private static _setPrototypeOf;
  22565. constructor(message: string, request?: XMLHttpRequest | undefined);
  22566. }
  22567. class RetryStrategy {
  22568. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: XMLHttpRequest, retryIndex: number) => number;
  22569. }
  22570. interface IFileRequest {
  22571. /**
  22572. * Raised when the request is complete (success or error).
  22573. */
  22574. onCompleteObservable: Observable<IFileRequest>;
  22575. /**
  22576. * Aborts the request for a file.
  22577. */
  22578. abort: () => void;
  22579. }
  22580. class Tools {
  22581. static BaseUrl: string;
  22582. static DefaultRetryStrategy: (url: string, request: XMLHttpRequest, retryIndex: number) => number;
  22583. /**
  22584. * Default behaviour for cors in the application.
  22585. * It can be a string if the expected behavior is identical in the entire app.
  22586. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  22587. */
  22588. static CorsBehavior: string | ((url: string | string[]) => string);
  22589. static UseFallbackTexture: boolean;
  22590. /**
  22591. * Use this object to register external classes like custom textures or material
  22592. * to allow the laoders to instantiate them
  22593. */
  22594. static RegisteredExternalClasses: {
  22595. [key: string]: Object;
  22596. };
  22597. static fallbackTexture: string;
  22598. /**
  22599. * Interpolates between a and b via alpha
  22600. * @param a The lower value (returned when alpha = 0)
  22601. * @param b The upper value (returned when alpha = 1)
  22602. * @param alpha The interpolation-factor
  22603. * @return The mixed value
  22604. */
  22605. static Mix(a: number, b: number, alpha: number): number;
  22606. static Instantiate(className: string): any;
  22607. /**
  22608. * Provides a slice function that will work even on IE
  22609. * @param data defines the array to slice
  22610. * @returns the new sliced array
  22611. */
  22612. static Slice(data: FloatArray): FloatArray;
  22613. static SetImmediate(action: () => void): void;
  22614. static IsExponentOfTwo(value: number): boolean;
  22615. /**
  22616. * Find the next highest power of two.
  22617. * @param x Number to start search from.
  22618. * @return Next highest power of two.
  22619. */
  22620. static CeilingPOT(x: number): number;
  22621. /**
  22622. * Find the next lowest power of two.
  22623. * @param x Number to start search from.
  22624. * @return Next lowest power of two.
  22625. */
  22626. static FloorPOT(x: number): number;
  22627. /**
  22628. * Find the nearest power of two.
  22629. * @param x Number to start search from.
  22630. * @return Next nearest power of two.
  22631. */
  22632. static NearestPOT(x: number): number;
  22633. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  22634. static GetFilename(path: string): string;
  22635. /**
  22636. * Extracts the "folder" part of a path (everything before the filename).
  22637. * @param uri The URI to extract the info from
  22638. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  22639. * @returns The "folder" part of the path
  22640. */
  22641. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  22642. static GetDOMTextContent(element: HTMLElement): string;
  22643. static ToDegrees(angle: number): number;
  22644. static ToRadians(angle: number): number;
  22645. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  22646. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  22647. minimum: Vector3;
  22648. maximum: Vector3;
  22649. };
  22650. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  22651. minimum: Vector3;
  22652. maximum: Vector3;
  22653. };
  22654. static Vector2ArrayFeeder(array: Array<Vector2> | Float32Array): (i: number) => Nullable<Vector2>;
  22655. static ExtractMinAndMaxVector2(feeder: (index: number) => Vector2, bias?: Nullable<Vector2>): {
  22656. minimum: Vector2;
  22657. maximum: Vector2;
  22658. };
  22659. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  22660. static GetPointerPrefix(): string;
  22661. /**
  22662. * @param func - the function to be called
  22663. * @param requester - the object that will request the next frame. Falls back to window.
  22664. */
  22665. static QueueNewFrame(func: () => void, requester?: any): number;
  22666. static RequestFullscreen(element: HTMLElement): void;
  22667. static ExitFullscreen(): void;
  22668. static SetCorsBehavior(url: string | string[], element: {
  22669. crossOrigin: string | null;
  22670. }): void;
  22671. static CleanUrl(url: string): string;
  22672. static PreprocessUrl: (url: string) => string;
  22673. static LoadImage(url: any, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, database: Nullable<Database>): HTMLImageElement;
  22674. 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;
  22675. /**
  22676. * Load a script (identified by an url). When the url returns, the
  22677. * content of this file is added into a new script element, attached to the DOM (body element)
  22678. */
  22679. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void): void;
  22680. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (this: MSBaseReader, ev: ProgressEvent) => any): IFileRequest;
  22681. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (this: MSBaseReader, ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  22682. static FileAsURL(content: string): string;
  22683. static Format(value: number, decimals?: number): string;
  22684. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  22685. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  22686. static IsEmpty(obj: any): boolean;
  22687. static RegisterTopRootEvents(events: {
  22688. name: string;
  22689. handler: Nullable<(e: FocusEvent) => any>;
  22690. }[]): void;
  22691. static UnregisterTopRootEvents(events: {
  22692. name: string;
  22693. handler: Nullable<(e: FocusEvent) => any>;
  22694. }[]): void;
  22695. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  22696. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  22697. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  22698. /**
  22699. * Generates an image screenshot from the specified camera.
  22700. *
  22701. * @param engine The engine to use for rendering
  22702. * @param camera The camera to use for rendering
  22703. * @param size This parameter can be set to a single number or to an object with the
  22704. * following (optional) properties: precision, width, height. If a single number is passed,
  22705. * it will be used for both width and height. If an object is passed, the screenshot size
  22706. * will be derived from the parameters. The precision property is a multiplier allowing
  22707. * rendering at a higher or lower resolution.
  22708. * @param successCallback The callback receives a single parameter which contains the
  22709. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  22710. * src parameter of an <img> to display it.
  22711. * @param mimeType The MIME type of the screenshot image (default: image/png).
  22712. * Check your browser for supported MIME types.
  22713. * @param samples Texture samples (default: 1)
  22714. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  22715. * @param fileName A name for for the downloaded file.
  22716. * @constructor
  22717. */
  22718. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  22719. static ValidateXHRData(xhr: XMLHttpRequest, dataType?: number): boolean;
  22720. /**
  22721. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  22722. * Be aware Math.random() could cause collisions, but:
  22723. * "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"
  22724. */
  22725. static RandomId(): string;
  22726. /**
  22727. * Test if the given uri is a base64 string.
  22728. * @param uri The uri to test
  22729. * @return True if the uri is a base64 string or false otherwise.
  22730. */
  22731. static IsBase64(uri: string): boolean;
  22732. /**
  22733. * Decode the given base64 uri.
  22734. * @param uri The uri to decode
  22735. * @return The decoded base64 data.
  22736. */
  22737. static DecodeBase64(uri: string): ArrayBuffer;
  22738. private static _NoneLogLevel;
  22739. private static _MessageLogLevel;
  22740. private static _WarningLogLevel;
  22741. private static _ErrorLogLevel;
  22742. private static _LogCache;
  22743. static errorsCount: number;
  22744. static OnNewCacheEntry: (entry: string) => void;
  22745. static readonly NoneLogLevel: number;
  22746. static readonly MessageLogLevel: number;
  22747. static readonly WarningLogLevel: number;
  22748. static readonly ErrorLogLevel: number;
  22749. static readonly AllLogLevel: number;
  22750. private static _AddLogEntry(entry);
  22751. private static _FormatMessage(message);
  22752. private static _LogDisabled(message);
  22753. private static _LogEnabled(message);
  22754. private static _WarnDisabled(message);
  22755. private static _WarnEnabled(message);
  22756. private static _ErrorDisabled(message);
  22757. private static _ErrorEnabled(message);
  22758. static Log: (message: string) => void;
  22759. static Warn: (message: string) => void;
  22760. static Error: (message: string) => void;
  22761. static readonly LogCache: string;
  22762. static ClearLogCache(): void;
  22763. static LogLevels: number;
  22764. static IsWindowObjectExist(): boolean;
  22765. private static _PerformanceNoneLogLevel;
  22766. private static _PerformanceUserMarkLogLevel;
  22767. private static _PerformanceConsoleLogLevel;
  22768. private static _performance;
  22769. static readonly PerformanceNoneLogLevel: number;
  22770. static readonly PerformanceUserMarkLogLevel: number;
  22771. static readonly PerformanceConsoleLogLevel: number;
  22772. static PerformanceLogLevel: number;
  22773. static _StartPerformanceCounterDisabled(counterName: string, condition?: boolean): void;
  22774. static _EndPerformanceCounterDisabled(counterName: string, condition?: boolean): void;
  22775. static _StartUserMark(counterName: string, condition?: boolean): void;
  22776. static _EndUserMark(counterName: string, condition?: boolean): void;
  22777. static _StartPerformanceConsole(counterName: string, condition?: boolean): void;
  22778. static _EndPerformanceConsole(counterName: string, condition?: boolean): void;
  22779. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  22780. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  22781. static readonly Now: number;
  22782. /**
  22783. * This method will return the name of the class used to create the instance of the given object.
  22784. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  22785. * @param object the object to get the class name from
  22786. * @return the name of the class, will be "object" for a custom data type not using the @className decorator
  22787. */
  22788. static GetClassName(object: any, isType?: boolean): string;
  22789. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  22790. /**
  22791. * This method will return the name of the full name of the class, including its owning module (if any).
  22792. * 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).
  22793. * @param object the object to get the class name from
  22794. * @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.
  22795. */
  22796. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  22797. /**
  22798. * 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.
  22799. * @param array
  22800. */
  22801. static arrayOrStringFeeder(array: any): (i: number) => number;
  22802. /**
  22803. * Compute the hashCode of a stream of number
  22804. * To compute the HashCode on a string or an Array of data types implementing the getHashCode() method, use the arrayOrStringFeeder method.
  22805. * @param feeder a callback that will be called until it returns null, each valid returned values will be used to compute the hash code.
  22806. * @return the hash code computed
  22807. */
  22808. static hashCodeFromStream(feeder: (index: number) => number): number;
  22809. /**
  22810. * Returns a promise that resolves after the given amount of time.
  22811. * @param delay Number of milliseconds to delay
  22812. * @returns Promise that resolves after the given amount of time
  22813. */
  22814. static DelayAsync(delay: number): Promise<void>;
  22815. }
  22816. /**
  22817. * This class is used to track a performance counter which is number based.
  22818. * The user has access to many properties which give statistics of different nature
  22819. *
  22820. * The implementer can track two kinds of Performance Counter: time and count
  22821. * 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.
  22822. * 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.
  22823. */
  22824. class PerfCounter {
  22825. static Enabled: boolean;
  22826. /**
  22827. * Returns the smallest value ever
  22828. */
  22829. readonly min: number;
  22830. /**
  22831. * Returns the biggest value ever
  22832. */
  22833. readonly max: number;
  22834. /**
  22835. * Returns the average value since the performance counter is running
  22836. */
  22837. readonly average: number;
  22838. /**
  22839. * Returns the average value of the last second the counter was monitored
  22840. */
  22841. readonly lastSecAverage: number;
  22842. /**
  22843. * Returns the current value
  22844. */
  22845. readonly current: number;
  22846. readonly total: number;
  22847. readonly count: number;
  22848. constructor();
  22849. /**
  22850. * Call this method to start monitoring a new frame.
  22851. * 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.
  22852. */
  22853. fetchNewFrame(): void;
  22854. /**
  22855. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  22856. * @param newCount the count value to add to the monitored count
  22857. * @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.
  22858. */
  22859. addCount(newCount: number, fetchResult: boolean): void;
  22860. /**
  22861. * Start monitoring this performance counter
  22862. */
  22863. beginMonitoring(): void;
  22864. /**
  22865. * Compute the time lapsed since the previous beginMonitoring() call.
  22866. * @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
  22867. */
  22868. endMonitoring(newFrame?: boolean): void;
  22869. private _fetchResult();
  22870. private _startMonitoringTime;
  22871. private _min;
  22872. private _max;
  22873. private _average;
  22874. private _current;
  22875. private _totalValueCount;
  22876. private _totalAccumulated;
  22877. private _lastSecAverage;
  22878. private _lastSecAccumulated;
  22879. private _lastSecTime;
  22880. private _lastSecValueCount;
  22881. }
  22882. /**
  22883. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  22884. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  22885. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  22886. * @param name The name of the class, case should be preserved
  22887. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  22888. */
  22889. function className(name: string, module?: string): (target: Object) => void;
  22890. /**
  22891. * An implementation of a loop for asynchronous functions.
  22892. */
  22893. class AsyncLoop {
  22894. iterations: number;
  22895. private _fn;
  22896. private _successCallback;
  22897. index: number;
  22898. private _done;
  22899. /**
  22900. * Constroctor.
  22901. * @param iterations the number of iterations.
  22902. * @param _fn the function to run each iteration
  22903. * @param _successCallback the callback that will be called upon succesful execution
  22904. * @param offset starting offset.
  22905. */
  22906. constructor(iterations: number, _fn: (asyncLoop: AsyncLoop) => void, _successCallback: () => void, offset?: number);
  22907. /**
  22908. * Execute the next iteration. Must be called after the last iteration was finished.
  22909. */
  22910. executeNext(): void;
  22911. /**
  22912. * Break the loop and run the success callback.
  22913. */
  22914. breakLoop(): void;
  22915. /**
  22916. * Helper function
  22917. */
  22918. static Run(iterations: number, _fn: (asyncLoop: AsyncLoop) => void, _successCallback: () => void, offset?: number): AsyncLoop;
  22919. /**
  22920. * A for-loop that will run a given number of iterations synchronous and the rest async.
  22921. * @param iterations total number of iterations
  22922. * @param syncedIterations number of synchronous iterations in each async iteration.
  22923. * @param fn the function to call each iteration.
  22924. * @param callback a success call back that will be called when iterating stops.
  22925. * @param breakFunction a break condition (optional)
  22926. * @param timeout timeout settings for the setTimeout function. default - 0.
  22927. * @constructor
  22928. */
  22929. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): void;
  22930. }
  22931. }
  22932. declare module BABYLON {
  22933. enum JoystickAxis {
  22934. X = 0,
  22935. Y = 1,
  22936. Z = 2,
  22937. }
  22938. class VirtualJoystick {
  22939. reverseLeftRight: boolean;
  22940. reverseUpDown: boolean;
  22941. deltaPosition: Vector3;
  22942. pressed: boolean;
  22943. private static _globalJoystickIndex;
  22944. private static vjCanvas;
  22945. private static vjCanvasContext;
  22946. private static vjCanvasWidth;
  22947. private static vjCanvasHeight;
  22948. private static halfWidth;
  22949. private _action;
  22950. private _axisTargetedByLeftAndRight;
  22951. private _axisTargetedByUpAndDown;
  22952. private _joystickSensibility;
  22953. private _inversedSensibility;
  22954. private _joystickPointerID;
  22955. private _joystickColor;
  22956. private _joystickPointerPos;
  22957. private _joystickPreviousPointerPos;
  22958. private _joystickPointerStartPos;
  22959. private _deltaJoystickVector;
  22960. private _leftJoystick;
  22961. private _touches;
  22962. private _onPointerDownHandlerRef;
  22963. private _onPointerMoveHandlerRef;
  22964. private _onPointerUpHandlerRef;
  22965. private _onResize;
  22966. constructor(leftJoystick?: boolean);
  22967. setJoystickSensibility(newJoystickSensibility: number): void;
  22968. private _onPointerDown(e);
  22969. private _onPointerMove(e);
  22970. private _onPointerUp(e);
  22971. /**
  22972. * Change the color of the virtual joystick
  22973. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  22974. */
  22975. setJoystickColor(newColor: string): void;
  22976. setActionOnTouch(action: () => any): void;
  22977. setAxisForLeftRight(axis: JoystickAxis): void;
  22978. setAxisForUpDown(axis: JoystickAxis): void;
  22979. private _drawVirtualJoystick();
  22980. releaseCanvas(): void;
  22981. }
  22982. }
  22983. declare module BABYLON {
  22984. /**
  22985. * Helper class to push actions to a pool of workers.
  22986. */
  22987. class WorkerPool implements IDisposable {
  22988. private _workerInfos;
  22989. private _pendingActions;
  22990. /**
  22991. * Constructor
  22992. * @param workers Array of workers to use for actions
  22993. */
  22994. constructor(workers: Array<Worker>);
  22995. /**
  22996. * Terminates all workers and clears any pending actions.
  22997. */
  22998. dispose(): void;
  22999. /**
  23000. * Pushes an action to the worker pool. If all the workers are active, the action will be
  23001. * pended until a worker has completed its action.
  23002. * @param action The action to perform. Call onComplete when the action is complete.
  23003. */
  23004. push(action: (worker: Worker, onComplete: () => void) => void): void;
  23005. private _execute(workerInfo, action);
  23006. }
  23007. }
  23008. declare module BABYLON {
  23009. class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  23010. readonly name: string;
  23011. private _zoomStopsAnimation;
  23012. private _idleRotationSpeed;
  23013. private _idleRotationWaitTime;
  23014. private _idleRotationSpinupTime;
  23015. /**
  23016. * Gets the flag that indicates if user zooming should stop animation.
  23017. */
  23018. /**
  23019. * Sets the flag that indicates if user zooming should stop animation.
  23020. */
  23021. zoomStopsAnimation: boolean;
  23022. /**
  23023. * Gets the default speed at which the camera rotates around the model.
  23024. */
  23025. /**
  23026. * Sets the default speed at which the camera rotates around the model.
  23027. */
  23028. idleRotationSpeed: number;
  23029. /**
  23030. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  23031. */
  23032. /**
  23033. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  23034. */
  23035. idleRotationWaitTime: number;
  23036. /**
  23037. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  23038. */
  23039. /**
  23040. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  23041. */
  23042. idleRotationSpinupTime: number;
  23043. /**
  23044. * Gets a value indicating if the camera is currently rotating because of this behavior
  23045. */
  23046. readonly rotationInProgress: boolean;
  23047. private _onPrePointerObservableObserver;
  23048. private _onAfterCheckInputsObserver;
  23049. private _attachedCamera;
  23050. private _isPointerDown;
  23051. private _lastFrameTime;
  23052. private _lastInteractionTime;
  23053. private _cameraRotationSpeed;
  23054. init(): void;
  23055. attach(camera: ArcRotateCamera): void;
  23056. detach(): void;
  23057. /**
  23058. * Returns true if user is scrolling.
  23059. * @return true if user is scrolling.
  23060. */
  23061. private _userIsZooming();
  23062. private _lastFrameRadius;
  23063. private _shouldAnimationStopForInteraction();
  23064. /**
  23065. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  23066. */
  23067. private _applyUserInteraction();
  23068. private _userIsMoving();
  23069. }
  23070. }
  23071. declare module BABYLON {
  23072. /**
  23073. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  23074. */
  23075. class BouncingBehavior implements Behavior<ArcRotateCamera> {
  23076. readonly name: string;
  23077. /**
  23078. * The easing function used by animations
  23079. */
  23080. static EasingFunction: BackEase;
  23081. /**
  23082. * The easing mode used by animations
  23083. */
  23084. static EasingMode: number;
  23085. /**
  23086. * The duration of the animation, in milliseconds
  23087. */
  23088. transitionDuration: number;
  23089. /**
  23090. * Length of the distance animated by the transition when lower radius is reached
  23091. */
  23092. lowerRadiusTransitionRange: number;
  23093. /**
  23094. * Length of the distance animated by the transition when upper radius is reached
  23095. */
  23096. upperRadiusTransitionRange: number;
  23097. private _autoTransitionRange;
  23098. /**
  23099. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  23100. */
  23101. /**
  23102. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  23103. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  23104. */
  23105. autoTransitionRange: boolean;
  23106. private _attachedCamera;
  23107. private _onAfterCheckInputsObserver;
  23108. private _onMeshTargetChangedObserver;
  23109. init(): void;
  23110. attach(camera: ArcRotateCamera): void;
  23111. detach(): void;
  23112. private _radiusIsAnimating;
  23113. private _radiusBounceTransition;
  23114. private _animatables;
  23115. private _cachedWheelPrecision;
  23116. /**
  23117. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  23118. * @param radiusLimit The limit to check against.
  23119. * @return Bool to indicate if at limit.
  23120. */
  23121. private _isRadiusAtLimit(radiusLimit);
  23122. /**
  23123. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  23124. * @param radiusDelta The delta by which to animate to. Can be negative.
  23125. */
  23126. private _applyBoundRadiusAnimation(radiusDelta);
  23127. /**
  23128. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  23129. */
  23130. protected _clearAnimationLocks(): void;
  23131. /**
  23132. * Stops and removes all animations that have been applied to the camera
  23133. */
  23134. stopAllAnimations(): void;
  23135. }
  23136. }
  23137. declare module BABYLON {
  23138. class FramingBehavior implements Behavior<ArcRotateCamera> {
  23139. readonly name: string;
  23140. private _mode;
  23141. private _radiusScale;
  23142. private _positionScale;
  23143. private _defaultElevation;
  23144. private _elevationReturnTime;
  23145. private _elevationReturnWaitTime;
  23146. private _zoomStopsAnimation;
  23147. private _framingTime;
  23148. /**
  23149. * The easing function used by animations
  23150. */
  23151. static EasingFunction: ExponentialEase;
  23152. /**
  23153. * The easing mode used by animations
  23154. */
  23155. static EasingMode: number;
  23156. /**
  23157. * Gets current mode used by the behavior.
  23158. */
  23159. /**
  23160. * Sets the current mode used by the behavior
  23161. */
  23162. mode: number;
  23163. /**
  23164. * Gets the scale applied to the radius
  23165. */
  23166. /**
  23167. * Sets the scale applied to the radius (1 by default)
  23168. */
  23169. radiusScale: number;
  23170. /**
  23171. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  23172. */
  23173. /**
  23174. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  23175. */
  23176. positionScale: number;
  23177. /**
  23178. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  23179. * behaviour is triggered, in radians.
  23180. */
  23181. /**
  23182. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  23183. * behaviour is triggered, in radians.
  23184. */
  23185. defaultElevation: number;
  23186. /**
  23187. * Gets the time (in milliseconds) taken to return to the default beta position.
  23188. * Negative value indicates camera should not return to default.
  23189. */
  23190. /**
  23191. * Sets the time (in milliseconds) taken to return to the default beta position.
  23192. * Negative value indicates camera should not return to default.
  23193. */
  23194. elevationReturnTime: number;
  23195. /**
  23196. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  23197. */
  23198. /**
  23199. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  23200. */
  23201. elevationReturnWaitTime: number;
  23202. /**
  23203. * Gets the flag that indicates if user zooming should stop animation.
  23204. */
  23205. /**
  23206. * Sets the flag that indicates if user zooming should stop animation.
  23207. */
  23208. zoomStopsAnimation: boolean;
  23209. /**
  23210. * Gets the transition time when framing the mesh, in milliseconds
  23211. */
  23212. /**
  23213. * Sets the transition time when framing the mesh, in milliseconds
  23214. */
  23215. framingTime: number;
  23216. private _onPrePointerObservableObserver;
  23217. private _onAfterCheckInputsObserver;
  23218. private _onMeshTargetChangedObserver;
  23219. private _attachedCamera;
  23220. private _isPointerDown;
  23221. private _lastInteractionTime;
  23222. init(): void;
  23223. attach(camera: ArcRotateCamera): void;
  23224. detach(): void;
  23225. private _animatables;
  23226. private _betaIsAnimating;
  23227. private _betaTransition;
  23228. private _radiusTransition;
  23229. private _vectorTransition;
  23230. /**
  23231. * Targets the given mesh and updates zoom level accordingly.
  23232. * @param mesh The mesh to target.
  23233. * @param radius Optional. If a cached radius position already exists, overrides default.
  23234. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  23235. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  23236. * @param onAnimationEnd Callback triggered at the end of the framing animation
  23237. */
  23238. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  23239. /**
  23240. * Targets the given mesh with its children and updates zoom level accordingly.
  23241. * @param mesh The mesh to target.
  23242. * @param radius Optional. If a cached radius position already exists, overrides default.
  23243. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  23244. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  23245. * @param onAnimationEnd Callback triggered at the end of the framing animation
  23246. */
  23247. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  23248. /**
  23249. * Targets the given meshes with their children and updates zoom level accordingly.
  23250. * @param meshes The mesh to target.
  23251. * @param radius Optional. If a cached radius position already exists, overrides default.
  23252. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  23253. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  23254. * @param onAnimationEnd Callback triggered at the end of the framing animation
  23255. */
  23256. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  23257. /**
  23258. * Targets the given mesh and updates zoom level accordingly.
  23259. * @param mesh The mesh to target.
  23260. * @param radius Optional. If a cached radius position already exists, overrides default.
  23261. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  23262. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  23263. * @param onAnimationEnd Callback triggered at the end of the framing animation
  23264. */
  23265. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  23266. /**
  23267. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  23268. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  23269. * frustum width.
  23270. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  23271. * to fully enclose the mesh in the viewing frustum.
  23272. */
  23273. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  23274. /**
  23275. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  23276. * is automatically returned to its default position (expected to be above ground plane).
  23277. */
  23278. private _maintainCameraAboveGround();
  23279. /**
  23280. * Returns the frustum slope based on the canvas ratio and camera FOV
  23281. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  23282. */
  23283. private _getFrustumSlope();
  23284. /**
  23285. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  23286. */
  23287. private _clearAnimationLocks();
  23288. /**
  23289. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  23290. */
  23291. private _applyUserInteraction();
  23292. /**
  23293. * Stops and removes all animations that have been applied to the camera
  23294. */
  23295. stopAllAnimations(): void;
  23296. /**
  23297. * Gets a value indicating if the user is moving the camera
  23298. */
  23299. readonly isUserIsMoving: boolean;
  23300. /**
  23301. * The camera can move all the way towards the mesh.
  23302. */
  23303. static IgnoreBoundsSizeMode: number;
  23304. /**
  23305. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  23306. */
  23307. static FitFrustumSidesMode: number;
  23308. }
  23309. }
  23310. declare module BABYLON {
  23311. class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  23312. camera: ArcRotateCamera;
  23313. gamepad: Nullable<Gamepad>;
  23314. private _onGamepadConnectedObserver;
  23315. private _onGamepadDisconnectedObserver;
  23316. gamepadRotationSensibility: number;
  23317. gamepadMoveSensibility: number;
  23318. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  23319. detachControl(element: Nullable<HTMLElement>): void;
  23320. checkInputs(): void;
  23321. getClassName(): string;
  23322. getSimpleName(): string;
  23323. }
  23324. }
  23325. declare module BABYLON {
  23326. class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  23327. camera: ArcRotateCamera;
  23328. private _keys;
  23329. keysUp: number[];
  23330. keysDown: number[];
  23331. keysLeft: number[];
  23332. keysRight: number[];
  23333. keysReset: number[];
  23334. panningSensibility: number;
  23335. zoomingSensibility: number;
  23336. useAltToZoom: boolean;
  23337. private _ctrlPressed;
  23338. private _altPressed;
  23339. private _onCanvasBlurObserver;
  23340. private _onKeyboardObserver;
  23341. private _engine;
  23342. private _scene;
  23343. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  23344. detachControl(element: Nullable<HTMLElement>): void;
  23345. checkInputs(): void;
  23346. getClassName(): string;
  23347. getSimpleName(): string;
  23348. }
  23349. }
  23350. declare module BABYLON {
  23351. class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  23352. camera: ArcRotateCamera;
  23353. private _wheel;
  23354. private _observer;
  23355. wheelPrecision: number;
  23356. /**
  23357. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  23358. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  23359. */
  23360. wheelDeltaPercentage: number;
  23361. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  23362. detachControl(element: Nullable<HTMLElement>): void;
  23363. getClassName(): string;
  23364. getSimpleName(): string;
  23365. }
  23366. }
  23367. declare module BABYLON {
  23368. class ArcRotateCameraPointersInput implements ICameraInput<ArcRotateCamera> {
  23369. camera: ArcRotateCamera;
  23370. buttons: number[];
  23371. angularSensibilityX: number;
  23372. angularSensibilityY: number;
  23373. pinchPrecision: number;
  23374. /**
  23375. * pinchDeltaPercentage will be used instead of pinchPrecision if different from 0.
  23376. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  23377. */
  23378. pinchDeltaPercentage: number;
  23379. panningSensibility: number;
  23380. multiTouchPanning: boolean;
  23381. multiTouchPanAndZoom: boolean;
  23382. private _isPanClick;
  23383. pinchInwards: boolean;
  23384. private _pointerInput;
  23385. private _observer;
  23386. private _onMouseMove;
  23387. private _onGestureStart;
  23388. private _onGesture;
  23389. private _MSGestureHandler;
  23390. private _onLostFocus;
  23391. private _onContextMenu;
  23392. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  23393. detachControl(element: Nullable<HTMLElement>): void;
  23394. getClassName(): string;
  23395. getSimpleName(): string;
  23396. }
  23397. }
  23398. declare module BABYLON {
  23399. class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  23400. camera: ArcRotateCamera;
  23401. alphaCorrection: number;
  23402. betaCorrection: number;
  23403. gammaCorrection: number;
  23404. private _alpha;
  23405. private _gamma;
  23406. private _dirty;
  23407. private _deviceOrientationHandler;
  23408. constructor();
  23409. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  23410. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  23411. checkInputs(): void;
  23412. detachControl(element: Nullable<HTMLElement>): void;
  23413. getClassName(): string;
  23414. getSimpleName(): string;
  23415. }
  23416. }
  23417. declare module BABYLON {
  23418. /**
  23419. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  23420. * Screen rotation is taken into account.
  23421. */
  23422. class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  23423. private _camera;
  23424. private _screenOrientationAngle;
  23425. private _constantTranform;
  23426. private _screenQuaternion;
  23427. private _alpha;
  23428. private _beta;
  23429. private _gamma;
  23430. constructor();
  23431. camera: FreeCamera;
  23432. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  23433. private _orientationChanged;
  23434. private _deviceOrientation;
  23435. detachControl(element: Nullable<HTMLElement>): void;
  23436. checkInputs(): void;
  23437. getClassName(): string;
  23438. getSimpleName(): string;
  23439. }
  23440. }
  23441. declare module BABYLON {
  23442. class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  23443. camera: FreeCamera;
  23444. gamepad: Nullable<Gamepad>;
  23445. private _onGamepadConnectedObserver;
  23446. private _onGamepadDisconnectedObserver;
  23447. gamepadAngularSensibility: number;
  23448. gamepadMoveSensibility: number;
  23449. private _cameraTransform;
  23450. private _deltaTransform;
  23451. private _vector3;
  23452. private _vector2;
  23453. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  23454. detachControl(element: Nullable<HTMLElement>): void;
  23455. checkInputs(): void;
  23456. getClassName(): string;
  23457. getSimpleName(): string;
  23458. }
  23459. }
  23460. declare module BABYLON {
  23461. class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  23462. camera: FreeCamera;
  23463. private _keys;
  23464. private _onCanvasBlurObserver;
  23465. private _onKeyboardObserver;
  23466. private _engine;
  23467. private _scene;
  23468. keysUp: number[];
  23469. keysDown: number[];
  23470. keysLeft: number[];
  23471. keysRight: number[];
  23472. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  23473. detachControl(element: Nullable<HTMLElement>): void;
  23474. checkInputs(): void;
  23475. getClassName(): string;
  23476. _onLostFocus(e: FocusEvent): void;
  23477. getSimpleName(): string;
  23478. }
  23479. }
  23480. declare module BABYLON {
  23481. class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  23482. touchEnabled: boolean;
  23483. camera: FreeCamera;
  23484. buttons: number[];
  23485. angularSensibility: number;
  23486. private _pointerInput;
  23487. private _onMouseMove;
  23488. private _observer;
  23489. private previousPosition;
  23490. constructor(touchEnabled?: boolean);
  23491. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  23492. detachControl(element: Nullable<HTMLElement>): void;
  23493. getClassName(): string;
  23494. getSimpleName(): string;
  23495. }
  23496. }
  23497. declare module BABYLON {
  23498. class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  23499. camera: FreeCamera;
  23500. private _offsetX;
  23501. private _offsetY;
  23502. private _pointerPressed;
  23503. private _pointerInput;
  23504. private _observer;
  23505. private _onLostFocus;
  23506. touchAngularSensibility: number;
  23507. touchMoveSensibility: number;
  23508. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  23509. detachControl(element: Nullable<HTMLElement>): void;
  23510. checkInputs(): void;
  23511. getClassName(): string;
  23512. getSimpleName(): string;
  23513. }
  23514. }
  23515. declare module BABYLON {
  23516. class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  23517. camera: FreeCamera;
  23518. private _leftjoystick;
  23519. private _rightjoystick;
  23520. getLeftJoystick(): VirtualJoystick;
  23521. getRightJoystick(): VirtualJoystick;
  23522. checkInputs(): void;
  23523. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  23524. detachControl(element: Nullable<HTMLElement>): void;
  23525. getClassName(): string;
  23526. getSimpleName(): string;
  23527. }
  23528. }
  23529. declare module BABYLON {
  23530. class VRCameraMetrics {
  23531. hResolution: number;
  23532. vResolution: number;
  23533. hScreenSize: number;
  23534. vScreenSize: number;
  23535. vScreenCenter: number;
  23536. eyeToScreenDistance: number;
  23537. lensSeparationDistance: number;
  23538. interpupillaryDistance: number;
  23539. distortionK: number[];
  23540. chromaAbCorrection: number[];
  23541. postProcessScaleFactor: number;
  23542. lensCenterOffset: number;
  23543. compensateDistortion: boolean;
  23544. readonly aspectRatio: number;
  23545. readonly aspectRatioFov: number;
  23546. readonly leftHMatrix: Matrix;
  23547. readonly rightHMatrix: Matrix;
  23548. readonly leftPreViewMatrix: Matrix;
  23549. readonly rightPreViewMatrix: Matrix;
  23550. static GetDefault(): VRCameraMetrics;
  23551. }
  23552. }
  23553. declare module BABYLON {
  23554. class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  23555. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  23556. getClassName(): string;
  23557. }
  23558. class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  23559. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  23560. getClassName(): string;
  23561. }
  23562. class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  23563. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  23564. getClassName(): string;
  23565. }
  23566. }
  23567. declare module BABYLON {
  23568. /**
  23569. * Options to modify the vr teleportation behavior.
  23570. */
  23571. interface VRTeleportationOptions {
  23572. /**
  23573. * The name of the mesh which should be used as the teleportation floor. (default: null)
  23574. */
  23575. floorMeshName?: string;
  23576. /**
  23577. * A list of meshes to be used as the teleportation floor. (default: empty)
  23578. */
  23579. floorMeshes?: Mesh[];
  23580. }
  23581. /**
  23582. * Options to modify the vr experience helper's behavior.
  23583. */
  23584. interface VRExperienceHelperOptions extends WebVROptions {
  23585. /**
  23586. * Create a DeviceOrientationCamera to be used as your out of vr camera.
  23587. */
  23588. createDeviceOrientationCamera?: boolean;
  23589. /**
  23590. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found.
  23591. */
  23592. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  23593. }
  23594. /**
  23595. * Helps to quickly add VR support to an existing scene.
  23596. * See http://doc.babylonjs.com/how_to/webvr_helper
  23597. */
  23598. class VRExperienceHelper {
  23599. /** Options to modify the vr experience helper's behavior. */ webVROptions: VRExperienceHelperOptions;
  23600. private _scene;
  23601. private _position;
  23602. private _btnVR;
  23603. private _btnVRDisplayed;
  23604. private _webVRsupported;
  23605. private _webVRready;
  23606. private _webVRrequesting;
  23607. private _webVRpresenting;
  23608. private _fullscreenVRpresenting;
  23609. private _canvas;
  23610. private _webVRCamera;
  23611. private _vrDeviceOrientationCamera;
  23612. private _deviceOrientationCamera;
  23613. private _existingCamera;
  23614. private _onKeyDown;
  23615. private _onVrDisplayPresentChange;
  23616. private _onVRDisplayChanged;
  23617. private _onVRRequestPresentStart;
  23618. private _onVRRequestPresentComplete;
  23619. /**
  23620. * Observable raised when entering VR.
  23621. */
  23622. onEnteringVRObservable: Observable<VRExperienceHelper>;
  23623. /**
  23624. * Observable raised when exiting VR.
  23625. */
  23626. onExitingVRObservable: Observable<VRExperienceHelper>;
  23627. /**
  23628. * Observable raised when controller mesh is loaded.
  23629. */
  23630. onControllerMeshLoadedObservable: Observable<WebVRController>;
  23631. /** Return this.onEnteringVRObservable
  23632. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  23633. */
  23634. readonly onEnteringVR: Observable<VRExperienceHelper>;
  23635. /** Return this.onExitingVRObservable
  23636. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  23637. */
  23638. readonly onExitingVR: Observable<VRExperienceHelper>;
  23639. /** Return this.onControllerMeshLoadedObservable
  23640. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  23641. */
  23642. readonly onControllerMeshLoaded: Observable<WebVRController>;
  23643. private _rayLength;
  23644. private _useCustomVRButton;
  23645. private _teleportationRequested;
  23646. private _teleportActive;
  23647. private _floorMeshName;
  23648. private _floorMeshesCollection;
  23649. private _rotationAllowed;
  23650. private _teleportBackwardsVector;
  23651. private _rotationRightAsked;
  23652. private _rotationLeftAsked;
  23653. private _teleportationTarget;
  23654. private _isDefaultTeleportationTarget;
  23655. private _postProcessMove;
  23656. private _teleportationFillColor;
  23657. private _teleportationBorderColor;
  23658. private _rotationAngle;
  23659. private _haloCenter;
  23660. private _cameraGazer;
  23661. private _padSensibilityUp;
  23662. private _padSensibilityDown;
  23663. private leftController;
  23664. private rightController;
  23665. /**
  23666. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  23667. */
  23668. onNewMeshSelected: Observable<AbstractMesh>;
  23669. /**
  23670. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  23671. */
  23672. onNewMeshPicked: Observable<PickingInfo>;
  23673. private _circleEase;
  23674. /**
  23675. * Observable raised before camera teleportation
  23676. */
  23677. onBeforeCameraTeleport: Observable<Vector3>;
  23678. /**
  23679. * Observable raised after camera teleportation
  23680. */
  23681. onAfterCameraTeleport: Observable<Vector3>;
  23682. /**
  23683. * Observable raised when current selected mesh gets unselected
  23684. */
  23685. onSelectedMeshUnselected: Observable<AbstractMesh>;
  23686. private _raySelectionPredicate;
  23687. /**
  23688. * To be optionaly changed by user to define custom ray selection
  23689. */
  23690. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  23691. /**
  23692. * To be optionaly changed by user to define custom selection logic (after ray selection)
  23693. */
  23694. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  23695. /**
  23696. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  23697. */
  23698. teleportationEnabled: boolean;
  23699. private _defaultHeight;
  23700. private _teleportationInitialized;
  23701. private _interactionsEnabled;
  23702. private _interactionsRequested;
  23703. private _displayGaze;
  23704. private _displayLaserPointer;
  23705. /**
  23706. * The mesh used to display where the user is going to teleport.
  23707. */
  23708. /**
  23709. * Sets the mesh to be used to display where the user is going to teleport.
  23710. */
  23711. teleportationTarget: Mesh;
  23712. /**
  23713. * The mesh used to display where the user is selecting,
  23714. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  23715. * See http://doc.babylonjs.com/resources/baking_transformations
  23716. */
  23717. gazeTrackerMesh: Mesh;
  23718. /**
  23719. * If the ray of the gaze should be displayed.
  23720. */
  23721. /**
  23722. * Sets if the ray of the gaze should be displayed.
  23723. */
  23724. displayGaze: boolean;
  23725. /**
  23726. * If the ray of the LaserPointer should be displayed.
  23727. */
  23728. /**
  23729. * Sets if the ray of the LaserPointer should be displayed.
  23730. */
  23731. displayLaserPointer: boolean;
  23732. /**
  23733. * The deviceOrientationCamera used as the camera when not in VR.
  23734. */
  23735. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  23736. /**
  23737. * Based on the current WebVR support, returns the current VR camera used.
  23738. */
  23739. readonly currentVRCamera: Nullable<Camera>;
  23740. /**
  23741. * The webVRCamera which is used when in VR.
  23742. */
  23743. readonly webVRCamera: WebVRFreeCamera;
  23744. /**
  23745. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  23746. */
  23747. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  23748. private readonly _teleportationRequestInitiated;
  23749. /**
  23750. * Instantiates a VRExperienceHelper.
  23751. * Helps to quickly add VR support to an existing scene.
  23752. * @param scene The scene the VRExperienceHelper belongs to.
  23753. * @param webVROptions Options to modify the vr experience helper's behavior.
  23754. */
  23755. constructor(scene: Scene, /** Options to modify the vr experience helper's behavior. */ webVROptions?: VRExperienceHelperOptions);
  23756. private _onDefaultMeshLoaded(webVRController);
  23757. private _onResize;
  23758. private _onFullscreenChange;
  23759. /**
  23760. * Gets a value indicating if we are currently in VR mode.
  23761. */
  23762. readonly isInVRMode: boolean;
  23763. private onVrDisplayPresentChange();
  23764. private onVRDisplayChanged(eventArgs);
  23765. private moveButtonToBottomRight();
  23766. private displayVRButton();
  23767. private updateButtonVisibility();
  23768. /**
  23769. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  23770. * Otherwise, will use the fullscreen API.
  23771. */
  23772. enterVR(): void;
  23773. /**
  23774. * Attempt to exit VR, or fullscreen.
  23775. */
  23776. exitVR(): void;
  23777. /**
  23778. * The position of the vr experience helper.
  23779. */
  23780. /**
  23781. * Sets the position of the vr experience helper.
  23782. */
  23783. position: Vector3;
  23784. /**
  23785. * Enables controllers and user interactions suck as selecting and object or clicking on an object.
  23786. */
  23787. enableInteractions(): void;
  23788. private beforeRender;
  23789. private _isTeleportationFloor(mesh);
  23790. /**
  23791. * Adds a floor mesh to be used for teleportation.
  23792. * @param floorMesh the mesh to be used for teleportation.
  23793. */
  23794. addFloorMesh(floorMesh: Mesh): void;
  23795. /**
  23796. * Removes a floor mesh from being used for teleportation.
  23797. * @param floorMesh the mesh to be removed.
  23798. */
  23799. removeFloorMesh(floorMesh: Mesh): void;
  23800. /**
  23801. * Enables interactions and teleportation using the VR controllers and gaze.
  23802. * @param vrTeleportationOptions options to modify teleportation behavior.
  23803. */
  23804. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  23805. private _onNewGamepadConnected;
  23806. private _tryEnableInteractionOnController;
  23807. private _onNewGamepadDisconnected;
  23808. private _enableInteractionOnController(controller);
  23809. private _checkTeleportWithRay(stateObject, gazer);
  23810. private _checkRotate(stateObject, gazer);
  23811. private _checkTeleportBackwards(stateObject, gazer);
  23812. private _enableTeleportationOnController(controller);
  23813. private _createTeleportationCircles();
  23814. private _displayTeleportationTarget();
  23815. private _hideTeleportationTarget();
  23816. private _rotateCamera(right);
  23817. private _moveTeleportationSelectorTo(hit, gazer);
  23818. private _workingVector;
  23819. private _workingQuaternion;
  23820. private _workingMatrix;
  23821. private _teleportCamera(location);
  23822. private _castRayAndSelectObject(gazer);
  23823. private _notifySelectedMeshUnselected(mesh);
  23824. /**
  23825. * Sets the color of the laser ray from the vr controllers.
  23826. * @param color new color for the ray.
  23827. */
  23828. changeLaserColor(color: Color3): void;
  23829. /**
  23830. * Sets the color of the ray from the vr headsets gaze.
  23831. * @param color new color for the ray.
  23832. */
  23833. changeGazeColor(color: Color3): void;
  23834. /**
  23835. * Exits VR and disposes of the vr experience helper
  23836. */
  23837. dispose(): void;
  23838. /**
  23839. * Gets the name of the VRExperienceHelper class
  23840. * @returns "VRExperienceHelper"
  23841. */
  23842. getClassName(): string;
  23843. }
  23844. }
  23845. declare var HMDVRDevice: any;
  23846. declare var VRDisplay: any;
  23847. declare var VRFrameData: any;
  23848. declare module BABYLON {
  23849. /**
  23850. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  23851. * IMPORTANT!! The data is right-hand data.
  23852. * @export
  23853. * @interface DevicePose
  23854. */
  23855. interface DevicePose {
  23856. /**
  23857. * The position of the device, values in array are [x,y,z].
  23858. */
  23859. readonly position?: Float32Array;
  23860. /**
  23861. * The linearVelocity of the device, values in array are [x,y,z].
  23862. */
  23863. readonly linearVelocity?: Float32Array;
  23864. /**
  23865. * The linearAcceleration of the device, values in array are [x,y,z].
  23866. */
  23867. readonly linearAcceleration?: Float32Array;
  23868. /**
  23869. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  23870. */
  23871. readonly orientation?: Float32Array;
  23872. /**
  23873. * The angularVelocity of the device, values in array are [x,y,z].
  23874. */
  23875. readonly angularVelocity?: Float32Array;
  23876. /**
  23877. * The angularAcceleration of the device, values in array are [x,y,z].
  23878. */
  23879. readonly angularAcceleration?: Float32Array;
  23880. }
  23881. /**
  23882. * Interface representing a pose controlled object in Babylon.
  23883. * A pose controlled object has both regular pose values as well as pose values
  23884. * from an external device such as a VR head mounted display
  23885. */
  23886. interface PoseControlled {
  23887. /**
  23888. * The position of the object in babylon space.
  23889. */
  23890. position: Vector3;
  23891. /**
  23892. * The rotation quaternion of the object in babylon space.
  23893. */
  23894. rotationQuaternion: Quaternion;
  23895. /**
  23896. * The position of the device in babylon space.
  23897. */
  23898. devicePosition?: Vector3;
  23899. /**
  23900. * The rotation quaternion of the device in babylon space.
  23901. */
  23902. deviceRotationQuaternion: Quaternion;
  23903. /**
  23904. * The raw pose coming from the device.
  23905. */
  23906. rawPose: Nullable<DevicePose>;
  23907. /**
  23908. * The scale of the device to be used when translating from device space to babylon space.
  23909. */
  23910. deviceScaleFactor: number;
  23911. /**
  23912. * Updates the poseControlled values based on the input device pose.
  23913. * @param poseData the pose data to update the object with
  23914. */
  23915. updateFromDevice(poseData: DevicePose): void;
  23916. }
  23917. /**
  23918. * Set of options to customize the webVRCamera
  23919. */
  23920. interface WebVROptions {
  23921. /**
  23922. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  23923. */
  23924. trackPosition?: boolean;
  23925. /**
  23926. * Sets the scale of the vrDevice in babylon space. (default: 1)
  23927. */
  23928. positionScale?: number;
  23929. /**
  23930. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  23931. */
  23932. displayName?: string;
  23933. /**
  23934. * Should the native controller meshes be initialized. (default: true)
  23935. */
  23936. controllerMeshes?: boolean;
  23937. /**
  23938. * Creating a default HemiLight only on controllers. (default: true)
  23939. */
  23940. defaultLightingOnControllers?: boolean;
  23941. /**
  23942. * If you don't want to use the default VR button of the helper. (default: false)
  23943. */
  23944. useCustomVRButton?: boolean;
  23945. /**
  23946. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  23947. */
  23948. customVRButton?: HTMLButtonElement;
  23949. /**
  23950. * To change the length of the ray for gaze/controllers. (default: 100)
  23951. */
  23952. rayLength?: number;
  23953. /**
  23954. * To change the default offset from the ground to account for user's height in meters. (default: 1.7)
  23955. */
  23956. defaultHeight?: number;
  23957. }
  23958. /**
  23959. * This represents a WebVR camera.
  23960. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  23961. * @example http://doc.babylonjs.com/how_to/webvr_camera
  23962. */
  23963. class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  23964. private webVROptions;
  23965. /**
  23966. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  23967. */
  23968. _vrDevice: any;
  23969. /**
  23970. * The rawPose of the vrDevice.
  23971. */
  23972. rawPose: Nullable<DevicePose>;
  23973. private _onVREnabled;
  23974. private _specsVersion;
  23975. private _attached;
  23976. private _frameData;
  23977. protected _descendants: Array<Node>;
  23978. private _deviceRoomPosition;
  23979. private _deviceRoomRotationQuaternion;
  23980. private _standingMatrix;
  23981. /**
  23982. * Represents device position in babylon space.
  23983. */
  23984. devicePosition: Vector3;
  23985. /**
  23986. * Represents device rotation in babylon space.
  23987. */
  23988. deviceRotationQuaternion: Quaternion;
  23989. /**
  23990. * The scale of the device to be used when translating from device space to babylon space.
  23991. */
  23992. deviceScaleFactor: number;
  23993. private _deviceToWorld;
  23994. private _worldToDevice;
  23995. /**
  23996. * References to the webVR controllers for the vrDevice.
  23997. */
  23998. controllers: Array<WebVRController>;
  23999. /**
  24000. * Emits an event when a controller is attached.
  24001. */
  24002. onControllersAttachedObservable: Observable<WebVRController[]>;
  24003. /**
  24004. * Emits an event when a controller's mesh has been loaded;
  24005. */
  24006. onControllerMeshLoadedObservable: Observable<WebVRController>;
  24007. /**
  24008. * If the rig cameras be used as parent instead of this camera.
  24009. */
  24010. rigParenting: boolean;
  24011. private _lightOnControllers;
  24012. private _defaultHeight?;
  24013. /**
  24014. * Instantiates a WebVRFreeCamera.
  24015. * @param name The name of the WebVRFreeCamera
  24016. * @param position The starting anchor position for the camera
  24017. * @param scene The scene the camera belongs to
  24018. * @param webVROptions a set of customizable options for the webVRCamera
  24019. */
  24020. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  24021. /**
  24022. * Gets the device distance from the ground in meters.
  24023. * @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.
  24024. */
  24025. deviceDistanceToRoomGround(): number;
  24026. /**
  24027. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  24028. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  24029. */
  24030. useStandingMatrix(callback?: (bool: boolean) => void): void;
  24031. /**
  24032. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  24033. * @returns A promise with a boolean set to if the standing matrix is supported.
  24034. */
  24035. useStandingMatrixAsync(): Promise<boolean>;
  24036. /**
  24037. * Disposes the camera
  24038. */
  24039. dispose(): void;
  24040. /**
  24041. * Gets a vrController by name.
  24042. * @param name The name of the controller to retreive
  24043. * @returns the controller matching the name specified or null if not found
  24044. */
  24045. getControllerByName(name: string): Nullable<WebVRController>;
  24046. private _leftController;
  24047. /**
  24048. * The controller corrisponding to the users left hand.
  24049. */
  24050. readonly leftController: Nullable<WebVRController>;
  24051. private _rightController;
  24052. /**
  24053. * The controller corrisponding to the users right hand.
  24054. */
  24055. readonly rightController: Nullable<WebVRController>;
  24056. /**
  24057. * Casts a ray forward from the vrCamera's gaze.
  24058. * @param length Length of the ray (default: 100)
  24059. * @returns the ray corrisponding to the gaze
  24060. */
  24061. getForwardRay(length?: number): Ray;
  24062. /**
  24063. * Updates the camera based on device's frame data
  24064. */
  24065. _checkInputs(): void;
  24066. /**
  24067. * Updates the poseControlled values based on the input device pose.
  24068. * @param poseData Pose coming from the device
  24069. */
  24070. updateFromDevice(poseData: DevicePose): void;
  24071. /**
  24072. * WebVR's attach control will start broadcasting frames to the device.
  24073. * Note that in certain browsers (chrome for example) this function must be called
  24074. * within a user-interaction callback. Example:
  24075. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  24076. *
  24077. * @param element html element to attach the vrDevice to
  24078. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  24079. */
  24080. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  24081. /**
  24082. * Detaches the camera from the html element and disables VR
  24083. *
  24084. * @param element html element to detach from
  24085. */
  24086. detachControl(element: HTMLElement): void;
  24087. /**
  24088. * @returns the name of this class
  24089. */
  24090. getClassName(): string;
  24091. /**
  24092. * Calls resetPose on the vrDisplay
  24093. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  24094. */
  24095. resetToCurrentRotation(): void;
  24096. /**
  24097. * Updates the rig cameras (left and right eye)
  24098. */
  24099. _updateRigCameras(): void;
  24100. private _workingVector;
  24101. private _oneVector;
  24102. private _workingMatrix;
  24103. private updateCacheCalled;
  24104. /**
  24105. * Updates the cached values of the camera
  24106. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  24107. */
  24108. _updateCache(ignoreParentClass?: boolean): void;
  24109. /**
  24110. * Updates the current device position and rotation in the babylon world
  24111. */
  24112. update(): void;
  24113. /**
  24114. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  24115. * @returns an identity matrix
  24116. */
  24117. _getViewMatrix(): Matrix;
  24118. /**
  24119. * This function is called by the two RIG cameras.
  24120. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  24121. */
  24122. protected _getWebVRViewMatrix(): Matrix;
  24123. protected _getWebVRProjectionMatrix(): Matrix;
  24124. private _onGamepadConnectedObserver;
  24125. private _onGamepadDisconnectedObserver;
  24126. /**
  24127. * Initializes the controllers and their meshes
  24128. */
  24129. initControllers(): void;
  24130. }
  24131. }
  24132. declare module BABYLON {
  24133. interface IOctreeContainer<T> {
  24134. blocks: Array<OctreeBlock<T>>;
  24135. }
  24136. class Octree<T> {
  24137. maxDepth: number;
  24138. blocks: Array<OctreeBlock<T>>;
  24139. dynamicContent: T[];
  24140. private _maxBlockCapacity;
  24141. private _selectionContent;
  24142. private _creationFunc;
  24143. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number, maxDepth?: number);
  24144. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  24145. addMesh(entry: T): void;
  24146. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  24147. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  24148. intersectsRay(ray: Ray): SmartArray<T>;
  24149. 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;
  24150. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  24151. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  24152. }
  24153. }
  24154. declare module BABYLON {
  24155. class OctreeBlock<T> {
  24156. entries: T[];
  24157. blocks: Array<OctreeBlock<T>>;
  24158. private _depth;
  24159. private _maxDepth;
  24160. private _capacity;
  24161. private _minPoint;
  24162. private _maxPoint;
  24163. private _boundingVectors;
  24164. private _creationFunc;
  24165. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  24166. readonly capacity: number;
  24167. readonly minPoint: Vector3;
  24168. readonly maxPoint: Vector3;
  24169. addEntry(entry: T): void;
  24170. addEntries(entries: T[]): void;
  24171. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  24172. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  24173. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  24174. createInnerBlocks(): void;
  24175. }
  24176. }
  24177. declare module BABYLON {
  24178. class GearVRController extends WebVRController {
  24179. static MODEL_BASE_URL: string;
  24180. static MODEL_FILENAME: string;
  24181. static readonly GAMEPAD_ID_PREFIX: string;
  24182. private readonly _buttonIndexToObservableNameMap;
  24183. constructor(vrGamepad: any);
  24184. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  24185. protected handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  24186. }
  24187. }
  24188. declare module BABYLON {
  24189. class GenericController extends WebVRController {
  24190. static readonly MODEL_BASE_URL: string;
  24191. static readonly MODEL_FILENAME: string;
  24192. constructor(vrGamepad: any);
  24193. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  24194. protected handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  24195. }
  24196. }
  24197. declare module BABYLON {
  24198. class OculusTouchController extends WebVRController {
  24199. static MODEL_BASE_URL: string;
  24200. static MODEL_LEFT_FILENAME: string;
  24201. static MODEL_RIGHT_FILENAME: string;
  24202. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  24203. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  24204. constructor(vrGamepad: any);
  24205. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  24206. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  24207. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  24208. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  24209. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  24210. protected handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  24211. }
  24212. }
  24213. declare module BABYLON {
  24214. enum PoseEnabledControllerType {
  24215. VIVE = 0,
  24216. OCULUS = 1,
  24217. WINDOWS = 2,
  24218. GEAR_VR = 3,
  24219. GENERIC = 4,
  24220. }
  24221. interface MutableGamepadButton {
  24222. value: number;
  24223. touched: boolean;
  24224. pressed: boolean;
  24225. }
  24226. interface ExtendedGamepadButton extends GamepadButton {
  24227. readonly pressed: boolean;
  24228. readonly touched: boolean;
  24229. readonly value: number;
  24230. }
  24231. class PoseEnabledControllerHelper {
  24232. static InitiateController(vrGamepad: any): OculusTouchController | WindowsMotionController | ViveController | GearVRController | GenericController;
  24233. }
  24234. class PoseEnabledController extends Gamepad implements PoseControlled {
  24235. private _deviceRoomPosition;
  24236. private _deviceRoomRotationQuaternion;
  24237. devicePosition: Vector3;
  24238. deviceRotationQuaternion: Quaternion;
  24239. deviceScaleFactor: number;
  24240. position: Vector3;
  24241. rotationQuaternion: Quaternion;
  24242. controllerType: PoseEnabledControllerType;
  24243. private _calculatedPosition;
  24244. private _calculatedRotation;
  24245. rawPose: DevicePose;
  24246. _mesh: Nullable<AbstractMesh>;
  24247. private _poseControlledCamera;
  24248. private _leftHandSystemQuaternion;
  24249. _deviceToWorld: Matrix;
  24250. constructor(browserGamepad: any);
  24251. private _workingMatrix;
  24252. update(): void;
  24253. updateFromDevice(poseData: DevicePose): void;
  24254. attachToMesh(mesh: AbstractMesh): void;
  24255. attachToPoseControlledCamera(camera: TargetCamera): void;
  24256. dispose(): void;
  24257. readonly mesh: Nullable<AbstractMesh>;
  24258. getForwardRay(length?: number): Ray;
  24259. }
  24260. }
  24261. declare module BABYLON {
  24262. class ViveController extends WebVRController {
  24263. static MODEL_BASE_URL: string;
  24264. static MODEL_FILENAME: string;
  24265. constructor(vrGamepad: any);
  24266. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  24267. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  24268. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  24269. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  24270. /**
  24271. * Vive mapping:
  24272. * 0: touchpad
  24273. * 1: trigger
  24274. * 2: left AND right buttons
  24275. * 3: menu button
  24276. */
  24277. protected handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  24278. }
  24279. }
  24280. declare module BABYLON {
  24281. abstract class WebVRController extends PoseEnabledController {
  24282. protected _defaultModel: AbstractMesh;
  24283. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  24284. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  24285. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  24286. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  24287. onPadValuesChangedObservable: Observable<StickValues>;
  24288. protected _buttons: Array<MutableGamepadButton>;
  24289. private _onButtonStateChange;
  24290. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  24291. pad: StickValues;
  24292. hand: string;
  24293. readonly defaultModel: AbstractMesh;
  24294. constructor(vrGamepad: any);
  24295. update(): void;
  24296. protected abstract handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  24297. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  24298. private _setButtonValue(newState, currentState, buttonIndex);
  24299. private _changes;
  24300. private _checkChanges(newState, currentState);
  24301. dispose(): void;
  24302. }
  24303. }
  24304. declare module BABYLON {
  24305. class WindowsMotionController extends WebVRController {
  24306. static MODEL_BASE_URL: string;
  24307. static MODEL_LEFT_FILENAME: string;
  24308. static MODEL_RIGHT_FILENAME: string;
  24309. static readonly GAMEPAD_ID_PREFIX: string;
  24310. private static readonly GAMEPAD_ID_PATTERN;
  24311. private _loadedMeshInfo;
  24312. private readonly _mapping;
  24313. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  24314. onTrackpadValuesChangedObservable: Observable<StickValues>;
  24315. trackpad: StickValues;
  24316. constructor(vrGamepad: any);
  24317. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  24318. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  24319. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  24320. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  24321. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  24322. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  24323. /**
  24324. * Called once per frame by the engine.
  24325. */
  24326. update(): void;
  24327. /**
  24328. * Called once for each button that changed state since the last frame
  24329. * @param buttonIdx Which button index changed
  24330. * @param state New state of the button
  24331. * @param changes Which properties on the state changed since last frame
  24332. */
  24333. protected handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  24334. protected lerpButtonTransform(buttonName: string, buttonValue: number): void;
  24335. protected lerpAxisTransform(axis: number, axisValue: number): void;
  24336. /**
  24337. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  24338. * @param scene scene in which to add meshes
  24339. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  24340. */
  24341. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  24342. /**
  24343. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  24344. * can be transformed by button presses and axes values, based on this._mapping.
  24345. *
  24346. * @param scene scene in which the meshes exist
  24347. * @param meshes list of meshes that make up the controller model to process
  24348. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  24349. */
  24350. private processModel(scene, meshes);
  24351. private createMeshInfo(rootNode);
  24352. getForwardRay(length?: number): Ray;
  24353. dispose(): void;
  24354. }
  24355. }
  24356. declare module BABYLON {
  24357. }
  24358. declare module BABYLON {
  24359. /**
  24360. * Interface to implement to create a shadow generator compatible with BJS.
  24361. */
  24362. interface IShadowGenerator {
  24363. /**
  24364. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  24365. * @returns The render target texture if present otherwise, null
  24366. */
  24367. getShadowMap(): Nullable<RenderTargetTexture>;
  24368. /**
  24369. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  24370. * @returns The render target texture if the shadow map is present otherwise, null
  24371. */
  24372. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  24373. /**
  24374. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  24375. * @param subMesh The submesh we want to render in the shadow map
  24376. * @param useInstances Defines wether will draw in the map using instances
  24377. * @returns true if ready otherwise, false
  24378. */
  24379. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  24380. /**
  24381. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  24382. * @param defines Defines of the material we want to update
  24383. * @param lightIndex Index of the light in the enabled light list of the material
  24384. */
  24385. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  24386. /**
  24387. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  24388. * defined in the generator but impacting the effect).
  24389. * It implies the unifroms available on the materials are the standard BJS ones.
  24390. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  24391. * @param effect The effect we are binfing the information for
  24392. */
  24393. bindShadowLight(lightIndex: string, effect: Effect): void;
  24394. /**
  24395. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  24396. * (eq to shadow prjection matrix * light transform matrix)
  24397. * @returns The transform matrix used to create the shadow map
  24398. */
  24399. getTransformMatrix(): Matrix;
  24400. /**
  24401. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  24402. * Cube and 2D textures for instance.
  24403. */
  24404. recreateShadowMap(): void;
  24405. /**
  24406. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  24407. * @param onCompiled Callback triggered at the and of the effects compilation
  24408. * @param options Sets of optional options forcing the compilation with different modes
  24409. */
  24410. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  24411. useInstances: boolean;
  24412. }>): void;
  24413. /**
  24414. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  24415. * @param options Sets of optional options forcing the compilation with different modes
  24416. * @returns A promise that resolves when the compilation completes
  24417. */
  24418. forceCompilationAsync(options?: Partial<{
  24419. useInstances: boolean;
  24420. }>): Promise<void>;
  24421. /**
  24422. * Serializes the shadow generator setup to a json object.
  24423. * @returns The serialized JSON object
  24424. */
  24425. serialize(): any;
  24426. /**
  24427. * Disposes the Shadow map and related Textures and effects.
  24428. */
  24429. dispose(): void;
  24430. }
  24431. /**
  24432. * Default implementation of @see IShadowGenerator.
  24433. * This is the main object responsible of generating shadows in the framework.
  24434. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  24435. */
  24436. class ShadowGenerator implements IShadowGenerator {
  24437. private static _FILTER_NONE;
  24438. private static _FILTER_EXPONENTIALSHADOWMAP;
  24439. private static _FILTER_POISSONSAMPLING;
  24440. private static _FILTER_BLUREXPONENTIALSHADOWMAP;
  24441. private static _FILTER_CLOSEEXPONENTIALSHADOWMAP;
  24442. private static _FILTER_BLURCLOSEEXPONENTIALSHADOWMAP;
  24443. /**
  24444. * Shadow generator mode None: no filtering applied.
  24445. */
  24446. static readonly FILTER_NONE: number;
  24447. /**
  24448. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  24449. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  24450. */
  24451. static readonly FILTER_POISSONSAMPLING: number;
  24452. /**
  24453. * Shadow generator mode ESM: Exponential Shadow Mapping.
  24454. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  24455. */
  24456. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  24457. /**
  24458. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  24459. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  24460. */
  24461. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  24462. /**
  24463. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  24464. * edge artifacts on steep falloff.
  24465. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  24466. */
  24467. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  24468. /**
  24469. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  24470. * edge artifacts on steep falloff.
  24471. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  24472. */
  24473. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  24474. private _bias;
  24475. /**
  24476. * Gets the bias: offset applied on the depth preventing acnea.
  24477. */
  24478. /**
  24479. * Sets the bias: offset applied on the depth preventing acnea.
  24480. */
  24481. bias: number;
  24482. private _blurBoxOffset;
  24483. /**
  24484. * Gets the blur box offset: offset applied during the blur pass.
  24485. * Only usefull if useKernelBlur = false
  24486. */
  24487. /**
  24488. * Sets the blur box offset: offset applied during the blur pass.
  24489. * Only usefull if useKernelBlur = false
  24490. */
  24491. blurBoxOffset: number;
  24492. private _blurScale;
  24493. /**
  24494. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  24495. * 2 means half of the size.
  24496. */
  24497. /**
  24498. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  24499. * 2 means half of the size.
  24500. */
  24501. blurScale: number;
  24502. private _blurKernel;
  24503. /**
  24504. * Gets the blur kernel: kernel size of the blur pass.
  24505. * Only usefull if useKernelBlur = true
  24506. */
  24507. /**
  24508. * Sets the blur kernel: kernel size of the blur pass.
  24509. * Only usefull if useKernelBlur = true
  24510. */
  24511. blurKernel: number;
  24512. private _useKernelBlur;
  24513. /**
  24514. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  24515. * Only usefull in filtered mode (useBlurExponentialShadowMap...)
  24516. */
  24517. /**
  24518. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  24519. * Only usefull in filtered mode (useBlurExponentialShadowMap...)
  24520. */
  24521. useKernelBlur: boolean;
  24522. private _depthScale;
  24523. /**
  24524. * Gets the depth scale used in ESM mode.
  24525. */
  24526. /**
  24527. * Sets the depth scale used in ESM mode.
  24528. * This can override the scale stored on the light.
  24529. */
  24530. depthScale: number;
  24531. private _filter;
  24532. /**
  24533. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  24534. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  24535. */
  24536. /**
  24537. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  24538. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  24539. */
  24540. filter: number;
  24541. /**
  24542. * Gets if the current filter is set to Poisson Sampling aka PCF.
  24543. */
  24544. /**
  24545. * Sets the current filter to Poisson Sampling aka PCF.
  24546. */
  24547. usePoissonSampling: boolean;
  24548. /**
  24549. * Gets if the current filter is set to VSM.
  24550. * DEPRECATED. Should use useExponentialShadowMap instead.
  24551. */
  24552. /**
  24553. * Sets the current filter is to VSM.
  24554. * DEPRECATED. Should use useExponentialShadowMap instead.
  24555. */
  24556. useVarianceShadowMap: boolean;
  24557. /**
  24558. * Gets if the current filter is set to blurred VSM.
  24559. * DEPRECATED. Should use useBlurExponentialShadowMap instead.
  24560. */
  24561. /**
  24562. * Sets the current filter is to blurred VSM.
  24563. * DEPRECATED. Should use useBlurExponentialShadowMap instead.
  24564. */
  24565. useBlurVarianceShadowMap: boolean;
  24566. /**
  24567. * Gets if the current filter is set to ESM.
  24568. */
  24569. /**
  24570. * Sets the current filter is to ESM.
  24571. */
  24572. useExponentialShadowMap: boolean;
  24573. /**
  24574. * Gets if the current filter is set to filtered ESM.
  24575. */
  24576. /**
  24577. * Gets if the current filter is set to filtered ESM.
  24578. */
  24579. useBlurExponentialShadowMap: boolean;
  24580. /**
  24581. * Gets if the current filter is set to "close ESM" (using the inverse of the
  24582. * exponential to prevent steep falloff artifacts).
  24583. */
  24584. /**
  24585. * Sets the current filter to "close ESM" (using the inverse of the
  24586. * exponential to prevent steep falloff artifacts).
  24587. */
  24588. useCloseExponentialShadowMap: boolean;
  24589. /**
  24590. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  24591. * exponential to prevent steep falloff artifacts).
  24592. */
  24593. /**
  24594. * Sets the current filter to fileterd "close ESM" (using the inverse of the
  24595. * exponential to prevent steep falloff artifacts).
  24596. */
  24597. useBlurCloseExponentialShadowMap: boolean;
  24598. private _darkness;
  24599. /**
  24600. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  24601. * 0 means strongest and 1 would means no shadow.
  24602. * @returns the darkness.
  24603. */
  24604. getDarkness(): number;
  24605. /**
  24606. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  24607. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  24608. * @returns the shadow generator allowing fluent coding.
  24609. */
  24610. setDarkness(darkness: number): ShadowGenerator;
  24611. private _transparencyShadow;
  24612. /**
  24613. * Sets the ability to have transparent shadow (boolean).
  24614. * @param transparent True if transparent else False
  24615. * @returns the shadow generator allowing fluent coding
  24616. */
  24617. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  24618. private _shadowMap;
  24619. private _shadowMap2;
  24620. /**
  24621. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  24622. * @returns The render target texture if present otherwise, null
  24623. */
  24624. getShadowMap(): Nullable<RenderTargetTexture>;
  24625. /**
  24626. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  24627. * @returns The render target texture if the shadow map is present otherwise, null
  24628. */
  24629. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  24630. /**
  24631. * Helper function to add a mesh and its descendants to the list of shadow casters.
  24632. * @param mesh Mesh to add
  24633. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  24634. * @returns the Shadow Generator itself
  24635. */
  24636. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  24637. /**
  24638. * Helper function to remove a mesh and its descendants from the list of shadow casters
  24639. * @param mesh Mesh to remove
  24640. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  24641. * @returns the Shadow Generator itself
  24642. */
  24643. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  24644. /**
  24645. * Controls the extent to which the shadows fade out at the edge of the frustum
  24646. * Used only by directionals and spots
  24647. */
  24648. frustumEdgeFalloff: number;
  24649. private _light;
  24650. /**
  24651. * Returns the associated light object.
  24652. * @returns the light generating the shadow
  24653. */
  24654. getLight(): IShadowLight;
  24655. /**
  24656. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  24657. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  24658. * It might on the other hand introduce peter panning.
  24659. */
  24660. forceBackFacesOnly: boolean;
  24661. private _scene;
  24662. private _lightDirection;
  24663. private _effect;
  24664. private _viewMatrix;
  24665. private _projectionMatrix;
  24666. private _transformMatrix;
  24667. private _cachedPosition;
  24668. private _cachedDirection;
  24669. private _cachedDefines;
  24670. private _currentRenderID;
  24671. private _boxBlurPostprocess;
  24672. private _kernelBlurXPostprocess;
  24673. private _kernelBlurYPostprocess;
  24674. private _blurPostProcesses;
  24675. private _mapSize;
  24676. private _currentFaceIndex;
  24677. private _currentFaceIndexCache;
  24678. private _textureType;
  24679. private _defaultTextureMatrix;
  24680. /**
  24681. * Creates a ShadowGenerator object.
  24682. * A ShadowGenerator is the required tool to use the shadows.
  24683. * Each light casting shadows needs to use its own ShadowGenerator.
  24684. * Documentation : http://doc.babylonjs.com/tutorials/shadows
  24685. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  24686. * @param light The light object generating the shadows.
  24687. * @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.
  24688. */
  24689. constructor(mapSize: number, light: IShadowLight, useFullFloatFirst?: boolean);
  24690. private _initializeGenerator();
  24691. private _initializeShadowMap();
  24692. private _initializeBlurRTTAndPostProcesses();
  24693. private _renderForShadowMap(opaqueSubMeshes, alphaTestSubMeshes, transparentSubMeshes, depthOnlySubMeshes);
  24694. private _renderSubMeshForShadowMap(subMesh);
  24695. private _applyFilterValues();
  24696. /**
  24697. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  24698. * @param onCompiled Callback triggered at the and of the effects compilation
  24699. * @param options Sets of optional options forcing the compilation with different modes
  24700. */
  24701. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  24702. useInstances: boolean;
  24703. }>): void;
  24704. /**
  24705. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  24706. * @param options Sets of optional options forcing the compilation with different modes
  24707. * @returns A promise that resolves when the compilation completes
  24708. */
  24709. forceCompilationAsync(options?: Partial<{
  24710. useInstances: boolean;
  24711. }>): Promise<void>;
  24712. /**
  24713. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  24714. * @param subMesh The submesh we want to render in the shadow map
  24715. * @param useInstances Defines wether will draw in the map using instances
  24716. * @returns true if ready otherwise, false
  24717. */
  24718. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  24719. /**
  24720. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  24721. * @param defines Defines of the material we want to update
  24722. * @param lightIndex Index of the light in the enabled light list of the material
  24723. */
  24724. prepareDefines(defines: any, lightIndex: number): void;
  24725. /**
  24726. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  24727. * defined in the generator but impacting the effect).
  24728. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  24729. * @param effect The effect we are binfing the information for
  24730. */
  24731. bindShadowLight(lightIndex: string, effect: Effect): void;
  24732. /**
  24733. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  24734. * (eq to shadow prjection matrix * light transform matrix)
  24735. * @returns The transform matrix used to create the shadow map
  24736. */
  24737. getTransformMatrix(): Matrix;
  24738. /**
  24739. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  24740. * Cube and 2D textures for instance.
  24741. */
  24742. recreateShadowMap(): void;
  24743. private _disposeBlurPostProcesses();
  24744. private _disposeRTTandPostProcesses();
  24745. /**
  24746. * Disposes the ShadowGenerator.
  24747. * Returns nothing.
  24748. */
  24749. dispose(): void;
  24750. /**
  24751. * Serializes the shadow generator setup to a json object.
  24752. * @returns The serialized JSON object
  24753. */
  24754. serialize(): any;
  24755. /**
  24756. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  24757. * @param parsedShadowGenerator The JSON object to parse
  24758. * @param scene The scene to create the shadow map for
  24759. * @returns The parsed shadow generator
  24760. */
  24761. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  24762. }
  24763. }
  24764. declare module BABYLON {
  24765. /**
  24766. * Background material used to create an efficient environement around your scene.
  24767. */
  24768. class BackgroundMaterial extends PushMaterial {
  24769. /**
  24770. * Standard reflectance value at parallel view angle.
  24771. */
  24772. static StandardReflectance0: number;
  24773. /**
  24774. * Standard reflectance value at grazing angle.
  24775. */
  24776. static StandardReflectance90: number;
  24777. protected _primaryColor: Color3;
  24778. /**
  24779. * Key light Color (multiply against the R channel of the environement texture)
  24780. */
  24781. primaryColor: Color3;
  24782. protected _primaryLevel: float;
  24783. /**
  24784. * Key light Level (allowing HDR output of the background)
  24785. */
  24786. primaryLevel: float;
  24787. protected _secondaryColor: Color3;
  24788. /**
  24789. * Secondary light Color (multiply against the G channel of the environement texture)
  24790. */
  24791. secondaryColor: Color3;
  24792. protected _secondaryLevel: float;
  24793. /**
  24794. * Secondary light Level (allowing HDR output of the background)
  24795. */
  24796. secondaryLevel: float;
  24797. protected _tertiaryColor: Color3;
  24798. /**
  24799. * Tertiary light Color (multiply against the B channel of the environement texture)
  24800. */
  24801. tertiaryColor: Color3;
  24802. protected _tertiaryLevel: float;
  24803. /**
  24804. * Tertiary light Level (allowing HDR output of the background)
  24805. */
  24806. tertiaryLevel: float;
  24807. protected _reflectionTexture: Nullable<BaseTexture>;
  24808. /**
  24809. * Reflection Texture used in the material.
  24810. * Should be author in a specific way for the best result (refer to the documentation).
  24811. */
  24812. reflectionTexture: Nullable<BaseTexture>;
  24813. protected _reflectionBlur: float;
  24814. /**
  24815. * Reflection Texture level of blur.
  24816. *
  24817. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  24818. * texture twice.
  24819. */
  24820. reflectionBlur: float;
  24821. protected _diffuseTexture: Nullable<BaseTexture>;
  24822. /**
  24823. * Diffuse Texture used in the material.
  24824. * Should be author in a specific way for the best result (refer to the documentation).
  24825. */
  24826. diffuseTexture: Nullable<BaseTexture>;
  24827. protected _shadowLights: Nullable<IShadowLight[]>;
  24828. /**
  24829. * Specify the list of lights casting shadow on the material.
  24830. * All scene shadow lights will be included if null.
  24831. */
  24832. shadowLights: Nullable<IShadowLight[]>;
  24833. protected _shadowBlurScale: int;
  24834. /**
  24835. * For the lights having a blurred shadow generator, this can add a second blur pass in order to reach
  24836. * soft lighting on the background.
  24837. */
  24838. shadowBlurScale: int;
  24839. protected _shadowLevel: float;
  24840. /**
  24841. * Helps adjusting the shadow to a softer level if required.
  24842. * 0 means black shadows and 1 means no shadows.
  24843. */
  24844. shadowLevel: float;
  24845. protected _sceneCenter: Vector3;
  24846. /**
  24847. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  24848. * It is usually zero but might be interesting to modify according to your setup.
  24849. */
  24850. sceneCenter: Vector3;
  24851. protected _opacityFresnel: boolean;
  24852. /**
  24853. * This helps specifying that the material is falling off to the sky box at grazing angle.
  24854. * This helps ensuring a nice transition when the camera goes under the ground.
  24855. */
  24856. opacityFresnel: boolean;
  24857. protected _reflectionFresnel: boolean;
  24858. /**
  24859. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  24860. * This helps adding a mirror texture on the ground.
  24861. */
  24862. reflectionFresnel: boolean;
  24863. protected _reflectionFalloffDistance: number;
  24864. /**
  24865. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  24866. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  24867. */
  24868. reflectionFalloffDistance: number;
  24869. protected _reflectionAmount: number;
  24870. /**
  24871. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  24872. */
  24873. reflectionAmount: number;
  24874. protected _reflectionReflectance0: number;
  24875. /**
  24876. * This specifies the weight of the reflection at grazing angle.
  24877. */
  24878. reflectionReflectance0: number;
  24879. protected _reflectionReflectance90: number;
  24880. /**
  24881. * This specifies the weight of the reflection at a perpendicular point of view.
  24882. */
  24883. reflectionReflectance90: number;
  24884. /**
  24885. * Sets the reflection reflectance fresnel values according to the default standard
  24886. * empirically know to work well :-)
  24887. */
  24888. reflectionStandardFresnelWeight: number;
  24889. protected _useRGBColor: boolean;
  24890. /**
  24891. * Helps to directly use the maps channels instead of their level.
  24892. */
  24893. useRGBColor: boolean;
  24894. protected _enableNoise: boolean;
  24895. /**
  24896. * This helps reducing the banding effect that could occur on the background.
  24897. */
  24898. enableNoise: boolean;
  24899. /**
  24900. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  24901. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  24902. * Recommended to be keep at 1.0 except for special cases.
  24903. */
  24904. fovMultiplier: number;
  24905. private _fovMultiplier;
  24906. /**
  24907. * Enable the FOV adjustment feature controlled by fovMultiplier.
  24908. * @type {boolean}
  24909. */
  24910. useEquirectangularFOV: boolean;
  24911. private _maxSimultaneousLights;
  24912. /**
  24913. * Number of Simultaneous lights allowed on the material.
  24914. */
  24915. maxSimultaneousLights: int;
  24916. /**
  24917. * Default configuration related to image processing available in the Background Material.
  24918. */
  24919. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  24920. /**
  24921. * Keep track of the image processing observer to allow dispose and replace.
  24922. */
  24923. private _imageProcessingObserver;
  24924. /**
  24925. * Attaches a new image processing configuration to the PBR Material.
  24926. * @param configuration (if null the scene configuration will be use)
  24927. */
  24928. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  24929. /**
  24930. * Gets the image processing configuration used either in this material.
  24931. */
  24932. /**
  24933. * Sets the Default image processing configuration used either in the this material.
  24934. *
  24935. * If sets to null, the scene one is in use.
  24936. */
  24937. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  24938. /**
  24939. * Gets wether the color curves effect is enabled.
  24940. */
  24941. /**
  24942. * Sets wether the color curves effect is enabled.
  24943. */
  24944. cameraColorCurvesEnabled: boolean;
  24945. /**
  24946. * Gets wether the color grading effect is enabled.
  24947. */
  24948. /**
  24949. * Gets wether the color grading effect is enabled.
  24950. */
  24951. cameraColorGradingEnabled: boolean;
  24952. /**
  24953. * Gets wether tonemapping is enabled or not.
  24954. */
  24955. /**
  24956. * Sets wether tonemapping is enabled or not
  24957. */
  24958. cameraToneMappingEnabled: boolean;
  24959. /**
  24960. * The camera exposure used on this material.
  24961. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  24962. * This corresponds to a photographic exposure.
  24963. */
  24964. /**
  24965. * The camera exposure used on this material.
  24966. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  24967. * This corresponds to a photographic exposure.
  24968. */
  24969. cameraExposure: float;
  24970. /**
  24971. * Gets The camera contrast used on this material.
  24972. */
  24973. /**
  24974. * Sets The camera contrast used on this material.
  24975. */
  24976. cameraContrast: float;
  24977. /**
  24978. * Gets the Color Grading 2D Lookup Texture.
  24979. */
  24980. /**
  24981. * Sets the Color Grading 2D Lookup Texture.
  24982. */
  24983. cameraColorGradingTexture: Nullable<BaseTexture>;
  24984. /**
  24985. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  24986. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  24987. * 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;
  24988. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  24989. */
  24990. /**
  24991. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  24992. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  24993. * 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;
  24994. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  24995. */
  24996. cameraColorCurves: Nullable<ColorCurves>;
  24997. /**
  24998. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  24999. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  25000. */
  25001. switchToBGR: boolean;
  25002. private _renderTargets;
  25003. private _reflectionControls;
  25004. /**
  25005. * Instantiates a Background Material in the given scene
  25006. * @param name The friendly name of the material
  25007. * @param scene The scene to add the material to
  25008. */
  25009. constructor(name: string, scene: Scene);
  25010. /**
  25011. * The entire material has been created in order to prevent overdraw.
  25012. * @returns false
  25013. */
  25014. needAlphaTesting(): boolean;
  25015. /**
  25016. * The entire material has been created in order to prevent overdraw.
  25017. * @returns true if blending is enable
  25018. */
  25019. needAlphaBlending(): boolean;
  25020. /**
  25021. * Checks wether the material is ready to be rendered for a given mesh.
  25022. * @param mesh The mesh to render
  25023. * @param subMesh The submesh to check against
  25024. * @param useInstances Specify wether or not the material is used with instances
  25025. * @returns true if all the dependencies are ready (Textures, Effects...)
  25026. */
  25027. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  25028. /**
  25029. * Build the uniform buffer used in the material.
  25030. */
  25031. buildUniformLayout(): void;
  25032. /**
  25033. * Unbind the material.
  25034. */
  25035. unbind(): void;
  25036. /**
  25037. * Bind only the world matrix to the material.
  25038. * @param world The world matrix to bind.
  25039. */
  25040. bindOnlyWorldMatrix(world: Matrix): void;
  25041. /**
  25042. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  25043. * @param world The world matrix to bind.
  25044. * @param subMesh The submesh to bind for.
  25045. */
  25046. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  25047. /**
  25048. * Dispose the material.
  25049. * @param forceDisposeEffect Force disposal of the associated effect.
  25050. * @param forceDisposeTextures Force disposal of the associated textures.
  25051. */
  25052. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  25053. /**
  25054. * Clones the material.
  25055. * @param name The cloned name.
  25056. * @returns The cloned material.
  25057. */
  25058. clone(name: string): BackgroundMaterial;
  25059. /**
  25060. * Serializes the current material to its JSON representation.
  25061. * @returns The JSON representation.
  25062. */
  25063. serialize(): any;
  25064. /**
  25065. * Gets the class name of the material
  25066. * @returns "BackgroundMaterial"
  25067. */
  25068. getClassName(): string;
  25069. /**
  25070. * Parse a JSON input to create back a background material.
  25071. * @param source The JSON data to parse
  25072. * @param scene The scene to create the parsed material in
  25073. * @param rootUrl The root url of the assets the material depends upon
  25074. * @returns the instantiated BackgroundMaterial.
  25075. */
  25076. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  25077. }
  25078. }
  25079. declare module BABYLON {
  25080. /**
  25081. * The Physically based material base class of BJS.
  25082. *
  25083. * This offers the main features of a standard PBR material.
  25084. * For more information, please refer to the documentation :
  25085. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  25086. */
  25087. abstract class PBRBaseMaterial extends PushMaterial {
  25088. /**
  25089. * Intensity of the direct lights e.g. the four lights available in your scene.
  25090. * This impacts both the direct diffuse and specular highlights.
  25091. */
  25092. protected _directIntensity: number;
  25093. /**
  25094. * Intensity of the emissive part of the material.
  25095. * This helps controlling the emissive effect without modifying the emissive color.
  25096. */
  25097. protected _emissiveIntensity: number;
  25098. /**
  25099. * Intensity of the environment e.g. how much the environment will light the object
  25100. * either through harmonics for rough material or through the refelction for shiny ones.
  25101. */
  25102. protected _environmentIntensity: number;
  25103. /**
  25104. * This is a special control allowing the reduction of the specular highlights coming from the
  25105. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  25106. */
  25107. protected _specularIntensity: number;
  25108. /**
  25109. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  25110. */
  25111. private _lightingInfos;
  25112. /**
  25113. * Debug Control allowing disabling the bump map on this material.
  25114. */
  25115. protected _disableBumpMap: boolean;
  25116. /**
  25117. * AKA Diffuse Texture in standard nomenclature.
  25118. */
  25119. protected _albedoTexture: BaseTexture;
  25120. /**
  25121. * AKA Occlusion Texture in other nomenclature.
  25122. */
  25123. protected _ambientTexture: BaseTexture;
  25124. /**
  25125. * AKA Occlusion Texture Intensity in other nomenclature.
  25126. */
  25127. protected _ambientTextureStrength: number;
  25128. /**
  25129. * Stores the alpha values in a texture.
  25130. */
  25131. protected _opacityTexture: BaseTexture;
  25132. /**
  25133. * Stores the reflection values in a texture.
  25134. */
  25135. protected _reflectionTexture: BaseTexture;
  25136. /**
  25137. * Stores the refraction values in a texture.
  25138. */
  25139. protected _refractionTexture: BaseTexture;
  25140. /**
  25141. * Stores the emissive values in a texture.
  25142. */
  25143. protected _emissiveTexture: BaseTexture;
  25144. /**
  25145. * AKA Specular texture in other nomenclature.
  25146. */
  25147. protected _reflectivityTexture: BaseTexture;
  25148. /**
  25149. * Used to switch from specular/glossiness to metallic/roughness workflow.
  25150. */
  25151. protected _metallicTexture: BaseTexture;
  25152. /**
  25153. * Specifies the metallic scalar of the metallic/roughness workflow.
  25154. * Can also be used to scale the metalness values of the metallic texture.
  25155. */
  25156. protected _metallic: number;
  25157. /**
  25158. * Specifies the roughness scalar of the metallic/roughness workflow.
  25159. * Can also be used to scale the roughness values of the metallic texture.
  25160. */
  25161. protected _roughness: number;
  25162. /**
  25163. * Used to enable roughness/glossiness fetch from a separate chanel depending on the current mode.
  25164. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  25165. */
  25166. protected _microSurfaceTexture: BaseTexture;
  25167. /**
  25168. * Stores surface normal data used to displace a mesh in a texture.
  25169. */
  25170. protected _bumpTexture: BaseTexture;
  25171. /**
  25172. * Stores the pre-calculated light information of a mesh in a texture.
  25173. */
  25174. protected _lightmapTexture: BaseTexture;
  25175. /**
  25176. * The color of a material in ambient lighting.
  25177. */
  25178. protected _ambientColor: Color3;
  25179. /**
  25180. * AKA Diffuse Color in other nomenclature.
  25181. */
  25182. protected _albedoColor: Color3;
  25183. /**
  25184. * AKA Specular Color in other nomenclature.
  25185. */
  25186. protected _reflectivityColor: Color3;
  25187. /**
  25188. * The color applied when light is reflected from a material.
  25189. */
  25190. protected _reflectionColor: Color3;
  25191. /**
  25192. * The color applied when light is emitted from a material.
  25193. */
  25194. protected _emissiveColor: Color3;
  25195. /**
  25196. * AKA Glossiness in other nomenclature.
  25197. */
  25198. protected _microSurface: number;
  25199. /**
  25200. * source material index of refraction (IOR)' / 'destination material IOR.
  25201. */
  25202. protected _indexOfRefraction: number;
  25203. /**
  25204. * Controls if refraction needs to be inverted on Y. This could be usefull for procedural texture.
  25205. */
  25206. protected _invertRefractionY: boolean;
  25207. /**
  25208. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  25209. * Materials half opaque for instance using refraction could benefit from this control.
  25210. */
  25211. protected _linkRefractionWithTransparency: boolean;
  25212. /**
  25213. * Specifies that the material will use the light map as a show map.
  25214. */
  25215. protected _useLightmapAsShadowmap: boolean;
  25216. /**
  25217. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  25218. * makes the reflect vector face the model (under horizon).
  25219. */
  25220. protected _useHorizonOcclusion: boolean;
  25221. /**
  25222. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  25223. * too much the area relying on ambient texture to define their ambient occlusion.
  25224. */
  25225. protected _useRadianceOcclusion: boolean;
  25226. /**
  25227. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  25228. */
  25229. protected _useAlphaFromAlbedoTexture: boolean;
  25230. /**
  25231. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  25232. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  25233. */
  25234. protected _useSpecularOverAlpha: boolean;
  25235. /**
  25236. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  25237. */
  25238. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  25239. /**
  25240. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  25241. */
  25242. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  25243. /**
  25244. * Specifies if the metallic texture contains the roughness information in its green channel.
  25245. */
  25246. protected _useRoughnessFromMetallicTextureGreen: boolean;
  25247. /**
  25248. * Specifies if the metallic texture contains the metallness information in its blue channel.
  25249. */
  25250. protected _useMetallnessFromMetallicTextureBlue: boolean;
  25251. /**
  25252. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  25253. */
  25254. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  25255. /**
  25256. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  25257. */
  25258. protected _useAmbientInGrayScale: boolean;
  25259. /**
  25260. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  25261. * The material will try to infer what glossiness each pixel should be.
  25262. */
  25263. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  25264. /**
  25265. * BJS is using an harcoded light falloff based on a manually sets up range.
  25266. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  25267. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  25268. */
  25269. protected _usePhysicalLightFalloff: boolean;
  25270. /**
  25271. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  25272. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  25273. */
  25274. protected _useRadianceOverAlpha: boolean;
  25275. /**
  25276. * Allows using an object space normal map (instead of tangent space).
  25277. */
  25278. protected _useObjectSpaceNormalMap: boolean;
  25279. /**
  25280. * Allows using the bump map in parallax mode.
  25281. */
  25282. protected _useParallax: boolean;
  25283. /**
  25284. * Allows using the bump map in parallax occlusion mode.
  25285. */
  25286. protected _useParallaxOcclusion: boolean;
  25287. /**
  25288. * Controls the scale bias of the parallax mode.
  25289. */
  25290. protected _parallaxScaleBias: number;
  25291. /**
  25292. * If sets to true, disables all the lights affecting the material.
  25293. */
  25294. protected _disableLighting: boolean;
  25295. /**
  25296. * Number of Simultaneous lights allowed on the material.
  25297. */
  25298. protected _maxSimultaneousLights: number;
  25299. /**
  25300. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  25301. */
  25302. protected _invertNormalMapX: boolean;
  25303. /**
  25304. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  25305. */
  25306. protected _invertNormalMapY: boolean;
  25307. /**
  25308. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  25309. */
  25310. protected _twoSidedLighting: boolean;
  25311. /**
  25312. * Defines the alpha limits in alpha test mode.
  25313. */
  25314. protected _alphaCutOff: number;
  25315. /**
  25316. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  25317. */
  25318. protected _forceAlphaTest: boolean;
  25319. /**
  25320. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  25321. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  25322. */
  25323. protected _useAlphaFresnel: boolean;
  25324. /**
  25325. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  25326. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  25327. */
  25328. protected _useLinearAlphaFresnel: boolean;
  25329. /**
  25330. * The transparency mode of the material.
  25331. */
  25332. protected _transparencyMode: Nullable<number>;
  25333. /**
  25334. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  25335. * from cos thetav and roughness:
  25336. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  25337. */
  25338. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  25339. /**
  25340. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  25341. */
  25342. protected _forceIrradianceInFragment: boolean;
  25343. /**
  25344. * Force normal to face away from face.
  25345. */
  25346. protected _forceNormalForward: boolean;
  25347. /**
  25348. * Force metallic workflow.
  25349. */
  25350. protected _forceMetallicWorkflow: boolean;
  25351. /**
  25352. * Default configuration related to image processing available in the PBR Material.
  25353. */
  25354. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  25355. /**
  25356. * Keep track of the image processing observer to allow dispose and replace.
  25357. */
  25358. private _imageProcessingObserver;
  25359. /**
  25360. * Attaches a new image processing configuration to the PBR Material.
  25361. * @param configuration
  25362. */
  25363. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  25364. /**
  25365. * Stores the available render targets.
  25366. */
  25367. private _renderTargets;
  25368. /**
  25369. * Sets the global ambient color for the material used in lighting calculations.
  25370. */
  25371. private _globalAmbientColor;
  25372. /**
  25373. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  25374. */
  25375. private _useLogarithmicDepth;
  25376. /**
  25377. * Instantiates a new PBRMaterial instance.
  25378. *
  25379. * @param name The material name
  25380. * @param scene The scene the material will be use in.
  25381. */
  25382. constructor(name: string, scene: Scene);
  25383. /**
  25384. * Gets the name of the material class.
  25385. */
  25386. getClassName(): string;
  25387. /**
  25388. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  25389. */
  25390. /**
  25391. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  25392. */
  25393. useLogarithmicDepth: boolean;
  25394. /**
  25395. * Gets the current transparency mode.
  25396. */
  25397. /**
  25398. * Sets the transparency mode of the material.
  25399. */
  25400. transparencyMode: Nullable<number>;
  25401. /**
  25402. * Returns true if alpha blending should be disabled.
  25403. */
  25404. private readonly _disableAlphaBlending;
  25405. /**
  25406. * Specifies whether or not this material should be rendered in alpha blend mode.
  25407. */
  25408. needAlphaBlending(): boolean;
  25409. /**
  25410. * Specifies if the mesh will require alpha blending.
  25411. * @param mesh - BJS mesh.
  25412. */
  25413. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  25414. /**
  25415. * Specifies whether or not this material should be rendered in alpha test mode.
  25416. */
  25417. needAlphaTesting(): boolean;
  25418. /**
  25419. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  25420. */
  25421. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  25422. /**
  25423. * Gets the texture used for the alpha test.
  25424. */
  25425. getAlphaTestTexture(): BaseTexture;
  25426. /**
  25427. * Stores the reflectivity values based on metallic roughness workflow.
  25428. */
  25429. private static _scaledReflectivity;
  25430. /**
  25431. * Specifies that the submesh is ready to be used.
  25432. * @param mesh - BJS mesh.
  25433. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  25434. * @param useInstances - Specifies that instances should be used.
  25435. * @returns - boolean indicating that the submesh is ready or not.
  25436. */
  25437. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  25438. private _prepareEffect(mesh, defines, onCompiled?, onError?, useInstances?, useClipPlane?);
  25439. private _prepareDefines(mesh, defines, useInstances?, useClipPlane?);
  25440. /**
  25441. * Force shader compilation
  25442. */
  25443. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  25444. clipPlane: boolean;
  25445. }>): void;
  25446. /**
  25447. * Initializes the uniform buffer layout for the shader.
  25448. */
  25449. buildUniformLayout(): void;
  25450. /**
  25451. * Unbinds the textures.
  25452. */
  25453. unbind(): void;
  25454. /**
  25455. * Binds the submesh data.
  25456. * @param world - The world matrix.
  25457. * @param mesh - The BJS mesh.
  25458. * @param subMesh - A submesh of the BJS mesh.
  25459. */
  25460. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  25461. /**
  25462. * Returns the animatable textures.
  25463. * @returns - Array of animatable textures.
  25464. */
  25465. getAnimatables(): IAnimatable[];
  25466. /**
  25467. * Returns the texture used for reflections.
  25468. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  25469. */
  25470. private _getReflectionTexture();
  25471. /**
  25472. * Returns the texture used for refraction or null if none is used.
  25473. * @returns - Refection texture if present. If no refraction texture and refraction
  25474. * is linked with transparency, returns environment texture. Otherwise, returns null.
  25475. */
  25476. private _getRefractionTexture();
  25477. /**
  25478. * Disposes the resources of the material.
  25479. * @param forceDisposeEffect - Forces the disposal of effects.
  25480. * @param forceDisposeTextures - Forces the disposal of all textures.
  25481. */
  25482. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  25483. }
  25484. }
  25485. declare module BABYLON {
  25486. /**
  25487. * The Physically based simple base material of BJS.
  25488. *
  25489. * This enables better naming and convention enforcements on top of the pbrMaterial.
  25490. * It is used as the base class for both the specGloss and metalRough conventions.
  25491. */
  25492. abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  25493. /**
  25494. * Number of Simultaneous lights allowed on the material.
  25495. */
  25496. maxSimultaneousLights: number;
  25497. /**
  25498. * If sets to true, disables all the lights affecting the material.
  25499. */
  25500. disableLighting: boolean;
  25501. /**
  25502. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  25503. */
  25504. environmentTexture: BaseTexture;
  25505. /**
  25506. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  25507. */
  25508. invertNormalMapX: boolean;
  25509. /**
  25510. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  25511. */
  25512. invertNormalMapY: boolean;
  25513. /**
  25514. * Normal map used in the model.
  25515. */
  25516. normalTexture: BaseTexture;
  25517. /**
  25518. * Emissivie color used to self-illuminate the model.
  25519. */
  25520. emissiveColor: Color3;
  25521. /**
  25522. * Emissivie texture used to self-illuminate the model.
  25523. */
  25524. emissiveTexture: BaseTexture;
  25525. /**
  25526. * Occlusion Channel Strenght.
  25527. */
  25528. occlusionStrength: number;
  25529. /**
  25530. * Occlusion Texture of the material (adding extra occlusion effects).
  25531. */
  25532. occlusionTexture: BaseTexture;
  25533. /**
  25534. * Defines the alpha limits in alpha test mode.
  25535. */
  25536. alphaCutOff: number;
  25537. /**
  25538. * Gets the current double sided mode.
  25539. */
  25540. /**
  25541. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  25542. */
  25543. doubleSided: boolean;
  25544. lightmapTexture: BaseTexture;
  25545. useLightmapAsShadowmap: boolean;
  25546. /**
  25547. * Return the active textures of the material.
  25548. */
  25549. getActiveTextures(): BaseTexture[];
  25550. hasTexture(texture: BaseTexture): boolean;
  25551. /**
  25552. * Instantiates a new PBRMaterial instance.
  25553. *
  25554. * @param name The material name
  25555. * @param scene The scene the material will be use in.
  25556. */
  25557. constructor(name: string, scene: Scene);
  25558. getClassName(): string;
  25559. }
  25560. }
  25561. declare module BABYLON {
  25562. /**
  25563. * The Physically based material of BJS.
  25564. *
  25565. * This offers the main features of a standard PBR material.
  25566. * For more information, please refer to the documentation :
  25567. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  25568. */
  25569. class PBRMaterial extends PBRBaseMaterial {
  25570. private static _PBRMATERIAL_OPAQUE;
  25571. /**
  25572. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  25573. */
  25574. static readonly PBRMATERIAL_OPAQUE: number;
  25575. /**
  25576. * Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  25577. */
  25578. private static _PBRMATERIAL_ALPHATEST;
  25579. /**
  25580. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  25581. */
  25582. static readonly PBRMATERIAL_ALPHATEST: number;
  25583. /**
  25584. * Represents the value for Alpha Blend. Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  25585. */
  25586. private static _PBRMATERIAL_ALPHABLEND;
  25587. /**
  25588. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  25589. */
  25590. static readonly PBRMATERIAL_ALPHABLEND: number;
  25591. /**
  25592. * 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.
  25593. * They are also discarded below the alpha cutoff threshold to improve performances.
  25594. */
  25595. private static _PBRMATERIAL_ALPHATESTANDBLEND;
  25596. /**
  25597. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  25598. * They are also discarded below the alpha cutoff threshold to improve performances.
  25599. */
  25600. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  25601. /**
  25602. * Intensity of the direct lights e.g. the four lights available in your scene.
  25603. * This impacts both the direct diffuse and specular highlights.
  25604. */
  25605. directIntensity: number;
  25606. /**
  25607. * Intensity of the emissive part of the material.
  25608. * This helps controlling the emissive effect without modifying the emissive color.
  25609. */
  25610. emissiveIntensity: number;
  25611. /**
  25612. * Intensity of the environment e.g. how much the environment will light the object
  25613. * either through harmonics for rough material or through the refelction for shiny ones.
  25614. */
  25615. environmentIntensity: number;
  25616. /**
  25617. * This is a special control allowing the reduction of the specular highlights coming from the
  25618. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  25619. */
  25620. specularIntensity: number;
  25621. /**
  25622. * Debug Control allowing disabling the bump map on this material.
  25623. */
  25624. disableBumpMap: boolean;
  25625. /**
  25626. * AKA Diffuse Texture in standard nomenclature.
  25627. */
  25628. albedoTexture: BaseTexture;
  25629. /**
  25630. * AKA Occlusion Texture in other nomenclature.
  25631. */
  25632. ambientTexture: BaseTexture;
  25633. /**
  25634. * AKA Occlusion Texture Intensity in other nomenclature.
  25635. */
  25636. ambientTextureStrength: number;
  25637. /**
  25638. * Stores the alpha values in a texture.
  25639. */
  25640. opacityTexture: BaseTexture;
  25641. /**
  25642. * Stores the reflection values in a texture.
  25643. */
  25644. reflectionTexture: Nullable<BaseTexture>;
  25645. /**
  25646. * Stores the emissive values in a texture.
  25647. */
  25648. emissiveTexture: BaseTexture;
  25649. /**
  25650. * AKA Specular texture in other nomenclature.
  25651. */
  25652. reflectivityTexture: BaseTexture;
  25653. /**
  25654. * Used to switch from specular/glossiness to metallic/roughness workflow.
  25655. */
  25656. metallicTexture: BaseTexture;
  25657. /**
  25658. * Specifies the metallic scalar of the metallic/roughness workflow.
  25659. * Can also be used to scale the metalness values of the metallic texture.
  25660. */
  25661. metallic: number;
  25662. /**
  25663. * Specifies the roughness scalar of the metallic/roughness workflow.
  25664. * Can also be used to scale the roughness values of the metallic texture.
  25665. */
  25666. roughness: number;
  25667. /**
  25668. * Used to enable roughness/glossiness fetch from a separate chanel depending on the current mode.
  25669. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  25670. */
  25671. microSurfaceTexture: BaseTexture;
  25672. /**
  25673. * Stores surface normal data used to displace a mesh in a texture.
  25674. */
  25675. bumpTexture: BaseTexture;
  25676. /**
  25677. * Stores the pre-calculated light information of a mesh in a texture.
  25678. */
  25679. lightmapTexture: BaseTexture;
  25680. /**
  25681. * Stores the refracted light information in a texture.
  25682. */
  25683. refractionTexture: BaseTexture;
  25684. /**
  25685. * The color of a material in ambient lighting.
  25686. */
  25687. ambientColor: Color3;
  25688. /**
  25689. * AKA Diffuse Color in other nomenclature.
  25690. */
  25691. albedoColor: Color3;
  25692. /**
  25693. * AKA Specular Color in other nomenclature.
  25694. */
  25695. reflectivityColor: Color3;
  25696. /**
  25697. * The color reflected from the material.
  25698. */
  25699. reflectionColor: Color3;
  25700. /**
  25701. * The color emitted from the material.
  25702. */
  25703. emissiveColor: Color3;
  25704. /**
  25705. * AKA Glossiness in other nomenclature.
  25706. */
  25707. microSurface: number;
  25708. /**
  25709. * source material index of refraction (IOR)' / 'destination material IOR.
  25710. */
  25711. indexOfRefraction: number;
  25712. /**
  25713. * Controls if refraction needs to be inverted on Y. This could be usefull for procedural texture.
  25714. */
  25715. invertRefractionY: boolean;
  25716. /**
  25717. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  25718. * Materials half opaque for instance using refraction could benefit from this control.
  25719. */
  25720. linkRefractionWithTransparency: boolean;
  25721. useLightmapAsShadowmap: boolean;
  25722. /**
  25723. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  25724. */
  25725. useAlphaFromAlbedoTexture: boolean;
  25726. /**
  25727. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  25728. */
  25729. forceAlphaTest: boolean;
  25730. /**
  25731. * Defines the alpha limits in alpha test mode.
  25732. */
  25733. alphaCutOff: number;
  25734. /**
  25735. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  25736. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  25737. */
  25738. useSpecularOverAlpha: boolean;
  25739. /**
  25740. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  25741. */
  25742. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  25743. /**
  25744. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  25745. */
  25746. useRoughnessFromMetallicTextureAlpha: boolean;
  25747. /**
  25748. * Specifies if the metallic texture contains the roughness information in its green channel.
  25749. */
  25750. useRoughnessFromMetallicTextureGreen: boolean;
  25751. /**
  25752. * Specifies if the metallic texture contains the metallness information in its blue channel.
  25753. */
  25754. useMetallnessFromMetallicTextureBlue: boolean;
  25755. /**
  25756. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  25757. */
  25758. useAmbientOcclusionFromMetallicTextureRed: boolean;
  25759. /**
  25760. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  25761. */
  25762. useAmbientInGrayScale: boolean;
  25763. /**
  25764. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  25765. * The material will try to infer what glossiness each pixel should be.
  25766. */
  25767. useAutoMicroSurfaceFromReflectivityMap: boolean;
  25768. /**
  25769. * BJS is using an harcoded light falloff based on a manually sets up range.
  25770. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  25771. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  25772. */
  25773. usePhysicalLightFalloff: boolean;
  25774. /**
  25775. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  25776. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  25777. */
  25778. useRadianceOverAlpha: boolean;
  25779. /**
  25780. * Allows using an object space normal map (instead of tangent space).
  25781. */
  25782. useObjectSpaceNormalMap: boolean;
  25783. /**
  25784. * Allows using the bump map in parallax mode.
  25785. */
  25786. useParallax: boolean;
  25787. /**
  25788. * Allows using the bump map in parallax occlusion mode.
  25789. */
  25790. useParallaxOcclusion: boolean;
  25791. /**
  25792. * Controls the scale bias of the parallax mode.
  25793. */
  25794. parallaxScaleBias: number;
  25795. /**
  25796. * If sets to true, disables all the lights affecting the material.
  25797. */
  25798. disableLighting: boolean;
  25799. /**
  25800. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  25801. */
  25802. forceIrradianceInFragment: boolean;
  25803. /**
  25804. * Number of Simultaneous lights allowed on the material.
  25805. */
  25806. maxSimultaneousLights: number;
  25807. /**
  25808. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  25809. */
  25810. invertNormalMapX: boolean;
  25811. /**
  25812. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  25813. */
  25814. invertNormalMapY: boolean;
  25815. /**
  25816. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  25817. */
  25818. twoSidedLighting: boolean;
  25819. /**
  25820. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  25821. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  25822. */
  25823. useAlphaFresnel: boolean;
  25824. /**
  25825. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  25826. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  25827. */
  25828. useLinearAlphaFresnel: boolean;
  25829. /**
  25830. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  25831. * And/Or occlude the blended part.
  25832. */
  25833. environmentBRDFTexture: Nullable<BaseTexture>;
  25834. /**
  25835. * Force normal to face away from face.
  25836. */
  25837. forceNormalForward: boolean;
  25838. /**
  25839. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  25840. * makes the reflect vector face the model (under horizon).
  25841. */
  25842. useHorizonOcclusion: boolean;
  25843. /**
  25844. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  25845. * too much the area relying on ambient texture to define their ambient occlusion.
  25846. */
  25847. useRadianceOcclusion: boolean;
  25848. /**
  25849. * Gets the image processing configuration used either in this material.
  25850. */
  25851. /**
  25852. * Sets the Default image processing configuration used either in the this material.
  25853. *
  25854. * If sets to null, the scene one is in use.
  25855. */
  25856. imageProcessingConfiguration: ImageProcessingConfiguration;
  25857. /**
  25858. * Gets wether the color curves effect is enabled.
  25859. */
  25860. /**
  25861. * Sets wether the color curves effect is enabled.
  25862. */
  25863. cameraColorCurvesEnabled: boolean;
  25864. /**
  25865. * Gets wether the color grading effect is enabled.
  25866. */
  25867. /**
  25868. * Gets wether the color grading effect is enabled.
  25869. */
  25870. cameraColorGradingEnabled: boolean;
  25871. /**
  25872. * Gets wether tonemapping is enabled or not.
  25873. */
  25874. /**
  25875. * Sets wether tonemapping is enabled or not
  25876. */
  25877. cameraToneMappingEnabled: boolean;
  25878. /**
  25879. * The camera exposure used on this material.
  25880. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  25881. * This corresponds to a photographic exposure.
  25882. */
  25883. /**
  25884. * The camera exposure used on this material.
  25885. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  25886. * This corresponds to a photographic exposure.
  25887. */
  25888. cameraExposure: number;
  25889. /**
  25890. * Gets The camera contrast used on this material.
  25891. */
  25892. /**
  25893. * Sets The camera contrast used on this material.
  25894. */
  25895. cameraContrast: number;
  25896. /**
  25897. * Gets the Color Grading 2D Lookup Texture.
  25898. */
  25899. /**
  25900. * Sets the Color Grading 2D Lookup Texture.
  25901. */
  25902. cameraColorGradingTexture: Nullable<BaseTexture>;
  25903. /**
  25904. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  25905. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  25906. * 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;
  25907. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  25908. */
  25909. /**
  25910. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  25911. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  25912. * 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;
  25913. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  25914. */
  25915. cameraColorCurves: Nullable<ColorCurves>;
  25916. /**
  25917. * Instantiates a new PBRMaterial instance.
  25918. *
  25919. * @param name The material name
  25920. * @param scene The scene the material will be use in.
  25921. */
  25922. constructor(name: string, scene: Scene);
  25923. /**
  25924. * Returns the name of this material class.
  25925. */
  25926. getClassName(): string;
  25927. /**
  25928. * Returns an array of the actively used textures.
  25929. * @returns - Array of BaseTextures
  25930. */
  25931. getActiveTextures(): BaseTexture[];
  25932. /**
  25933. * Checks to see if a texture is used in the material.
  25934. * @param texture - Base texture to use.
  25935. * @returns - Boolean specifying if a texture is used in the material.
  25936. */
  25937. hasTexture(texture: BaseTexture): boolean;
  25938. /**
  25939. * Makes a duplicate of the current material.
  25940. * @param name - name to use for the new material.
  25941. */
  25942. clone(name: string): PBRMaterial;
  25943. /**
  25944. * Serializes this PBR Material.
  25945. * @returns - An object with the serialized material.
  25946. */
  25947. serialize(): any;
  25948. /**
  25949. * Parses a PBR Material from a serialized object.
  25950. * @param source - Serialized object.
  25951. * @param scene - BJS scene instance.
  25952. * @param rootUrl - url for the scene object
  25953. * @returns - PBRMaterial
  25954. */
  25955. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  25956. }
  25957. }
  25958. declare module BABYLON {
  25959. /**
  25960. * The PBR material of BJS following the metal roughness convention.
  25961. *
  25962. * This fits to the PBR convention in the GLTF definition:
  25963. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  25964. */
  25965. class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  25966. /**
  25967. * The base color has two different interpretations depending on the value of metalness.
  25968. * When the material is a metal, the base color is the specific measured reflectance value
  25969. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  25970. * of the material.
  25971. */
  25972. baseColor: Color3;
  25973. /**
  25974. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  25975. * well as opacity information in the alpha channel.
  25976. */
  25977. baseTexture: BaseTexture;
  25978. /**
  25979. * Specifies the metallic scalar value of the material.
  25980. * Can also be used to scale the metalness values of the metallic texture.
  25981. */
  25982. metallic: number;
  25983. /**
  25984. * Specifies the roughness scalar value of the material.
  25985. * Can also be used to scale the roughness values of the metallic texture.
  25986. */
  25987. roughness: number;
  25988. /**
  25989. * Texture containing both the metallic value in the B channel and the
  25990. * roughness value in the G channel to keep better precision.
  25991. */
  25992. metallicRoughnessTexture: BaseTexture;
  25993. /**
  25994. * Instantiates a new PBRMetalRoughnessMaterial instance.
  25995. *
  25996. * @param name The material name
  25997. * @param scene The scene the material will be use in.
  25998. */
  25999. constructor(name: string, scene: Scene);
  26000. /**
  26001. * Return the currrent class name of the material.
  26002. */
  26003. getClassName(): string;
  26004. /**
  26005. * Return the active textures of the material.
  26006. */
  26007. getActiveTextures(): BaseTexture[];
  26008. /**
  26009. * Checks to see if a texture is used in the material.
  26010. * @param texture - Base texture to use.
  26011. * @returns - Boolean specifying if a texture is used in the material.
  26012. */
  26013. hasTexture(texture: BaseTexture): boolean;
  26014. /**
  26015. * Makes a duplicate of the current material.
  26016. * @param name - name to use for the new material.
  26017. */
  26018. clone(name: string): PBRMetallicRoughnessMaterial;
  26019. /**
  26020. * Serialize the material to a parsable JSON object.
  26021. */
  26022. serialize(): any;
  26023. /**
  26024. * Parses a JSON object correponding to the serialize function.
  26025. */
  26026. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  26027. }
  26028. }
  26029. declare module BABYLON {
  26030. /**
  26031. * The PBR material of BJS following the specular glossiness convention.
  26032. *
  26033. * This fits to the PBR convention in the GLTF definition:
  26034. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  26035. */
  26036. class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  26037. /**
  26038. * Specifies the diffuse color of the material.
  26039. */
  26040. diffuseColor: Color3;
  26041. /**
  26042. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  26043. * channel.
  26044. */
  26045. diffuseTexture: BaseTexture;
  26046. /**
  26047. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  26048. */
  26049. specularColor: Color3;
  26050. /**
  26051. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  26052. */
  26053. glossiness: number;
  26054. /**
  26055. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  26056. */
  26057. specularGlossinessTexture: BaseTexture;
  26058. /**
  26059. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  26060. *
  26061. * @param name The material name
  26062. * @param scene The scene the material will be use in.
  26063. */
  26064. constructor(name: string, scene: Scene);
  26065. /**
  26066. * Return the currrent class name of the material.
  26067. */
  26068. getClassName(): string;
  26069. /**
  26070. * Return the active textures of the material.
  26071. */
  26072. getActiveTextures(): BaseTexture[];
  26073. /**
  26074. * Checks to see if a texture is used in the material.
  26075. * @param texture - Base texture to use.
  26076. * @returns - Boolean specifying if a texture is used in the material.
  26077. */
  26078. hasTexture(texture: BaseTexture): boolean;
  26079. /**
  26080. * Makes a duplicate of the current material.
  26081. * @param name - name to use for the new material.
  26082. */
  26083. clone(name: string): PBRSpecularGlossinessMaterial;
  26084. /**
  26085. * Serialize the material to a parsable JSON object.
  26086. */
  26087. serialize(): any;
  26088. /**
  26089. * Parses a JSON object correponding to the serialize function.
  26090. */
  26091. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  26092. }
  26093. }
  26094. declare module BABYLON {
  26095. class BaseTexture {
  26096. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  26097. name: string;
  26098. private _hasAlpha;
  26099. hasAlpha: boolean;
  26100. getAlphaFromRGB: boolean;
  26101. level: number;
  26102. coordinatesIndex: number;
  26103. private _coordinatesMode;
  26104. /**
  26105. * How a texture is mapped.
  26106. *
  26107. * | Value | Type | Description |
  26108. * | ----- | ----------------------------------- | ----------- |
  26109. * | 0 | EXPLICIT_MODE | |
  26110. * | 1 | SPHERICAL_MODE | |
  26111. * | 2 | PLANAR_MODE | |
  26112. * | 3 | CUBIC_MODE | |
  26113. * | 4 | PROJECTION_MODE | |
  26114. * | 5 | SKYBOX_MODE | |
  26115. * | 6 | INVCUBIC_MODE | |
  26116. * | 7 | EQUIRECTANGULAR_MODE | |
  26117. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  26118. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  26119. */
  26120. coordinatesMode: number;
  26121. /**
  26122. * | Value | Type | Description |
  26123. * | ----- | ------------------ | ----------- |
  26124. * | 0 | CLAMP_ADDRESSMODE | |
  26125. * | 1 | WRAP_ADDRESSMODE | |
  26126. * | 2 | MIRROR_ADDRESSMODE | |
  26127. */
  26128. wrapU: number;
  26129. /**
  26130. * | Value | Type | Description |
  26131. * | ----- | ------------------ | ----------- |
  26132. * | 0 | CLAMP_ADDRESSMODE | |
  26133. * | 1 | WRAP_ADDRESSMODE | |
  26134. * | 2 | MIRROR_ADDRESSMODE | |
  26135. */
  26136. wrapV: number;
  26137. /**
  26138. * | Value | Type | Description |
  26139. * | ----- | ------------------ | ----------- |
  26140. * | 0 | CLAMP_ADDRESSMODE | |
  26141. * | 1 | WRAP_ADDRESSMODE | |
  26142. * | 2 | MIRROR_ADDRESSMODE | |
  26143. */
  26144. wrapR: number;
  26145. anisotropicFilteringLevel: number;
  26146. isCube: boolean;
  26147. is3D: boolean;
  26148. gammaSpace: boolean;
  26149. invertZ: boolean;
  26150. lodLevelInAlpha: boolean;
  26151. lodGenerationOffset: number;
  26152. lodGenerationScale: number;
  26153. isRenderTarget: boolean;
  26154. readonly uid: string;
  26155. toString(): string;
  26156. getClassName(): string;
  26157. animations: Animation[];
  26158. /**
  26159. * An event triggered when the texture is disposed.
  26160. * @type {BABYLON.Observable}
  26161. */
  26162. onDisposeObservable: Observable<BaseTexture>;
  26163. private _onDisposeObserver;
  26164. onDispose: () => void;
  26165. delayLoadState: number;
  26166. private _scene;
  26167. _texture: Nullable<InternalTexture>;
  26168. private _uid;
  26169. readonly isBlocking: boolean;
  26170. constructor(scene: Nullable<Scene>);
  26171. getScene(): Nullable<Scene>;
  26172. getTextureMatrix(): Matrix;
  26173. getReflectionTextureMatrix(): Matrix;
  26174. getInternalTexture(): Nullable<InternalTexture>;
  26175. isReadyOrNotBlocking(): boolean;
  26176. isReady(): boolean;
  26177. getSize(): ISize;
  26178. getBaseSize(): ISize;
  26179. scale(ratio: number): void;
  26180. readonly canRescale: boolean;
  26181. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number): Nullable<InternalTexture>;
  26182. _rebuild(): void;
  26183. delayLoad(): void;
  26184. clone(): Nullable<BaseTexture>;
  26185. readonly textureType: number;
  26186. readonly textureFormat: number;
  26187. readPixels(faceIndex?: number): Nullable<ArrayBufferView>;
  26188. releaseInternalTexture(): void;
  26189. sphericalPolynomial: Nullable<SphericalPolynomial>;
  26190. readonly _lodTextureHigh: Nullable<BaseTexture>;
  26191. readonly _lodTextureMid: Nullable<BaseTexture>;
  26192. readonly _lodTextureLow: Nullable<BaseTexture>;
  26193. dispose(): void;
  26194. serialize(): any;
  26195. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  26196. }
  26197. }
  26198. declare module BABYLON {
  26199. /**
  26200. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  26201. * It can help converting any input color in a desired output one. This can then be used to create effects
  26202. * from sepia, black and white to sixties or futuristic rendering...
  26203. *
  26204. * The only supported format is currently 3dl.
  26205. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table/
  26206. */
  26207. class ColorGradingTexture extends BaseTexture {
  26208. /**
  26209. * The current texture matrix. (will always be identity in color grading texture)
  26210. */
  26211. private _textureMatrix;
  26212. /**
  26213. * The texture URL.
  26214. */
  26215. url: string;
  26216. /**
  26217. * Empty line regex stored for GC.
  26218. */
  26219. private static _noneEmptyLineRegex;
  26220. private _engine;
  26221. /**
  26222. * Instantiates a ColorGradingTexture from the following parameters.
  26223. *
  26224. * @param url The location of the color gradind data (currently only supporting 3dl)
  26225. * @param scene The scene the texture will be used in
  26226. */
  26227. constructor(url: string, scene: Scene);
  26228. /**
  26229. * Returns the texture matrix used in most of the material.
  26230. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  26231. */
  26232. getTextureMatrix(): Matrix;
  26233. /**
  26234. * Occurs when the file being loaded is a .3dl LUT file.
  26235. */
  26236. private load3dlTexture();
  26237. /**
  26238. * Starts the loading process of the texture.
  26239. */
  26240. private loadTexture();
  26241. /**
  26242. * Clones the color gradind texture.
  26243. */
  26244. clone(): ColorGradingTexture;
  26245. /**
  26246. * Called during delayed load for textures.
  26247. */
  26248. delayLoad(): void;
  26249. /**
  26250. * Parses a color grading texture serialized by Babylon.
  26251. * @param parsedTexture The texture information being parsedTexture
  26252. * @param scene The scene to load the texture in
  26253. * @param rootUrl The root url of the data assets to load
  26254. * @return A color gradind texture
  26255. */
  26256. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<ColorGradingTexture>;
  26257. /**
  26258. * Serializes the LUT texture to json format.
  26259. */
  26260. serialize(): any;
  26261. }
  26262. }
  26263. declare module BABYLON {
  26264. class CubeTexture extends BaseTexture {
  26265. url: string;
  26266. coordinatesMode: number;
  26267. /**
  26268. * Gets or sets the center of the bounding box associated with the cube texture
  26269. * It must define where the camera used to render the texture was set
  26270. */
  26271. boundingBoxPosition: Vector3;
  26272. private _boundingBoxSize;
  26273. /**
  26274. * Gets or sets the size of the bounding box associated with the cube texture
  26275. * When defined, the cubemap will switch to local mode
  26276. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  26277. * @example https://www.babylonjs-playground.com/#RNASML
  26278. */
  26279. boundingBoxSize: Vector3;
  26280. private _noMipmap;
  26281. private _files;
  26282. private _extensions;
  26283. private _textureMatrix;
  26284. private _format;
  26285. private _prefiltered;
  26286. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  26287. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any): CubeTexture;
  26288. 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);
  26289. delayLoad(): void;
  26290. getReflectionTextureMatrix(): Matrix;
  26291. setReflectionTextureMatrix(value: Matrix): void;
  26292. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  26293. clone(): CubeTexture;
  26294. }
  26295. }
  26296. declare module BABYLON {
  26297. class DynamicTexture extends Texture {
  26298. private _generateMipMaps;
  26299. private _canvas;
  26300. private _context;
  26301. private _engine;
  26302. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  26303. readonly canRescale: boolean;
  26304. private _recreate(textureSize);
  26305. scale(ratio: number): void;
  26306. scaleTo(width: number, height: number): void;
  26307. getContext(): CanvasRenderingContext2D;
  26308. clear(): void;
  26309. update(invertY?: boolean): void;
  26310. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  26311. clone(): DynamicTexture;
  26312. _rebuild(): void;
  26313. }
  26314. }
  26315. declare module BABYLON {
  26316. /**
  26317. * This represents a texture coming from an HDR input.
  26318. *
  26319. * The only supported format is currently panorama picture stored in RGBE format.
  26320. * Example of such files can be found on HDRLib: http://hdrlib.com/
  26321. */
  26322. class HDRCubeTexture extends BaseTexture {
  26323. private static _facesMapping;
  26324. private _useInGammaSpace;
  26325. private _generateHarmonics;
  26326. private _noMipmap;
  26327. private _textureMatrix;
  26328. private _size;
  26329. private _usePMREMGenerator;
  26330. private _isBABYLONPreprocessed;
  26331. private _onLoad;
  26332. private _onError;
  26333. /**
  26334. * The texture URL.
  26335. */
  26336. url: string;
  26337. /**
  26338. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  26339. */
  26340. coordinatesMode: number;
  26341. /**
  26342. * Specifies wether the texture has been generated through the PMREMGenerator tool.
  26343. * This is usefull at run time to apply the good shader.
  26344. */
  26345. isPMREM: boolean;
  26346. protected _isBlocking: boolean;
  26347. /**
  26348. * Gets wether or not the texture is blocking during loading.
  26349. */
  26350. /**
  26351. * Sets wether or not the texture is blocking during loading.
  26352. */
  26353. isBlocking: boolean;
  26354. /**
  26355. * Gets or sets the center of the bounding box associated with the cube texture
  26356. * It must define where the camera used to render the texture was set
  26357. */
  26358. boundingBoxPosition: Vector3;
  26359. private _boundingBoxSize;
  26360. /**
  26361. * Gets or sets the size of the bounding box associated with the cube texture
  26362. * When defined, the cubemap will switch to local mode
  26363. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  26364. * @example https://www.babylonjs-playground.com/#RNASML
  26365. */
  26366. boundingBoxSize: Vector3;
  26367. /**
  26368. * Instantiates an HDRTexture from the following parameters.
  26369. *
  26370. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  26371. * @param scene The scene the texture will be used in
  26372. * @param size The cubemap 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.
  26373. * @param noMipmap Forces to not generate the mipmap if true
  26374. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  26375. * @param useInGammaSpace 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)
  26376. * @param usePMREMGenerator Specifies whether or not to generate the CubeMap through CubeMapGen to avoid seams issue at run time.
  26377. */
  26378. constructor(url: string, scene: Scene, size?: number, noMipmap?: boolean, generateHarmonics?: boolean, useInGammaSpace?: boolean, usePMREMGenerator?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  26379. /**
  26380. * Occurs when the file is a preprocessed .babylon.hdr file.
  26381. */
  26382. private loadBabylonTexture();
  26383. /**
  26384. * Occurs when the file is raw .hdr file.
  26385. */
  26386. private loadHDRTexture();
  26387. /**
  26388. * Starts the loading process of the texture.
  26389. */
  26390. private loadTexture();
  26391. clone(): HDRCubeTexture;
  26392. delayLoad(): void;
  26393. getReflectionTextureMatrix(): Matrix;
  26394. setReflectionTextureMatrix(value: Matrix): void;
  26395. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  26396. serialize(): any;
  26397. /**
  26398. * Saves as a file the data contained in the texture in a binary format.
  26399. * This can be used to prevent the long loading tie associated with creating the seamless texture as well
  26400. * as the spherical used in the lighting.
  26401. * @param url The HDR file url.
  26402. * @param size The size of the texture data to generate (one of the cubemap face desired width).
  26403. * @param onError Method called if any error happens during download.
  26404. * @return The packed binary data.
  26405. */
  26406. static generateBabylonHDROnDisk(url: string, size: number, onError?: Nullable<(() => void)>): void;
  26407. /**
  26408. * Serializes the data contained in the texture in a binary format.
  26409. * This can be used to prevent the long loading tie associated with creating the seamless texture as well
  26410. * as the spherical used in the lighting.
  26411. * @param url The HDR file url.
  26412. * @param size The size of the texture data to generate (one of the cubemap face desired width).
  26413. * @param onError Method called if any error happens during download.
  26414. * @return The packed binary data.
  26415. */
  26416. static generateBabylonHDR(url: string, size: number, callback: ((ArrayBuffer: ArrayBuffer) => void), onError?: Nullable<(() => void)>): void;
  26417. }
  26418. }
  26419. declare module BABYLON {
  26420. /**
  26421. * Class used to store data associated with WebGL texture data for the engine
  26422. * This class should not be used directly
  26423. */
  26424. class InternalTexture implements IInternalTextureTracker {
  26425. /**
  26426. * The source of the texture data is unknown
  26427. */
  26428. static DATASOURCE_UNKNOWN: number;
  26429. /**
  26430. * Texture data comes from an URL
  26431. */
  26432. static DATASOURCE_URL: number;
  26433. /**
  26434. * Texture data is only used for temporary storage
  26435. */
  26436. static DATASOURCE_TEMP: number;
  26437. /**
  26438. * Texture data comes from raw data (ArrayBuffer)
  26439. */
  26440. static DATASOURCE_RAW: number;
  26441. /**
  26442. * Texture content is dynamic (video or dynamic texture)
  26443. */
  26444. static DATASOURCE_DYNAMIC: number;
  26445. /**
  26446. * Texture content is generated by rendering to it
  26447. */
  26448. static DATASOURCE_RENDERTARGET: number;
  26449. /**
  26450. * Texture content is part of a multi render target process
  26451. */
  26452. static DATASOURCE_MULTIRENDERTARGET: number;
  26453. /**
  26454. * Texture data comes from a cube data file
  26455. */
  26456. static DATASOURCE_CUBE: number;
  26457. /**
  26458. * Texture data comes from a raw cube data
  26459. */
  26460. static DATASOURCE_CUBERAW: number;
  26461. /**
  26462. * Texture data come from a prefiltered cube data file
  26463. */
  26464. static DATASOURCE_CUBEPREFILTERED: number;
  26465. /**
  26466. * Texture content is raw 3D data
  26467. */
  26468. static DATASOURCE_RAW3D: number;
  26469. /**
  26470. * Texture content is a depth texture
  26471. */
  26472. static DATASOURCE_DEPTHTEXTURE: number;
  26473. /**
  26474. * Defines if the texture is ready
  26475. */
  26476. isReady: boolean;
  26477. /**
  26478. * Defines if the texture is a cube texture
  26479. */
  26480. isCube: boolean;
  26481. /**
  26482. * Defines if the texture contains 3D data
  26483. */
  26484. is3D: boolean;
  26485. /**
  26486. * Gets the URL used to load this texture
  26487. */
  26488. url: string;
  26489. /**
  26490. * Gets the sampling mode of the texture
  26491. */
  26492. samplingMode: number;
  26493. /**
  26494. * Gets a boolean indicating if the texture needs mipmaps generation
  26495. */
  26496. generateMipMaps: boolean;
  26497. /**
  26498. * Gets the number of samples used by the texture (WebGL2+ only)
  26499. */
  26500. samples: number;
  26501. /**
  26502. * Gets the type of the texture
  26503. */
  26504. type: number;
  26505. /**
  26506. * Gets the format of the texture
  26507. */
  26508. format: number;
  26509. /**
  26510. * Observable called when the texture is loaded
  26511. */
  26512. onLoadedObservable: Observable<InternalTexture>;
  26513. /**
  26514. * Gets the width of the texture
  26515. */
  26516. width: number;
  26517. /**
  26518. * Gets the height of the texture
  26519. */
  26520. height: number;
  26521. /**
  26522. * Gets the depth of the texture
  26523. */
  26524. depth: number;
  26525. /**
  26526. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  26527. */
  26528. baseWidth: number;
  26529. /**
  26530. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  26531. */
  26532. baseHeight: number;
  26533. /**
  26534. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  26535. */
  26536. baseDepth: number;
  26537. /**
  26538. * Gets a boolean indicating if the texture is inverted on Y axis
  26539. */
  26540. invertY: boolean;
  26541. /**
  26542. * Gets or set the previous tracker in the list
  26543. */
  26544. previous: Nullable<IInternalTextureTracker>;
  26545. /**
  26546. * Gets or set the next tracker in the list
  26547. */
  26548. next: Nullable<IInternalTextureTracker>;
  26549. /** @ignore */
  26550. _initialSlot: number;
  26551. /** @ignore */
  26552. _designatedSlot: number;
  26553. /** @ignore */
  26554. _dataSource: number;
  26555. /** @ignore */
  26556. _buffer: Nullable<ArrayBuffer | HTMLImageElement>;
  26557. /** @ignore */
  26558. _bufferView: Nullable<ArrayBufferView>;
  26559. /** @ignore */
  26560. _bufferViewArray: Nullable<ArrayBufferView[]>;
  26561. /** @ignore */
  26562. _size: number;
  26563. /** @ignore */
  26564. _extension: string;
  26565. /** @ignore */
  26566. _files: Nullable<string[]>;
  26567. /** @ignore */
  26568. _workingCanvas: HTMLCanvasElement;
  26569. /** @ignore */
  26570. _workingContext: CanvasRenderingContext2D;
  26571. /** @ignore */
  26572. _framebuffer: Nullable<WebGLFramebuffer>;
  26573. /** @ignore */
  26574. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  26575. /** @ignore */
  26576. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  26577. /** @ignore */
  26578. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  26579. /** @ignore */
  26580. _attachments: Nullable<number[]>;
  26581. /** @ignore */
  26582. _cachedCoordinatesMode: Nullable<number>;
  26583. /** @ignore */
  26584. _cachedWrapU: Nullable<number>;
  26585. /** @ignore */
  26586. _cachedWrapV: Nullable<number>;
  26587. /** @ignore */
  26588. _cachedWrapR: Nullable<number>;
  26589. /** @ignore */
  26590. _cachedAnisotropicFilteringLevel: Nullable<number>;
  26591. /** @ignore */
  26592. _isDisabled: boolean;
  26593. /** @ignore */
  26594. _compression: Nullable<string>;
  26595. /** @ignore */
  26596. _generateStencilBuffer: boolean;
  26597. /** @ignore */
  26598. _generateDepthBuffer: boolean;
  26599. /** @ignore */
  26600. _comparisonFunction: number;
  26601. /** @ignore */
  26602. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  26603. /** @ignore */
  26604. _lodGenerationScale: number;
  26605. /** @ignore */
  26606. _lodGenerationOffset: number;
  26607. /** @ignore */
  26608. _lodTextureHigh: BaseTexture;
  26609. /** @ignore */
  26610. _lodTextureMid: BaseTexture;
  26611. /** @ignore */
  26612. _lodTextureLow: BaseTexture;
  26613. /** @ignore */
  26614. _webGLTexture: Nullable<WebGLTexture>;
  26615. /** @ignore */
  26616. _references: number;
  26617. private _engine;
  26618. /**
  26619. * Gets the data source type of the texture (can be one of the BABYLON.InternalTexture.DATASOURCE_XXXX)
  26620. */
  26621. readonly dataSource: number;
  26622. /**
  26623. * Creates a new InternalTexture
  26624. * @param engine defines the engine to use
  26625. * @param dataSource defines the type of data that will be used
  26626. */
  26627. constructor(engine: Engine, dataSource: number);
  26628. /**
  26629. * Increments the number of references (ie. the number of {BABYLON.Texture} that point to it)
  26630. */
  26631. incrementReferences(): void;
  26632. /**
  26633. * Change the size of the texture (not the size of the content)
  26634. * @param width defines the new width
  26635. * @param height defines the new height
  26636. * @param depth defines the new depth (1 by default)
  26637. */
  26638. updateSize(width: int, height: int, depth?: int): void;
  26639. /** @ignore */
  26640. _rebuild(): void;
  26641. private _swapAndDie(target);
  26642. /**
  26643. * Dispose the current allocated resources
  26644. */
  26645. dispose(): void;
  26646. }
  26647. }
  26648. declare module BABYLON {
  26649. /**
  26650. * Internal interface used to track {BABYLON.InternalTexture} already bound to the GL context
  26651. */
  26652. interface IInternalTextureTracker {
  26653. /**
  26654. * Gets or set the previous tracker in the list
  26655. */
  26656. previous: Nullable<IInternalTextureTracker>;
  26657. /**
  26658. * Gets or set the next tracker in the list
  26659. */
  26660. next: Nullable<IInternalTextureTracker>;
  26661. }
  26662. /**
  26663. * Internal class used by the engine to get list of {BABYLON.InternalTexture} already bound to the GL context
  26664. */
  26665. class DummyInternalTextureTracker {
  26666. /**
  26667. * Gets or set the previous tracker in the list
  26668. */
  26669. previous: Nullable<IInternalTextureTracker>;
  26670. /**
  26671. * Gets or set the next tracker in the list
  26672. */
  26673. next: Nullable<IInternalTextureTracker>;
  26674. }
  26675. }
  26676. declare module BABYLON {
  26677. class MirrorTexture extends RenderTargetTexture {
  26678. mirrorPlane: Plane;
  26679. private _transformMatrix;
  26680. private _mirrorMatrix;
  26681. private _savedViewMatrix;
  26682. private _blurX;
  26683. private _blurY;
  26684. private _adaptiveBlurKernel;
  26685. private _blurKernelX;
  26686. private _blurKernelY;
  26687. private _blurRatio;
  26688. blurRatio: number;
  26689. adaptiveBlurKernel: number;
  26690. blurKernel: number;
  26691. blurKernelX: number;
  26692. blurKernelY: number;
  26693. private _autoComputeBlurKernel();
  26694. protected _onRatioRescale(): void;
  26695. constructor(name: string, size: number | {
  26696. width: number;
  26697. height: number;
  26698. } | {
  26699. ratio: number;
  26700. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  26701. private _preparePostProcesses();
  26702. clone(): MirrorTexture;
  26703. serialize(): any;
  26704. }
  26705. }
  26706. declare module BABYLON {
  26707. interface IMultiRenderTargetOptions {
  26708. generateMipMaps?: boolean;
  26709. types?: number[];
  26710. samplingModes?: number[];
  26711. generateDepthBuffer?: boolean;
  26712. generateStencilBuffer?: boolean;
  26713. generateDepthTexture?: boolean;
  26714. textureCount?: number;
  26715. doNotChangeAspectRatio?: boolean;
  26716. defaultType?: number;
  26717. }
  26718. class MultiRenderTarget extends RenderTargetTexture {
  26719. private _internalTextures;
  26720. private _textures;
  26721. readonly isSupported: boolean;
  26722. private _multiRenderTargetOptions;
  26723. readonly textures: Texture[];
  26724. readonly depthTexture: Texture;
  26725. wrapU: number;
  26726. wrapV: number;
  26727. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  26728. _rebuild(): void;
  26729. private _createInternalTextures();
  26730. private _createTextures();
  26731. samples: number;
  26732. resize(size: any): void;
  26733. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  26734. dispose(): void;
  26735. releaseInternalTextures(): void;
  26736. }
  26737. }
  26738. declare module BABYLON {
  26739. class RawTexture extends Texture {
  26740. format: number;
  26741. private _engine;
  26742. constructor(data: ArrayBufferView, width: number, height: number, format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  26743. update(data: ArrayBufferView): void;
  26744. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  26745. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  26746. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  26747. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  26748. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  26749. }
  26750. }
  26751. declare module BABYLON {
  26752. /**
  26753. * Creates a refraction texture used by refraction channel of the standard material.
  26754. * @param name the texture name
  26755. * @param size size of the underlying texture
  26756. * @param scene root scene
  26757. */
  26758. class RefractionTexture extends RenderTargetTexture {
  26759. refractionPlane: Plane;
  26760. depth: number;
  26761. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  26762. clone(): RefractionTexture;
  26763. serialize(): any;
  26764. }
  26765. }
  26766. declare module BABYLON {
  26767. class RenderTargetTexture extends Texture {
  26768. isCube: boolean;
  26769. static _REFRESHRATE_RENDER_ONCE: number;
  26770. static _REFRESHRATE_RENDER_ONEVERYFRAME: number;
  26771. static _REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  26772. static readonly REFRESHRATE_RENDER_ONCE: number;
  26773. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  26774. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  26775. /**
  26776. * Use this predicate to dynamically define the list of mesh you want to render.
  26777. * If set, the renderList property will be overwritten.
  26778. */
  26779. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  26780. /**
  26781. * Use this list to define the list of mesh you want to render.
  26782. */
  26783. renderList: Nullable<Array<AbstractMesh>>;
  26784. renderParticles: boolean;
  26785. renderSprites: boolean;
  26786. coordinatesMode: number;
  26787. activeCamera: Nullable<Camera>;
  26788. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  26789. useCameraPostProcesses: boolean;
  26790. ignoreCameraViewport: boolean;
  26791. private _postProcessManager;
  26792. private _postProcesses;
  26793. private _resizeObserver;
  26794. /**
  26795. * An event triggered when the texture is unbind.
  26796. * @type {BABYLON.Observable}
  26797. */
  26798. onBeforeBindObservable: Observable<RenderTargetTexture>;
  26799. /**
  26800. * An event triggered when the texture is unbind.
  26801. * @type {BABYLON.Observable}
  26802. */
  26803. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  26804. private _onAfterUnbindObserver;
  26805. onAfterUnbind: () => void;
  26806. /**
  26807. * An event triggered before rendering the texture
  26808. * @type {BABYLON.Observable}
  26809. */
  26810. onBeforeRenderObservable: Observable<number>;
  26811. private _onBeforeRenderObserver;
  26812. onBeforeRender: (faceIndex: number) => void;
  26813. /**
  26814. * An event triggered after rendering the texture
  26815. * @type {BABYLON.Observable}
  26816. */
  26817. onAfterRenderObservable: Observable<number>;
  26818. private _onAfterRenderObserver;
  26819. onAfterRender: (faceIndex: number) => void;
  26820. /**
  26821. * An event triggered after the texture clear
  26822. * @type {BABYLON.Observable}
  26823. */
  26824. onClearObservable: Observable<Engine>;
  26825. private _onClearObserver;
  26826. onClear: (Engine: Engine) => void;
  26827. clearColor: Color4;
  26828. protected _size: number | {
  26829. width: number;
  26830. height: number;
  26831. };
  26832. protected _initialSizeParameter: number | {
  26833. width: number;
  26834. height: number;
  26835. } | {
  26836. ratio: number;
  26837. };
  26838. protected _sizeRatio: Nullable<number>;
  26839. _generateMipMaps: boolean;
  26840. protected _renderingManager: RenderingManager;
  26841. _waitingRenderList: string[];
  26842. protected _doNotChangeAspectRatio: boolean;
  26843. protected _currentRefreshId: number;
  26844. protected _refreshRate: number;
  26845. protected _textureMatrix: Matrix;
  26846. protected _samples: number;
  26847. protected _renderTargetOptions: RenderTargetCreationOptions;
  26848. readonly renderTargetOptions: RenderTargetCreationOptions;
  26849. protected _engine: Engine;
  26850. protected _onRatioRescale(): void;
  26851. /**
  26852. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  26853. * It must define where the camera used to render the texture is set
  26854. */
  26855. boundingBoxPosition: Vector3;
  26856. private _boundingBoxSize;
  26857. /**
  26858. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  26859. * When defined, the cubemap will switch to local mode
  26860. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  26861. * @example https://www.babylonjs-playground.com/#RNASML
  26862. */
  26863. boundingBoxSize: Vector3;
  26864. /**
  26865. * In case the RTT has been created with a depth texture, get the associated
  26866. * depth texture.
  26867. * Otherwise, return null.
  26868. */
  26869. depthStencilTexture: Nullable<InternalTexture>;
  26870. /**
  26871. * Instantiate a render target texture. This is mainly to render of screen the scene to for instance apply post processse
  26872. * or used a shadow, depth texture...
  26873. * @param name The friendly name of the texture
  26874. * @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)
  26875. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  26876. * @param generateMipMaps True if mip maps need to be generated after render.
  26877. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  26878. * @param type The type of the buffer in the RTT (int, half float, float...)
  26879. * @param isCube True if a cube texture needs to be created
  26880. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  26881. * @param generateDepthBuffer True to generate a depth buffer
  26882. * @param generateStencilBuffer True to generate a stencil buffer
  26883. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  26884. */
  26885. constructor(name: string, size: number | {
  26886. width: number;
  26887. height: number;
  26888. } | {
  26889. ratio: number;
  26890. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean);
  26891. private _processSizeParameter(size);
  26892. samples: number;
  26893. resetRefreshCounter(): void;
  26894. refreshRate: number;
  26895. addPostProcess(postProcess: PostProcess): void;
  26896. clearPostProcesses(dispose?: boolean): void;
  26897. removePostProcess(postProcess: PostProcess): void;
  26898. _shouldRender(): boolean;
  26899. getRenderSize(): number;
  26900. getRenderWidth(): number;
  26901. getRenderHeight(): number;
  26902. readonly canRescale: boolean;
  26903. scale(ratio: number): void;
  26904. getReflectionTextureMatrix(): Matrix;
  26905. resize(size: number | {
  26906. width: number;
  26907. height: number;
  26908. } | {
  26909. ratio: number;
  26910. }): void;
  26911. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  26912. private _bestReflectionRenderTargetDimension(renderDimension, scale);
  26913. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  26914. private renderToTarget(faceIndex, currentRenderList, currentRenderListLength, useCameraPostProcess, dumpForDebug);
  26915. /**
  26916. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  26917. * This allowed control for front to back rendering or reversly depending of the special needs.
  26918. *
  26919. * @param renderingGroupId The rendering group id corresponding to its index
  26920. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  26921. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  26922. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  26923. */
  26924. 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;
  26925. /**
  26926. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  26927. *
  26928. * @param renderingGroupId The rendering group id corresponding to its index
  26929. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  26930. */
  26931. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  26932. clone(): RenderTargetTexture;
  26933. serialize(): any;
  26934. disposeFramebufferObjects(): void;
  26935. dispose(): void;
  26936. _rebuild(): void;
  26937. }
  26938. }
  26939. declare module BABYLON {
  26940. class Texture extends BaseTexture {
  26941. static NEAREST_SAMPLINGMODE: number;
  26942. static NEAREST_NEAREST_MIPLINEAR: number;
  26943. static BILINEAR_SAMPLINGMODE: number;
  26944. static LINEAR_LINEAR_MIPNEAREST: number;
  26945. static TRILINEAR_SAMPLINGMODE: number;
  26946. static LINEAR_LINEAR_MIPLINEAR: number;
  26947. static NEAREST_NEAREST_MIPNEAREST: number;
  26948. static NEAREST_LINEAR_MIPNEAREST: number;
  26949. static NEAREST_LINEAR_MIPLINEAR: number;
  26950. static NEAREST_LINEAR: number;
  26951. static NEAREST_NEAREST: number;
  26952. static LINEAR_NEAREST_MIPNEAREST: number;
  26953. static LINEAR_NEAREST_MIPLINEAR: number;
  26954. static LINEAR_LINEAR: number;
  26955. static LINEAR_NEAREST: number;
  26956. static EXPLICIT_MODE: number;
  26957. static SPHERICAL_MODE: number;
  26958. static PLANAR_MODE: number;
  26959. static CUBIC_MODE: number;
  26960. static PROJECTION_MODE: number;
  26961. static SKYBOX_MODE: number;
  26962. static INVCUBIC_MODE: number;
  26963. static EQUIRECTANGULAR_MODE: number;
  26964. static FIXED_EQUIRECTANGULAR_MODE: number;
  26965. static FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  26966. static CLAMP_ADDRESSMODE: number;
  26967. static WRAP_ADDRESSMODE: number;
  26968. static MIRROR_ADDRESSMODE: number;
  26969. /**
  26970. * 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
  26971. */
  26972. static UseSerializedUrlIfAny: boolean;
  26973. url: Nullable<string>;
  26974. uOffset: number;
  26975. vOffset: number;
  26976. uScale: number;
  26977. vScale: number;
  26978. uAng: number;
  26979. vAng: number;
  26980. wAng: number;
  26981. readonly noMipmap: boolean;
  26982. private _noMipmap;
  26983. _invertY: boolean;
  26984. private _rowGenerationMatrix;
  26985. private _cachedTextureMatrix;
  26986. private _projectionModeMatrix;
  26987. private _t0;
  26988. private _t1;
  26989. private _t2;
  26990. private _cachedUOffset;
  26991. private _cachedVOffset;
  26992. private _cachedUScale;
  26993. private _cachedVScale;
  26994. private _cachedUAng;
  26995. private _cachedVAng;
  26996. private _cachedWAng;
  26997. private _cachedProjectionMatrixId;
  26998. private _cachedCoordinatesMode;
  26999. _samplingMode: number;
  27000. private _buffer;
  27001. private _deleteBuffer;
  27002. protected _format: Nullable<number>;
  27003. private _delayedOnLoad;
  27004. private _delayedOnError;
  27005. private _onLoadObservable;
  27006. protected _isBlocking: boolean;
  27007. isBlocking: boolean;
  27008. readonly samplingMode: number;
  27009. constructor(url: Nullable<string>, scene: Nullable<Scene>, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, buffer?: any, deleteBuffer?: boolean, format?: number);
  27010. updateURL(url: string): void;
  27011. delayLoad(): void;
  27012. updateSamplingMode(samplingMode: number): void;
  27013. private _prepareRowForTextureGeneration(x, y, z, t);
  27014. getTextureMatrix(): Matrix;
  27015. getReflectionTextureMatrix(): Matrix;
  27016. clone(): Texture;
  27017. readonly onLoadObservable: Observable<Texture>;
  27018. serialize(): any;
  27019. getClassName(): string;
  27020. dispose(): void;
  27021. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  27022. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  27023. 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;
  27024. }
  27025. }
  27026. declare module BABYLON {
  27027. /**
  27028. * Settings for finer control over video usage
  27029. */
  27030. interface VideoTextureSettings {
  27031. /**
  27032. * Applies `autoplay` to video, if specified
  27033. */
  27034. autoPlay?: boolean;
  27035. /**
  27036. * Applies `loop` to video, if specified
  27037. */
  27038. loop?: boolean;
  27039. /**
  27040. * Automatically updates internal texture from video at every frame in the render loop
  27041. */
  27042. autoUpdateTexture: boolean;
  27043. }
  27044. class VideoTexture extends Texture {
  27045. /**
  27046. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  27047. */
  27048. readonly autoUpdateTexture: boolean;
  27049. /**
  27050. * The video instance used by the texture internally
  27051. */
  27052. readonly video: HTMLVideoElement;
  27053. private _generateMipMaps;
  27054. private _engine;
  27055. /**
  27056. * Creates a video texture.
  27057. * Sample : https://doc.babylonjs.com/how_to/video_texture
  27058. * @param {string | null} name optional name, will detect from video source, if not defined
  27059. * @param {(string | string[] | HTMLVideoElement)} src can be used to provide an url, array of urls or an already setup HTML video element.
  27060. * @param {BABYLON.Scene} scene is obviously the current scene.
  27061. * @param {boolean} generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  27062. * @param {boolean} invertY is false by default but can be used to invert video on Y axis
  27063. * @param {number} samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  27064. * @param {VideoTextureSettings} [settings] allows finer control over video usage
  27065. */
  27066. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  27067. private _getName(src);
  27068. private _getVideo(src);
  27069. private _createInternalTexture;
  27070. private reset;
  27071. /**
  27072. * Internal method to initiate `update`.
  27073. */
  27074. _rebuild(): void;
  27075. /**
  27076. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  27077. */
  27078. update(): void;
  27079. /**
  27080. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  27081. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  27082. */
  27083. updateTexture(isVisible: boolean): void;
  27084. protected _updateInternalTexture: (e?: Event | undefined) => void;
  27085. /**
  27086. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  27087. * @param url New url.
  27088. */
  27089. updateURL(url: string): void;
  27090. dispose(): void;
  27091. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  27092. minWidth: number;
  27093. maxWidth: number;
  27094. minHeight: number;
  27095. maxHeight: number;
  27096. deviceId: string;
  27097. }): void;
  27098. }
  27099. }
  27100. declare var DracoDecoderModule: any;
  27101. declare module BABYLON {
  27102. /**
  27103. * Draco compression (https://google.github.io/draco/)
  27104. */
  27105. class DracoCompression implements IDisposable {
  27106. private _workerPool;
  27107. /**
  27108. * Gets the url to the draco decoder if available.
  27109. */
  27110. static DecoderUrl: Nullable<string>;
  27111. /**
  27112. * Constructor
  27113. * @param numWorkers The number of workers for async operations
  27114. */
  27115. constructor(numWorkers?: number);
  27116. /**
  27117. * Stop all async operations and release resources.
  27118. */
  27119. dispose(): void;
  27120. /**
  27121. * Decode Draco compressed mesh data to vertex data.
  27122. * @param data The array buffer view for the Draco compression data
  27123. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  27124. * @returns A promise that resolves with the decoded vertex data
  27125. */
  27126. decodeMeshAsync(data: ArrayBufferView, attributes: {
  27127. [kind: string]: number;
  27128. }): Promise<VertexData>;
  27129. /**
  27130. * The worker function that gets converted to a blob url to pass into a worker.
  27131. */
  27132. private static _Worker();
  27133. private static _WorkerBlobUrl;
  27134. private static _GetDefaultDecoderUrl();
  27135. }
  27136. }
  27137. declare module BABYLON {
  27138. /**
  27139. * Particle emitter emitting particles from the inside of a box.
  27140. * It emits the particles randomly between 2 given directions.
  27141. */
  27142. class BoxParticleEmitter implements IParticleEmitterType {
  27143. /**
  27144. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  27145. */
  27146. direction1: Vector3;
  27147. /**
  27148. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  27149. */
  27150. direction2: Vector3;
  27151. /**
  27152. * 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.
  27153. */
  27154. minEmitBox: Vector3;
  27155. /**
  27156. * 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.
  27157. */
  27158. maxEmitBox: Vector3;
  27159. /**
  27160. * Creates a new instance of @see BoxParticleEmitter
  27161. */
  27162. constructor();
  27163. /**
  27164. * Called by the particle System when the direction is computed for the created particle.
  27165. * @param emitPower is the power of the particle (speed)
  27166. * @param worldMatrix is the world matrix of the particle system
  27167. * @param directionToUpdate is the direction vector to update with the result
  27168. * @param particle is the particle we are computed the direction for
  27169. */
  27170. startDirectionFunction(emitPower: number, worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  27171. /**
  27172. * Called by the particle System when the position is computed for the created particle.
  27173. * @param worldMatrix is the world matrix of the particle system
  27174. * @param positionToUpdate is the position vector to update with the result
  27175. * @param particle is the particle we are computed the position for
  27176. */
  27177. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  27178. /**
  27179. * Clones the current emitter and returns a copy of it
  27180. * @returns the new emitter
  27181. */
  27182. clone(): BoxParticleEmitter;
  27183. /**
  27184. * Called by the {BABYLON.GPUParticleSystem} to setup the update shader
  27185. * @param effect defines the update shader
  27186. */
  27187. applyToShader(effect: Effect): void;
  27188. /**
  27189. * Returns a string to use to update the GPU particles update shader
  27190. * @returns a string containng the defines string
  27191. */
  27192. getEffectDefines(): string;
  27193. /**
  27194. * Returns the string "BoxEmitter"
  27195. * @returns a string containing the class name
  27196. */
  27197. getClassName(): string;
  27198. /**
  27199. * Serializes the particle system to a JSON object.
  27200. * @returns the JSON object
  27201. */
  27202. serialize(): any;
  27203. /**
  27204. * Parse properties from a JSON object
  27205. * @param serializationObject defines the JSON object
  27206. */
  27207. parse(serializationObject: any): void;
  27208. }
  27209. }
  27210. declare module BABYLON {
  27211. /**
  27212. * Particle emitter emitting particles from the inside of a cone.
  27213. * It emits the particles alongside the cone volume from the base to the particle.
  27214. * The emission direction might be randomized.
  27215. */
  27216. class ConeParticleEmitter implements IParticleEmitterType {
  27217. /**
  27218. * The radius of the emission cone.
  27219. */
  27220. angle: number;
  27221. /**
  27222. * The cone base angle.
  27223. */
  27224. directionRandomizer: number;
  27225. private _radius;
  27226. private _height;
  27227. /**
  27228. * Gets the radius of the emission cone.
  27229. */
  27230. /**
  27231. * Sets the radius of the emission cone.
  27232. */
  27233. radius: number;
  27234. /**
  27235. * Creates a new instance of @see ConeParticleEmitter
  27236. * @param radius the radius of the emission cone (1 by default)
  27237. * @param angles the cone base angle (PI by default)
  27238. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  27239. */
  27240. constructor(radius?: number,
  27241. /**
  27242. * The radius of the emission cone.
  27243. */
  27244. angle?: number,
  27245. /**
  27246. * The cone base angle.
  27247. */
  27248. directionRandomizer?: number);
  27249. /**
  27250. * Called by the particle System when the direction is computed for the created particle.
  27251. * @param emitPower is the power of the particle (speed)
  27252. * @param worldMatrix is the world matrix of the particle system
  27253. * @param directionToUpdate is the direction vector to update with the result
  27254. * @param particle is the particle we are computed the direction for
  27255. */
  27256. startDirectionFunction(emitPower: number, worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  27257. /**
  27258. * Called by the particle System when the position is computed for the created particle.
  27259. * @param worldMatrix is the world matrix of the particle system
  27260. * @param positionToUpdate is the position vector to update with the result
  27261. * @param particle is the particle we are computed the position for
  27262. */
  27263. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  27264. /**
  27265. * Clones the current emitter and returns a copy of it
  27266. * @returns the new emitter
  27267. */
  27268. clone(): ConeParticleEmitter;
  27269. /**
  27270. * Called by the {BABYLON.GPUParticleSystem} to setup the update shader
  27271. * @param effect defines the update shader
  27272. */
  27273. applyToShader(effect: Effect): void;
  27274. /**
  27275. * Returns a string to use to update the GPU particles update shader
  27276. * @returns a string containng the defines string
  27277. */
  27278. getEffectDefines(): string;
  27279. /**
  27280. * Returns the string "BoxEmitter"
  27281. * @returns a string containing the class name
  27282. */
  27283. getClassName(): string;
  27284. /**
  27285. * Serializes the particle system to a JSON object.
  27286. * @returns the JSON object
  27287. */
  27288. serialize(): any;
  27289. /**
  27290. * Parse properties from a JSON object
  27291. * @param serializationObject defines the JSON object
  27292. */
  27293. parse(serializationObject: any): void;
  27294. }
  27295. }
  27296. declare module BABYLON {
  27297. /**
  27298. * Particle emitter represents a volume emitting particles.
  27299. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  27300. */
  27301. interface IParticleEmitterType {
  27302. /**
  27303. * Called by the particle System when the direction is computed for the created particle.
  27304. * @param emitPower is the power of the particle (speed)
  27305. * @param worldMatrix is the world matrix of the particle system
  27306. * @param directionToUpdate is the direction vector to update with the result
  27307. * @param particle is the particle we are computed the direction for
  27308. */
  27309. startDirectionFunction(emitPower: number, worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  27310. /**
  27311. * Called by the particle System when the position is computed for the created particle.
  27312. * @param worldMatrix is the world matrix of the particle system
  27313. * @param positionToUpdate is the position vector to update with the result
  27314. * @param particle is the particle we are computed the position for
  27315. */
  27316. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  27317. /**
  27318. * Clones the current emitter and returns a copy of it
  27319. * @returns the new emitter
  27320. */
  27321. clone(): IParticleEmitterType;
  27322. /**
  27323. * Called by the {BABYLON.GPUParticleSystem} to setup the update shader
  27324. * @param effect defines the update shader
  27325. */
  27326. applyToShader(effect: Effect): void;
  27327. /**
  27328. * Returns a string to use to update the GPU particles update shader
  27329. * @returns the effect defines string
  27330. */
  27331. getEffectDefines(): string;
  27332. /**
  27333. * Returns a string representing the class name
  27334. * @returns a string containing the class name
  27335. */
  27336. getClassName(): string;
  27337. /**
  27338. * Serializes the particle system to a JSON object.
  27339. * @returns the JSON object
  27340. */
  27341. serialize(): any;
  27342. /**
  27343. * Parse properties from a JSON object
  27344. * @param serializationObject defines the JSON object
  27345. */
  27346. parse(serializationObject: any): void;
  27347. }
  27348. }
  27349. declare module BABYLON {
  27350. /**
  27351. * Particle emitter emitting particles from the inside of a sphere.
  27352. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  27353. */
  27354. class SphereParticleEmitter implements IParticleEmitterType {
  27355. /**
  27356. * The radius of the emission sphere.
  27357. */
  27358. radius: number;
  27359. /**
  27360. * How much to randomize the particle direction [0-1].
  27361. */
  27362. directionRandomizer: number;
  27363. /**
  27364. * Creates a new instance of @see SphereParticleEmitter
  27365. * @param radius the radius of the emission sphere (1 by default)
  27366. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  27367. */
  27368. constructor(
  27369. /**
  27370. * The radius of the emission sphere.
  27371. */
  27372. radius?: number,
  27373. /**
  27374. * How much to randomize the particle direction [0-1].
  27375. */
  27376. directionRandomizer?: number);
  27377. /**
  27378. * Called by the particle System when the direction is computed for the created particle.
  27379. * @param emitPower is the power of the particle (speed)
  27380. * @param worldMatrix is the world matrix of the particle system
  27381. * @param directionToUpdate is the direction vector to update with the result
  27382. * @param particle is the particle we are computed the direction for
  27383. */
  27384. startDirectionFunction(emitPower: number, worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  27385. /**
  27386. * Called by the particle System when the position is computed for the created particle.
  27387. * @param worldMatrix is the world matrix of the particle system
  27388. * @param positionToUpdate is the position vector to update with the result
  27389. * @param particle is the particle we are computed the position for
  27390. */
  27391. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  27392. /**
  27393. * Clones the current emitter and returns a copy of it
  27394. * @returns the new emitter
  27395. */
  27396. clone(): SphereParticleEmitter;
  27397. /**
  27398. * Called by the {BABYLON.GPUParticleSystem} to setup the update shader
  27399. * @param effect defines the update shader
  27400. */
  27401. applyToShader(effect: Effect): void;
  27402. /**
  27403. * Returns a string to use to update the GPU particles update shader
  27404. * @returns a string containng the defines string
  27405. */
  27406. getEffectDefines(): string;
  27407. /**
  27408. * Returns the string "SphereParticleEmitter"
  27409. * @returns a string containing the class name
  27410. */
  27411. getClassName(): string;
  27412. /**
  27413. * Serializes the particle system to a JSON object.
  27414. * @returns the JSON object
  27415. */
  27416. serialize(): any;
  27417. /**
  27418. * Parse properties from a JSON object
  27419. * @param serializationObject defines the JSON object
  27420. */
  27421. parse(serializationObject: any): void;
  27422. }
  27423. /**
  27424. * Particle emitter emitting particles from the inside of a sphere.
  27425. * It emits the particles randomly between two vectors.
  27426. */
  27427. class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  27428. /**
  27429. * The min limit of the emission direction.
  27430. */
  27431. direction1: Vector3;
  27432. /**
  27433. * The max limit of the emission direction.
  27434. */
  27435. direction2: Vector3;
  27436. /**
  27437. * Creates a new instance of @see SphereDirectedParticleEmitter
  27438. * @param radius the radius of the emission sphere (1 by default)
  27439. * @param direction1 the min limit of the emission direction (up vector by default)
  27440. * @param direction2 the max limit of the emission direction (up vector by default)
  27441. */
  27442. constructor(radius?: number,
  27443. /**
  27444. * The min limit of the emission direction.
  27445. */
  27446. direction1?: Vector3,
  27447. /**
  27448. * The max limit of the emission direction.
  27449. */
  27450. direction2?: Vector3);
  27451. /**
  27452. * Called by the particle System when the direction is computed for the created particle.
  27453. * @param emitPower is the power of the particle (speed)
  27454. * @param worldMatrix is the world matrix of the particle system
  27455. * @param directionToUpdate is the direction vector to update with the result
  27456. * @param particle is the particle we are computed the direction for
  27457. */
  27458. startDirectionFunction(emitPower: number, worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  27459. /**
  27460. * Clones the current emitter and returns a copy of it
  27461. * @returns the new emitter
  27462. */
  27463. clone(): SphereDirectedParticleEmitter;
  27464. /**
  27465. * Called by the {BABYLON.GPUParticleSystem} to setup the update shader
  27466. * @param effect defines the update shader
  27467. */
  27468. applyToShader(effect: Effect): void;
  27469. /**
  27470. * Returns a string to use to update the GPU particles update shader
  27471. * @returns a string containng the defines string
  27472. */
  27473. getEffectDefines(): string;
  27474. /**
  27475. * Returns the string "SphereDirectedParticleEmitter"
  27476. * @returns a string containing the class name
  27477. */
  27478. getClassName(): string;
  27479. /**
  27480. * Serializes the particle system to a JSON object.
  27481. * @returns the JSON object
  27482. */
  27483. serialize(): any;
  27484. /**
  27485. * Parse properties from a JSON object
  27486. * @param serializationObject defines the JSON object
  27487. */
  27488. parse(serializationObject: any): void;
  27489. }
  27490. }
  27491. declare module BABYLON {
  27492. class CannonJSPlugin implements IPhysicsEnginePlugin {
  27493. private _useDeltaForWorldStep;
  27494. world: any;
  27495. name: string;
  27496. private _physicsMaterials;
  27497. private _fixedTimeStep;
  27498. BJSCANNON: any;
  27499. constructor(_useDeltaForWorldStep?: boolean, iterations?: number);
  27500. setGravity(gravity: Vector3): void;
  27501. setTimeStep(timeStep: number): void;
  27502. getTimeStep(): number;
  27503. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  27504. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  27505. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  27506. generatePhysicsBody(impostor: PhysicsImpostor): void;
  27507. private _processChildMeshes(mainImpostor);
  27508. removePhysicsBody(impostor: PhysicsImpostor): void;
  27509. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  27510. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  27511. private _addMaterial(name, friction, restitution);
  27512. private _checkWithEpsilon(value);
  27513. private _createShape(impostor);
  27514. private _createHeightmap(object, pointDepth?);
  27515. private _minus90X;
  27516. private _plus90X;
  27517. private _tmpPosition;
  27518. private _tmpDeltaPosition;
  27519. private _tmpUnityRotation;
  27520. private _updatePhysicsBodyTransformation(impostor);
  27521. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  27522. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  27523. isSupported(): boolean;
  27524. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  27525. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  27526. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  27527. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  27528. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  27529. getBodyMass(impostor: PhysicsImpostor): number;
  27530. getBodyFriction(impostor: PhysicsImpostor): number;
  27531. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  27532. getBodyRestitution(impostor: PhysicsImpostor): number;
  27533. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  27534. sleepBody(impostor: PhysicsImpostor): void;
  27535. wakeUpBody(impostor: PhysicsImpostor): void;
  27536. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  27537. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  27538. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  27539. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  27540. getRadius(impostor: PhysicsImpostor): number;
  27541. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  27542. dispose(): void;
  27543. private _extendNamespace();
  27544. }
  27545. }
  27546. declare module BABYLON {
  27547. class OimoJSPlugin implements IPhysicsEnginePlugin {
  27548. world: any;
  27549. name: string;
  27550. BJSOIMO: any;
  27551. constructor(iterations?: number);
  27552. setGravity(gravity: Vector3): void;
  27553. setTimeStep(timeStep: number): void;
  27554. getTimeStep(): number;
  27555. private _tmpImpostorsArray;
  27556. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  27557. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  27558. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  27559. generatePhysicsBody(impostor: PhysicsImpostor): void;
  27560. private _tmpPositionVector;
  27561. removePhysicsBody(impostor: PhysicsImpostor): void;
  27562. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  27563. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  27564. isSupported(): boolean;
  27565. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  27566. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  27567. private _getLastShape(body);
  27568. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  27569. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  27570. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  27571. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  27572. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  27573. getBodyMass(impostor: PhysicsImpostor): number;
  27574. getBodyFriction(impostor: PhysicsImpostor): number;
  27575. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  27576. getBodyRestitution(impostor: PhysicsImpostor): number;
  27577. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  27578. sleepBody(impostor: PhysicsImpostor): void;
  27579. wakeUpBody(impostor: PhysicsImpostor): void;
  27580. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  27581. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  27582. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  27583. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  27584. getRadius(impostor: PhysicsImpostor): number;
  27585. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  27586. dispose(): void;
  27587. }
  27588. }
  27589. declare module BABYLON {
  27590. /**
  27591. * This represents a set of one or more post processes in Babylon.
  27592. * A post process can be used to apply a shader to a texture after it is rendered.
  27593. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  27594. */
  27595. class PostProcessRenderEffect {
  27596. private _postProcesses;
  27597. private _getPostProcesses;
  27598. private _singleInstance;
  27599. private _cameras;
  27600. private _indicesForCamera;
  27601. /**
  27602. * Name of the effect
  27603. */
  27604. _name: string;
  27605. /**
  27606. * Instantiates a post process render effect.
  27607. * A post process can be used to apply a shader to a texture after it is rendered.
  27608. * @param engine The engine the effect is tied to
  27609. * @param name The name of the effect
  27610. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  27611. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  27612. */
  27613. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  27614. /**
  27615. * Checks if all the post processes in the effect are supported.
  27616. */
  27617. readonly isSupported: boolean;
  27618. /**
  27619. * Updates the current state of the effect
  27620. */
  27621. _update(): void;
  27622. /**
  27623. * Attaches the effect on cameras
  27624. * @param cameras The camera to attach to.
  27625. */
  27626. _attachCameras(cameras: Camera): void;
  27627. /**
  27628. * Attaches the effect on cameras
  27629. * @param cameras The camera to attach to.
  27630. */
  27631. _attachCameras(cameras: Camera[]): void;
  27632. /**
  27633. * Detatches the effect on cameras
  27634. * @param cameras The camera to detatch from.
  27635. */
  27636. _detachCameras(cameras: Camera): void;
  27637. /**
  27638. * Detatches the effect on cameras
  27639. * @param cameras The camera to detatch from.
  27640. */
  27641. _detachCameras(cameras: Camera[]): void;
  27642. /**
  27643. * Enables the effect on given cameras
  27644. * @param cameras The camera to enable.
  27645. */
  27646. _enable(cameras: Camera): void;
  27647. /**
  27648. * Enables the effect on given cameras
  27649. * @param cameras The camera to enable.
  27650. */
  27651. _enable(cameras: Nullable<Camera[]>): void;
  27652. /**
  27653. * Disables the effect on the given cameras
  27654. * @param cameras The camera to disable.
  27655. */
  27656. _disable(cameras: Camera): void;
  27657. /**
  27658. * Disables the effect on the given cameras
  27659. * @param cameras The camera to disable.
  27660. */
  27661. _disable(cameras: Nullable<Camera[]>): void;
  27662. /**
  27663. * Gets a list of the post processes contained in the effect.
  27664. * @param camera The camera to get the post processes on.
  27665. * @returns The list of the post processes in the effect.
  27666. */
  27667. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  27668. }
  27669. }
  27670. declare module BABYLON {
  27671. class PostProcessRenderPipeline {
  27672. private engine;
  27673. private _renderEffects;
  27674. private _renderEffectsForIsolatedPass;
  27675. protected _cameras: Camera[];
  27676. _name: string;
  27677. constructor(engine: Engine, name: string);
  27678. getClassName(): string;
  27679. readonly isSupported: boolean;
  27680. addEffect(renderEffect: PostProcessRenderEffect): void;
  27681. _rebuild(): void;
  27682. _enableEffect(renderEffectName: string, cameras: Camera): void;
  27683. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  27684. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  27685. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  27686. _attachCameras(cameras: Camera, unique: boolean): void;
  27687. _attachCameras(cameras: Camera[], unique: boolean): void;
  27688. _detachCameras(cameras: Camera): void;
  27689. _detachCameras(cameras: Nullable<Camera[]>): void;
  27690. _update(): void;
  27691. _reset(): void;
  27692. protected _enableMSAAOnFirstPostProcess(): boolean;
  27693. dispose(): void;
  27694. }
  27695. }
  27696. declare module BABYLON {
  27697. class PostProcessRenderPipelineManager {
  27698. private _renderPipelines;
  27699. constructor();
  27700. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  27701. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: Camera, unique?: boolean): void;
  27702. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: Camera[], unique?: boolean): void;
  27703. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: Camera): void;
  27704. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: Camera[]): void;
  27705. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: Camera): void;
  27706. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: Camera[]): void;
  27707. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: Camera): void;
  27708. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: Camera[]): void;
  27709. update(): void;
  27710. _rebuild(): void;
  27711. dispose(): void;
  27712. }
  27713. }
  27714. declare module BABYLON {
  27715. /**
  27716. * Helper class dealing with the extraction of spherical polynomial dataArray
  27717. * from a cube map.
  27718. */
  27719. class CubeMapToSphericalPolynomialTools {
  27720. private static FileFaces;
  27721. /**
  27722. * Converts a texture to the according Spherical Polynomial data.
  27723. * This extracts the first 3 orders only as they are the only one used in the lighting.
  27724. *
  27725. * @param texture The texture to extract the information from.
  27726. * @return The Spherical Polynomial data.
  27727. */
  27728. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  27729. /**
  27730. * Converts a cubemap to the according Spherical Polynomial data.
  27731. * This extracts the first 3 orders only as they are the only one used in the lighting.
  27732. *
  27733. * @param cubeInfo The Cube map to extract the information from.
  27734. * @return The Spherical Polynomial data.
  27735. */
  27736. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  27737. }
  27738. }
  27739. declare module BABYLON {
  27740. /**
  27741. * Header information of HDR texture files.
  27742. */
  27743. interface HDRInfo {
  27744. /**
  27745. * The height of the texture in pixels.
  27746. */
  27747. height: number;
  27748. /**
  27749. * The width of the texture in pixels.
  27750. */
  27751. width: number;
  27752. /**
  27753. * The index of the beginning of the data in the binary file.
  27754. */
  27755. dataPosition: number;
  27756. }
  27757. /**
  27758. * This groups tools to convert HDR texture to native colors array.
  27759. */
  27760. class HDRTools {
  27761. private static Ldexp(mantissa, exponent);
  27762. private static Rgbe2float(float32array, red, green, blue, exponent, index);
  27763. private static readStringLine(uint8array, startIndex);
  27764. /**
  27765. * Reads header information from an RGBE texture stored in a native array.
  27766. * More information on this format are available here:
  27767. * https://en.wikipedia.org/wiki/RGBE_image_format
  27768. *
  27769. * @param uint8array The binary file stored in native array.
  27770. * @return The header information.
  27771. */
  27772. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  27773. /**
  27774. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  27775. * This RGBE texture needs to store the information as a panorama.
  27776. *
  27777. * More information on this format are available here:
  27778. * https://en.wikipedia.org/wiki/RGBE_image_format
  27779. *
  27780. * @param buffer The binary file stored in an array buffer.
  27781. * @param size The expected size of the extracted cubemap.
  27782. * @return The Cube Map information.
  27783. */
  27784. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  27785. /**
  27786. * Returns the pixels data extracted from an RGBE texture.
  27787. * This pixels will be stored left to right up to down in the R G B order in one array.
  27788. *
  27789. * More information on this format are available here:
  27790. * https://en.wikipedia.org/wiki/RGBE_image_format
  27791. *
  27792. * @param uint8array The binary file stored in an array buffer.
  27793. * @param hdrInfo The header information of the file.
  27794. * @return The pixels data in RGB right to left up to down order.
  27795. */
  27796. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  27797. private static RGBE_ReadPixels_RLE(uint8array, hdrInfo);
  27798. }
  27799. }
  27800. declare module BABYLON {
  27801. /**
  27802. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  27803. */
  27804. interface CubeMapInfo {
  27805. /**
  27806. * The pixel array for the front face.
  27807. * This is stored in format, left to right, up to down format.
  27808. */
  27809. front: Nullable<ArrayBufferView>;
  27810. /**
  27811. * The pixel array for the back face.
  27812. * This is stored in format, left to right, up to down format.
  27813. */
  27814. back: Nullable<ArrayBufferView>;
  27815. /**
  27816. * The pixel array for the left face.
  27817. * This is stored in format, left to right, up to down format.
  27818. */
  27819. left: Nullable<ArrayBufferView>;
  27820. /**
  27821. * The pixel array for the right face.
  27822. * This is stored in format, left to right, up to down format.
  27823. */
  27824. right: Nullable<ArrayBufferView>;
  27825. /**
  27826. * The pixel array for the up face.
  27827. * This is stored in format, left to right, up to down format.
  27828. */
  27829. up: Nullable<ArrayBufferView>;
  27830. /**
  27831. * The pixel array for the down face.
  27832. * This is stored in format, left to right, up to down format.
  27833. */
  27834. down: Nullable<ArrayBufferView>;
  27835. /**
  27836. * The size of the cubemap stored.
  27837. *
  27838. * Each faces will be size * size pixels.
  27839. */
  27840. size: number;
  27841. /**
  27842. * The format of the texture.
  27843. *
  27844. * RGBA, RGB.
  27845. */
  27846. format: number;
  27847. /**
  27848. * The type of the texture data.
  27849. *
  27850. * UNSIGNED_INT, FLOAT.
  27851. */
  27852. type: number;
  27853. /**
  27854. * Specifies whether the texture is in gamma space.
  27855. */
  27856. gammaSpace: boolean;
  27857. }
  27858. /**
  27859. * Helper class usefull to convert panorama picture to their cubemap representation in 6 faces.
  27860. */
  27861. class PanoramaToCubeMapTools {
  27862. private static FACE_FRONT;
  27863. private static FACE_BACK;
  27864. private static FACE_RIGHT;
  27865. private static FACE_LEFT;
  27866. private static FACE_DOWN;
  27867. private static FACE_UP;
  27868. /**
  27869. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  27870. *
  27871. * @param float32Array The source data.
  27872. * @param inputWidth The width of the input panorama.
  27873. * @param inputhHeight The height of the input panorama.
  27874. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  27875. * @return The cubemap data
  27876. */
  27877. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  27878. private static CreateCubemapTexture(texSize, faceData, float32Array, inputWidth, inputHeight);
  27879. private static CalcProjectionSpherical(vDir, float32Array, inputWidth, inputHeight);
  27880. }
  27881. }
  27882. declare module BABYLON {
  27883. class CustomProceduralTexture extends ProceduralTexture {
  27884. private _animate;
  27885. private _time;
  27886. private _config;
  27887. private _texturePath;
  27888. constructor(name: string, texturePath: any, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  27889. private loadJson(jsonUrl);
  27890. isReady(): boolean;
  27891. render(useCameraPostProcess?: boolean): void;
  27892. updateTextures(): void;
  27893. updateShaderUniforms(): void;
  27894. animate: boolean;
  27895. }
  27896. }
  27897. declare module BABYLON {
  27898. class ProceduralTexture extends Texture {
  27899. isCube: boolean;
  27900. private _size;
  27901. _generateMipMaps: boolean;
  27902. isEnabled: boolean;
  27903. private _currentRefreshId;
  27904. private _refreshRate;
  27905. onGenerated: () => void;
  27906. private _vertexBuffers;
  27907. private _indexBuffer;
  27908. private _effect;
  27909. private _uniforms;
  27910. private _samplers;
  27911. private _fragment;
  27912. _textures: {
  27913. [key: string]: Texture;
  27914. };
  27915. private _floats;
  27916. private _floatsArrays;
  27917. private _colors3;
  27918. private _colors4;
  27919. private _vectors2;
  27920. private _vectors3;
  27921. private _matrices;
  27922. private _fallbackTexture;
  27923. private _fallbackTextureUsed;
  27924. private _engine;
  27925. constructor(name: string, size: any, fragment: any, scene: Scene, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  27926. private _createIndexBuffer();
  27927. _rebuild(): void;
  27928. reset(): void;
  27929. isReady(): boolean;
  27930. resetRefreshCounter(): void;
  27931. setFragment(fragment: any): void;
  27932. refreshRate: number;
  27933. _shouldRender(): boolean;
  27934. getRenderSize(): number;
  27935. resize(size: number, generateMipMaps: boolean): void;
  27936. private _checkUniform(uniformName);
  27937. setTexture(name: string, texture: Texture): ProceduralTexture;
  27938. setFloat(name: string, value: number): ProceduralTexture;
  27939. setFloats(name: string, value: number[]): ProceduralTexture;
  27940. setColor3(name: string, value: Color3): ProceduralTexture;
  27941. setColor4(name: string, value: Color4): ProceduralTexture;
  27942. setVector2(name: string, value: Vector2): ProceduralTexture;
  27943. setVector3(name: string, value: Vector3): ProceduralTexture;
  27944. setMatrix(name: string, value: Matrix): ProceduralTexture;
  27945. render(useCameraPostProcess?: boolean): void;
  27946. clone(): ProceduralTexture;
  27947. dispose(): void;
  27948. }
  27949. }
  27950. declare module BABYLON {
  27951. /**
  27952. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  27953. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  27954. */
  27955. class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  27956. private _scene;
  27957. /**
  27958. * ID of the pass post process used for bloom,
  27959. */
  27960. readonly PassPostProcessId: string;
  27961. /**
  27962. * ID of the highlight post process used for bloom,
  27963. */
  27964. readonly HighLightsPostProcessId: string;
  27965. /**
  27966. * ID of the blurX post process used for bloom,
  27967. */
  27968. readonly BlurXPostProcessId: string;
  27969. /**
  27970. * ID of the blurY post process used for bloom,
  27971. */
  27972. readonly BlurYPostProcessId: string;
  27973. /**
  27974. * ID of the copy back post process used for bloom,
  27975. */
  27976. readonly CopyBackPostProcessId: string;
  27977. /**
  27978. * ID of the image processing post process;
  27979. */
  27980. readonly ImageProcessingPostProcessId: string;
  27981. /**
  27982. * ID of the Fast Approximate Anti-Aliasing post process;
  27983. */
  27984. readonly FxaaPostProcessId: string;
  27985. /**
  27986. * ID of the final merge post process;
  27987. */
  27988. readonly FinalMergePostProcessId: string;
  27989. /**
  27990. * First pass of bloom to capture the original image texture for later use.
  27991. */
  27992. pass: PassPostProcess;
  27993. /**
  27994. * Second pass of bloom used to brighten bright portions of the image.
  27995. */
  27996. highlights: HighlightsPostProcess;
  27997. /**
  27998. * BlurX post process used in coordination with blurY to guassian blur the highlighted image.
  27999. */
  28000. blurX: BlurPostProcess;
  28001. /**
  28002. * BlurY post process used in coordination with blurX to guassian blur the highlighted image.
  28003. */
  28004. blurY: BlurPostProcess;
  28005. /**
  28006. * Final pass run for bloom to copy the resulting bloom texture back to screen.
  28007. */
  28008. copyBack: PassPostProcess;
  28009. /**
  28010. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  28011. */
  28012. depthOfField: DepthOfFieldEffect;
  28013. /**
  28014. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  28015. */
  28016. fxaa: FxaaPostProcess;
  28017. /**
  28018. * Image post processing pass used to perform operations such as tone mapping or color grading.
  28019. */
  28020. imageProcessing: ImageProcessingPostProcess;
  28021. /**
  28022. * Final post process to merge results of all previous passes
  28023. */
  28024. finalMerge: PassPostProcess;
  28025. /**
  28026. * Animations which can be used to tweak settings over a period of time
  28027. */
  28028. animations: Animation[];
  28029. private _bloomEnabled;
  28030. private _depthOfFieldEnabled;
  28031. private _depthOfFieldBlurLevel;
  28032. private _fxaaEnabled;
  28033. private _imageProcessingEnabled;
  28034. private _defaultPipelineTextureType;
  28035. private _bloomScale;
  28036. private _buildAllowed;
  28037. /**
  28038. * Specifies the size of the bloom blur kernel, relative to the final output size
  28039. */
  28040. bloomKernel: number;
  28041. /**
  28042. * Specifies the weight of the bloom in the final rendering
  28043. */
  28044. private _bloomWeight;
  28045. private _hdr;
  28046. /**
  28047. * The strength of the bloom.
  28048. */
  28049. bloomWeight: number;
  28050. /**
  28051. * The scale of the bloom, lower value will provide better performance.
  28052. */
  28053. bloomScale: number;
  28054. /**
  28055. * Enable or disable the bloom from the pipeline
  28056. */
  28057. bloomEnabled: boolean;
  28058. /**
  28059. * If the depth of field is enabled.
  28060. */
  28061. depthOfFieldEnabled: boolean;
  28062. /**
  28063. * Blur level of the depth of field effect. (Higher blur will effect performance)
  28064. */
  28065. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  28066. /**
  28067. * If the anti aliasing is enabled.
  28068. */
  28069. fxaaEnabled: boolean;
  28070. /**
  28071. * If image processing is enabled.
  28072. */
  28073. imageProcessingEnabled: boolean;
  28074. /**
  28075. * @constructor
  28076. * @param {string} name - The rendering pipeline name
  28077. * @param {BABYLON.Scene} scene - The scene linked to this pipeline
  28078. * @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)
  28079. * @param {BABYLON.Camera[]} cameras - The array of cameras that the rendering pipeline will be attached to
  28080. * @param {boolean} automaticBuild - if false, you will have to manually call prepare() to update the pipeline
  28081. */
  28082. constructor(name: string, hdr: boolean, scene: Scene, cameras?: Camera[], automaticBuild?: boolean);
  28083. /**
  28084. * Force the compilation of the entire pipeline.
  28085. */
  28086. prepare(): void;
  28087. private _buildPipeline();
  28088. private _disposePostProcesses();
  28089. /**
  28090. * Dispose of the pipeline and stop all post processes
  28091. */
  28092. dispose(): void;
  28093. /**
  28094. * Serialize the rendering pipeline (Used when exporting)
  28095. * @returns the serialized object
  28096. */
  28097. serialize(): any;
  28098. /**
  28099. * Parse the serialized pipeline
  28100. * @param source Source pipeline.
  28101. * @param scene The scene to load the pipeline to.
  28102. * @param rootUrl The URL of the serialized pipeline.
  28103. * @returns An instantiated pipeline from the serialized object.
  28104. */
  28105. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  28106. }
  28107. }
  28108. declare module BABYLON {
  28109. class LensRenderingPipeline extends PostProcessRenderPipeline {
  28110. /**
  28111. * The chromatic aberration PostProcess id in the pipeline
  28112. * @type {string}
  28113. */
  28114. LensChromaticAberrationEffect: string;
  28115. /**
  28116. * The highlights enhancing PostProcess id in the pipeline
  28117. * @type {string}
  28118. */
  28119. HighlightsEnhancingEffect: string;
  28120. /**
  28121. * The depth-of-field PostProcess id in the pipeline
  28122. * @type {string}
  28123. */
  28124. LensDepthOfFieldEffect: string;
  28125. private _scene;
  28126. private _depthTexture;
  28127. private _grainTexture;
  28128. private _chromaticAberrationPostProcess;
  28129. private _highlightsPostProcess;
  28130. private _depthOfFieldPostProcess;
  28131. private _edgeBlur;
  28132. private _grainAmount;
  28133. private _chromaticAberration;
  28134. private _distortion;
  28135. private _highlightsGain;
  28136. private _highlightsThreshold;
  28137. private _dofDistance;
  28138. private _dofAperture;
  28139. private _dofDarken;
  28140. private _dofPentagon;
  28141. private _blurNoise;
  28142. /**
  28143. * @constructor
  28144. *
  28145. * Effect parameters are as follow:
  28146. * {
  28147. * chromatic_aberration: number; // from 0 to x (1 for realism)
  28148. * edge_blur: number; // from 0 to x (1 for realism)
  28149. * distortion: number; // from 0 to x (1 for realism)
  28150. * grain_amount: number; // from 0 to 1
  28151. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  28152. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  28153. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  28154. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  28155. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  28156. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  28157. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  28158. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  28159. * }
  28160. * Note: if an effect parameter is unset, effect is disabled
  28161. *
  28162. * @param {string} name - The rendering pipeline name
  28163. * @param {object} parameters - An object containing all parameters (see above)
  28164. * @param {BABYLON.Scene} scene - The scene linked to this pipeline
  28165. * @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)
  28166. * @param {BABYLON.Camera[]} cameras - The array of cameras that the rendering pipeline will be attached to
  28167. */
  28168. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  28169. setEdgeBlur(amount: number): void;
  28170. disableEdgeBlur(): void;
  28171. setGrainAmount(amount: number): void;
  28172. disableGrain(): void;
  28173. setChromaticAberration(amount: number): void;
  28174. disableChromaticAberration(): void;
  28175. setEdgeDistortion(amount: number): void;
  28176. disableEdgeDistortion(): void;
  28177. setFocusDistance(amount: number): void;
  28178. disableDepthOfField(): void;
  28179. setAperture(amount: number): void;
  28180. setDarkenOutOfFocus(amount: number): void;
  28181. enablePentagonBokeh(): void;
  28182. disablePentagonBokeh(): void;
  28183. enableNoiseBlur(): void;
  28184. disableNoiseBlur(): void;
  28185. setHighlightsGain(amount: number): void;
  28186. setHighlightsThreshold(amount: number): void;
  28187. disableHighlights(): void;
  28188. /**
  28189. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  28190. */
  28191. dispose(disableDepthRender?: boolean): void;
  28192. private _createChromaticAberrationPostProcess(ratio);
  28193. private _createHighlightsPostProcess(ratio);
  28194. private _createDepthOfFieldPostProcess(ratio);
  28195. private _createGrainTexture();
  28196. }
  28197. }
  28198. declare module BABYLON {
  28199. class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  28200. /**
  28201. * The PassPostProcess id in the pipeline that contains the original scene color
  28202. * @type {string}
  28203. */
  28204. SSAOOriginalSceneColorEffect: string;
  28205. /**
  28206. * The SSAO PostProcess id in the pipeline
  28207. * @type {string}
  28208. */
  28209. SSAORenderEffect: string;
  28210. /**
  28211. * The horizontal blur PostProcess id in the pipeline
  28212. * @type {string}
  28213. */
  28214. SSAOBlurHRenderEffect: string;
  28215. /**
  28216. * The vertical blur PostProcess id in the pipeline
  28217. * @type {string}
  28218. */
  28219. SSAOBlurVRenderEffect: string;
  28220. /**
  28221. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  28222. * @type {string}
  28223. */
  28224. SSAOCombineRenderEffect: string;
  28225. /**
  28226. * The output strength of the SSAO post-process. Default value is 1.0.
  28227. * @type {number}
  28228. */
  28229. totalStrength: number;
  28230. /**
  28231. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  28232. * @type {number}
  28233. */
  28234. maxZ: number;
  28235. /**
  28236. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  28237. * @type {number}
  28238. */
  28239. minZAspect: number;
  28240. /**
  28241. * Number of samples used for the SSAO calculations. Default value is 8
  28242. * @type {number}
  28243. */
  28244. private _samples;
  28245. /**
  28246. * Dynamically generated sphere sampler.
  28247. * @type {number[]}
  28248. */
  28249. private _sampleSphere;
  28250. /**
  28251. * Blur filter offsets
  28252. * @type {number[]}
  28253. */
  28254. private _samplerOffsets;
  28255. samples: number;
  28256. /**
  28257. * Are we using bilateral blur ?
  28258. * @type {boolean}
  28259. */
  28260. private _expensiveBlur;
  28261. expensiveBlur: boolean;
  28262. /**
  28263. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  28264. * @type {number}
  28265. */
  28266. radius: number;
  28267. /**
  28268. * The base color of the SSAO post-process
  28269. * The final result is "base + ssao" between [0, 1]
  28270. * @type {number}
  28271. */
  28272. base: number;
  28273. /**
  28274. * Support test.
  28275. * @type {boolean}
  28276. */
  28277. static readonly IsSupported: boolean;
  28278. private _scene;
  28279. private _depthTexture;
  28280. private _normalTexture;
  28281. private _randomTexture;
  28282. private _originalColorPostProcess;
  28283. private _ssaoPostProcess;
  28284. private _blurHPostProcess;
  28285. private _blurVPostProcess;
  28286. private _ssaoCombinePostProcess;
  28287. private _firstUpdate;
  28288. /**
  28289. * @constructor
  28290. * @param {string} name - The rendering pipeline name
  28291. * @param {BABYLON.Scene} scene - The scene linked to this pipeline
  28292. * @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 }
  28293. * @param {BABYLON.Camera[]} cameras - The array of cameras that the rendering pipeline will be attached to
  28294. */
  28295. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  28296. /**
  28297. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  28298. */
  28299. dispose(disableGeometryBufferRenderer?: boolean): void;
  28300. private _createBlurPostProcess(ssaoRatio, blurRatio);
  28301. _rebuild(): void;
  28302. private _generateHemisphere();
  28303. private _createSSAOPostProcess(ratio);
  28304. private _createSSAOCombinePostProcess(ratio);
  28305. private _createRandomTexture();
  28306. }
  28307. }
  28308. declare module BABYLON {
  28309. class SSAORenderingPipeline extends PostProcessRenderPipeline {
  28310. /**
  28311. * The PassPostProcess id in the pipeline that contains the original scene color
  28312. * @type {string}
  28313. */
  28314. SSAOOriginalSceneColorEffect: string;
  28315. /**
  28316. * The SSAO PostProcess id in the pipeline
  28317. * @type {string}
  28318. */
  28319. SSAORenderEffect: string;
  28320. /**
  28321. * The horizontal blur PostProcess id in the pipeline
  28322. * @type {string}
  28323. */
  28324. SSAOBlurHRenderEffect: string;
  28325. /**
  28326. * The vertical blur PostProcess id in the pipeline
  28327. * @type {string}
  28328. */
  28329. SSAOBlurVRenderEffect: string;
  28330. /**
  28331. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  28332. * @type {string}
  28333. */
  28334. SSAOCombineRenderEffect: string;
  28335. /**
  28336. * The output strength of the SSAO post-process. Default value is 1.0.
  28337. * @type {number}
  28338. */
  28339. totalStrength: number;
  28340. /**
  28341. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  28342. * @type {number}
  28343. */
  28344. radius: number;
  28345. /**
  28346. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  28347. * Must not be equal to fallOff and superior to fallOff.
  28348. * Default value is 0.975
  28349. * @type {number}
  28350. */
  28351. area: number;
  28352. /**
  28353. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  28354. * Must not be equal to area and inferior to area.
  28355. * Default value is 0.0
  28356. * @type {number}
  28357. */
  28358. fallOff: number;
  28359. /**
  28360. * The base color of the SSAO post-process
  28361. * The final result is "base + ssao" between [0, 1]
  28362. * @type {number}
  28363. */
  28364. base: number;
  28365. private _scene;
  28366. private _depthTexture;
  28367. private _randomTexture;
  28368. private _originalColorPostProcess;
  28369. private _ssaoPostProcess;
  28370. private _blurHPostProcess;
  28371. private _blurVPostProcess;
  28372. private _ssaoCombinePostProcess;
  28373. private _firstUpdate;
  28374. /**
  28375. * @constructor
  28376. * @param {string} name - The rendering pipeline name
  28377. * @param {BABYLON.Scene} scene - The scene linked to this pipeline
  28378. * @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 }
  28379. * @param {BABYLON.Camera[]} cameras - The array of cameras that the rendering pipeline will be attached to
  28380. */
  28381. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  28382. /**
  28383. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  28384. */
  28385. dispose(disableDepthRender?: boolean): void;
  28386. private _createBlurPostProcess(ratio);
  28387. _rebuild(): void;
  28388. private _createSSAOPostProcess(ratio);
  28389. private _createSSAOCombinePostProcess(ratio);
  28390. private _createRandomTexture();
  28391. }
  28392. }
  28393. declare module BABYLON {
  28394. class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  28395. /**
  28396. * Public members
  28397. */
  28398. originalPostProcess: Nullable<PostProcess>;
  28399. downSampleX4PostProcess: Nullable<PostProcess>;
  28400. brightPassPostProcess: Nullable<PostProcess>;
  28401. blurHPostProcesses: PostProcess[];
  28402. blurVPostProcesses: PostProcess[];
  28403. textureAdderPostProcess: Nullable<PostProcess>;
  28404. volumetricLightPostProcess: Nullable<PostProcess>;
  28405. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  28406. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  28407. volumetricLightMergePostProces: Nullable<PostProcess>;
  28408. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  28409. luminancePostProcess: Nullable<PostProcess>;
  28410. luminanceDownSamplePostProcesses: PostProcess[];
  28411. hdrPostProcess: Nullable<PostProcess>;
  28412. textureAdderFinalPostProcess: Nullable<PostProcess>;
  28413. lensFlareFinalPostProcess: Nullable<PostProcess>;
  28414. hdrFinalPostProcess: Nullable<PostProcess>;
  28415. lensFlarePostProcess: Nullable<PostProcess>;
  28416. lensFlareComposePostProcess: Nullable<PostProcess>;
  28417. motionBlurPostProcess: Nullable<PostProcess>;
  28418. depthOfFieldPostProcess: Nullable<PostProcess>;
  28419. brightThreshold: number;
  28420. blurWidth: number;
  28421. horizontalBlur: boolean;
  28422. exposure: number;
  28423. lensTexture: Nullable<Texture>;
  28424. volumetricLightCoefficient: number;
  28425. volumetricLightPower: number;
  28426. volumetricLightBlurScale: number;
  28427. sourceLight: Nullable<SpotLight | DirectionalLight>;
  28428. hdrMinimumLuminance: number;
  28429. hdrDecreaseRate: number;
  28430. hdrIncreaseRate: number;
  28431. lensColorTexture: Nullable<Texture>;
  28432. lensFlareStrength: number;
  28433. lensFlareGhostDispersal: number;
  28434. lensFlareHaloWidth: number;
  28435. lensFlareDistortionStrength: number;
  28436. lensStarTexture: Nullable<Texture>;
  28437. lensFlareDirtTexture: Nullable<Texture>;
  28438. depthOfFieldDistance: number;
  28439. depthOfFieldBlurWidth: number;
  28440. motionStrength: number;
  28441. animations: Animation[];
  28442. /**
  28443. * Private members
  28444. */
  28445. private _scene;
  28446. private _currentDepthOfFieldSource;
  28447. private _basePostProcess;
  28448. private _hdrCurrentLuminance;
  28449. private _floatTextureType;
  28450. private _ratio;
  28451. private _bloomEnabled;
  28452. private _depthOfFieldEnabled;
  28453. private _vlsEnabled;
  28454. private _lensFlareEnabled;
  28455. private _hdrEnabled;
  28456. private _motionBlurEnabled;
  28457. private _motionBlurSamples;
  28458. private _volumetricLightStepsCount;
  28459. BloomEnabled: boolean;
  28460. DepthOfFieldEnabled: boolean;
  28461. LensFlareEnabled: boolean;
  28462. HDREnabled: boolean;
  28463. VLSEnabled: boolean;
  28464. MotionBlurEnabled: boolean;
  28465. volumetricLightStepsCount: number;
  28466. motionBlurSamples: number;
  28467. /**
  28468. * @constructor
  28469. * @param {string} name - The rendering pipeline name
  28470. * @param {BABYLON.Scene} scene - The scene linked to this pipeline
  28471. * @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)
  28472. * @param {BABYLON.PostProcess} originalPostProcess - the custom original color post-process. Must be "reusable". Can be null.
  28473. * @param {BABYLON.Camera[]} cameras - The array of cameras that the rendering pipeline will be attached to
  28474. */
  28475. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  28476. private _buildPipeline();
  28477. private _createDownSampleX4PostProcess(scene, ratio);
  28478. private _createBrightPassPostProcess(scene, ratio);
  28479. private _createBlurPostProcesses(scene, ratio, indice, blurWidthKey?);
  28480. private _createTextureAdderPostProcess(scene, ratio);
  28481. private _createVolumetricLightPostProcess(scene, ratio);
  28482. private _createLuminancePostProcesses(scene, textureType);
  28483. private _createHdrPostProcess(scene, ratio);
  28484. private _createLensFlarePostProcess(scene, ratio);
  28485. private _createDepthOfFieldPostProcess(scene, ratio);
  28486. private _createMotionBlurPostProcess(scene, ratio);
  28487. private _getDepthTexture();
  28488. private _disposePostProcesses();
  28489. dispose(): void;
  28490. serialize(): any;
  28491. /**
  28492. * Static members
  28493. */
  28494. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  28495. static LuminanceSteps: number;
  28496. }
  28497. }