babylon.d.ts 1.3 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976
  1. declare module 'babylonjs' {
  2. export = BABYLON;
  3. }
  4. declare module BABYLON {
  5. /**
  6. * Set of assets to keep when moving a scene into an asset container.
  7. */
  8. class KeepAssets {
  9. /**
  10. * Cameras to keep.
  11. */
  12. cameras: Camera[];
  13. /**
  14. * Lights to keep.
  15. */
  16. lights: Light[];
  17. /**
  18. * Meshes to keep.
  19. */
  20. meshes: AbstractMesh[];
  21. /**
  22. * Skeletons to keep.
  23. */
  24. skeletons: Skeleton[];
  25. /**
  26. * ParticleSystems to keep.
  27. */
  28. particleSystems: IParticleSystem[];
  29. /**
  30. * Animations to keep.
  31. */
  32. animations: Animation[];
  33. /**
  34. * AnimationGroups to keep.
  35. */
  36. animationGroups: AnimationGroup[];
  37. /**
  38. * MultiMaterials to keep.
  39. */
  40. multiMaterials: MultiMaterial[];
  41. /**
  42. * Materials to keep.
  43. */
  44. materials: Material[];
  45. /**
  46. * MorphTargetManagers to keep.
  47. */
  48. morphTargetManagers: MorphTargetManager[];
  49. /**
  50. * Geometries to keep.
  51. */
  52. geometries: Geometry[];
  53. /**
  54. * TransformNodes to keep.
  55. */
  56. transformNodes: TransformNode[];
  57. /**
  58. * LensFlareSystems to keep.
  59. */
  60. lensFlareSystems: LensFlareSystem[];
  61. /**
  62. * ShadowGenerators to keep.
  63. */
  64. shadowGenerators: ShadowGenerator[];
  65. /**
  66. * ActionManagers to keep.
  67. */
  68. actionManagers: ActionManager[];
  69. /**
  70. * Sounds to keep.
  71. */
  72. sounds: Sound[];
  73. /**
  74. * Textures to keep.
  75. */
  76. textures: Texture[];
  77. }
  78. /**
  79. * Container with a set of assets that can be added or removed from a scene.
  80. */
  81. class AssetContainer {
  82. /**
  83. * The scene the AssetContainer belongs to.
  84. */
  85. scene: Scene;
  86. /**
  87. * Cameras populated in the container.
  88. */
  89. cameras: Camera[];
  90. /**
  91. * Lights populated in the container.
  92. */
  93. lights: Light[];
  94. /**
  95. * Meshes populated in the container.
  96. */
  97. meshes: AbstractMesh[];
  98. /**
  99. * Skeletons populated in the container.
  100. */
  101. skeletons: Skeleton[];
  102. /**
  103. * ParticleSystems populated in the container.
  104. */
  105. particleSystems: IParticleSystem[];
  106. /**
  107. * Animations populated in the container.
  108. */
  109. animations: Animation[];
  110. /**
  111. * AnimationGroups populated in the container.
  112. */
  113. animationGroups: AnimationGroup[];
  114. /**
  115. * MultiMaterials populated in the container.
  116. */
  117. multiMaterials: MultiMaterial[];
  118. /**
  119. * Materials populated in the container.
  120. */
  121. materials: Material[];
  122. /**
  123. * MorphTargetManagers populated in the container.
  124. */
  125. morphTargetManagers: MorphTargetManager[];
  126. /**
  127. * Geometries populated in the container.
  128. */
  129. geometries: Geometry[];
  130. /**
  131. * TransformNodes populated in the container.
  132. */
  133. transformNodes: TransformNode[];
  134. /**
  135. * LensFlareSystems populated in the container.
  136. */
  137. lensFlareSystems: LensFlareSystem[];
  138. /**
  139. * ShadowGenerators populated in the container.
  140. */
  141. shadowGenerators: ShadowGenerator[];
  142. /**
  143. * ActionManagers populated in the container.
  144. */
  145. actionManagers: ActionManager[];
  146. /**
  147. * Sounds populated in the container.
  148. */
  149. sounds: Sound[];
  150. /**
  151. * Textures populated in the container.
  152. */
  153. textures: Texture[];
  154. /**
  155. * Instantiates an AssetContainer.
  156. * @param scene The scene the AssetContainer belongs to.
  157. */
  158. constructor(scene: Scene);
  159. /**
  160. * Adds all the assets from the container to the scene.
  161. */
  162. addAllToScene(): void;
  163. /**
  164. * Removes all the assets in the container from the scene
  165. */
  166. removeAllFromScene(): void;
  167. private _moveAssets<T>(sourceAssets, targetAssets, keepAssets);
  168. /**
  169. * Removes all the assets contained in the scene and adds them to the container.
  170. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  171. */
  172. moveAllFromScene(keepAssets?: KeepAssets): void;
  173. }
  174. }
  175. interface Window {
  176. mozIndexedDB: IDBFactory;
  177. webkitIndexedDB: IDBFactory;
  178. msIndexedDB: IDBFactory;
  179. webkitURL: typeof URL;
  180. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  181. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  182. WebGLRenderingContext: WebGLRenderingContext;
  183. MSGesture: MSGesture;
  184. CANNON: any;
  185. AudioContext: AudioContext;
  186. webkitAudioContext: AudioContext;
  187. PointerEvent: any;
  188. Math: Math;
  189. Uint8Array: Uint8ArrayConstructor;
  190. Float32Array: Float32ArrayConstructor;
  191. mozURL: typeof URL;
  192. msURL: typeof URL;
  193. VRFrameData: any;
  194. DracoDecoderModule: any;
  195. }
  196. interface WebGLRenderingContext {
  197. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  198. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  199. vertexAttribDivisor(index: number, divisor: number): void;
  200. createVertexArray(): any;
  201. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  202. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  203. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  204. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  205. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  206. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  207. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  208. createQuery(): WebGLQuery;
  209. deleteQuery(query: WebGLQuery): void;
  210. beginQuery(target: number, query: WebGLQuery): void;
  211. endQuery(target: number): void;
  212. getQueryParameter(query: WebGLQuery, pname: number): any;
  213. getQuery(target: number, pname: number): any;
  214. MAX_SAMPLES: number;
  215. RGBA8: number;
  216. READ_FRAMEBUFFER: number;
  217. DRAW_FRAMEBUFFER: number;
  218. UNIFORM_BUFFER: number;
  219. HALF_FLOAT_OES: number;
  220. RGBA16F: number;
  221. RGBA32F: number;
  222. R32F: number;
  223. RG32F: number;
  224. RGB32F: number;
  225. RED: number;
  226. RG: number;
  227. UNSIGNED_INT_24_8: number;
  228. DEPTH24_STENCIL8: number;
  229. drawBuffers(buffers: number[]): void;
  230. readBuffer(src: number): void;
  231. readonly COLOR_ATTACHMENT0: number;
  232. readonly COLOR_ATTACHMENT1: number;
  233. readonly COLOR_ATTACHMENT2: number;
  234. readonly COLOR_ATTACHMENT3: number;
  235. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  236. ANY_SAMPLES_PASSED: number;
  237. QUERY_RESULT_AVAILABLE: number;
  238. QUERY_RESULT: number;
  239. }
  240. interface Document {
  241. mozCancelFullScreen(): void;
  242. msCancelFullScreen(): void;
  243. mozFullScreen: boolean;
  244. msIsFullScreen: boolean;
  245. fullscreen: boolean;
  246. mozPointerLockElement: HTMLElement;
  247. msPointerLockElement: HTMLElement;
  248. webkitPointerLockElement: HTMLElement;
  249. }
  250. interface HTMLCanvasElement {
  251. msRequestPointerLock?(): void;
  252. mozRequestPointerLock?(): void;
  253. webkitRequestPointerLock?(): void;
  254. }
  255. interface CanvasRenderingContext2D {
  256. msImageSmoothingEnabled: boolean;
  257. }
  258. interface WebGLBuffer {
  259. references: number;
  260. capacity: number;
  261. is32Bits: boolean;
  262. }
  263. interface WebGLProgram {
  264. transformFeedback?: WebGLTransformFeedback | null;
  265. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  266. }
  267. interface MouseEvent {
  268. mozMovementX: number;
  269. mozMovementY: number;
  270. webkitMovementX: number;
  271. webkitMovementY: number;
  272. msMovementX: number;
  273. msMovementY: number;
  274. }
  275. interface Navigator {
  276. mozGetVRDevices: (any: any) => any;
  277. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  278. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  279. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  280. webkitGetGamepads(): Gamepad[];
  281. msGetGamepads(): Gamepad[];
  282. webkitGamepads(): Gamepad[];
  283. }
  284. interface HTMLVideoElement {
  285. mozSrcObject: any;
  286. }
  287. interface Screen {
  288. orientation: string;
  289. mozOrientation: string;
  290. }
  291. interface Math {
  292. fround(x: number): number;
  293. imul(a: number, b: number): number;
  294. }
  295. interface GamepadPose {
  296. hasOrientation: boolean;
  297. hasPosition: boolean;
  298. position?: Float32Array;
  299. linearVelocity?: Float32Array;
  300. linearAcceleration?: Float32Array;
  301. orientation?: Float32Array;
  302. angularVelocity?: Float32Array;
  303. angularAcceleration?: Float32Array;
  304. }
  305. interface EXT_disjoint_timer_query {
  306. QUERY_COUNTER_BITS_EXT: number;
  307. TIME_ELAPSED_EXT: number;
  308. TIMESTAMP_EXT: number;
  309. GPU_DISJOINT_EXT: number;
  310. QUERY_RESULT_EXT: number;
  311. QUERY_RESULT_AVAILABLE_EXT: number;
  312. queryCounterEXT(query: WebGLQuery, target: number): void;
  313. createQueryEXT(): WebGLQuery;
  314. beginQueryEXT(target: number, query: WebGLQuery): void;
  315. endQueryEXT(target: number): void;
  316. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  317. deleteQueryEXT(query: WebGLQuery): void;
  318. }
  319. interface WebGLUniformLocation {
  320. _currentState: any;
  321. }
  322. declare module BABYLON {
  323. /**
  324. * Node is the basic class for all scene objects (Mesh, Light Camera).
  325. */
  326. class Node {
  327. /**
  328. * Gets or sets the name of the node
  329. */
  330. name: string;
  331. /**
  332. * Gets or sets the id of the node
  333. */
  334. id: string;
  335. /**
  336. * Gets or sets the unique id of the node
  337. */
  338. uniqueId: number;
  339. /**
  340. * Gets or sets a string used to store user defined state for the node
  341. */
  342. state: string;
  343. /**
  344. * Gets or sets an object used to store user defined information for the node
  345. */
  346. metadata: any;
  347. /**
  348. * Gets or sets a boolean used to define if the node must be serialized
  349. */
  350. doNotSerialize: boolean;
  351. /** @ignore */
  352. _isDisposed: boolean;
  353. /**
  354. * Gets a list of {BABYLON.Animation} associated with the node
  355. */
  356. animations: Animation[];
  357. private _ranges;
  358. /**
  359. * Callback raised when the node is ready to be used
  360. */
  361. onReady: (node: Node) => void;
  362. private _isEnabled;
  363. private _isReady;
  364. /** @ignore */
  365. _currentRenderId: number;
  366. private _parentRenderId;
  367. protected _childRenderId: number;
  368. /** @ignore */
  369. _waitingParentId: Nullable<string>;
  370. private _scene;
  371. /** @ignore */
  372. _cache: any;
  373. private _parentNode;
  374. private _children;
  375. /**
  376. * Gets a boolean indicating if the node has been disposed
  377. * @returns true if the node was disposed
  378. */
  379. isDisposed(): boolean;
  380. /**
  381. * Gets or sets the parent of the node
  382. */
  383. parent: Nullable<Node>;
  384. private _animationPropertiesOverride;
  385. /**
  386. * Gets or sets the animation properties override
  387. */
  388. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  389. /**
  390. * Gets a string idenfifying the name of the class
  391. * @returns "Node" string
  392. */
  393. getClassName(): string;
  394. /**
  395. * An event triggered when the mesh is disposed
  396. */
  397. onDisposeObservable: Observable<Node>;
  398. private _onDisposeObserver;
  399. /**
  400. * Sets a callback that will be raised when the node will be disposed
  401. */
  402. onDispose: () => void;
  403. /**
  404. * Creates a new Node
  405. * @param {string} name - the name and id to be given to this node
  406. * @param {BABYLON.Scene} the scene this node will be added to
  407. */
  408. constructor(name: string, scene?: Nullable<Scene>);
  409. /**
  410. * Gets the scene of the node
  411. * @returns a {BABYLON.Scene}
  412. */
  413. getScene(): Scene;
  414. /**
  415. * Gets the engine of the node
  416. * @returns a {BABYLON.Engine}
  417. */
  418. getEngine(): Engine;
  419. private _behaviors;
  420. /**
  421. * Attach a behavior to the node
  422. * @see http://doc.babylonjs.com/features/behaviour
  423. * @param behavior defines the behavior to attach
  424. * @returns the current Node
  425. */
  426. addBehavior(behavior: Behavior<Node>): Node;
  427. /**
  428. * Remove an attached behavior
  429. * @see http://doc.babylonjs.com/features/behaviour
  430. * @param behavior defines the behavior to attach
  431. * @returns the current Node
  432. */
  433. removeBehavior(behavior: Behavior<Node>): Node;
  434. /**
  435. * Gets the list of attached behaviors
  436. * @see http://doc.babylonjs.com/features/behaviour
  437. */
  438. readonly behaviors: Behavior<Node>[];
  439. /**
  440. * Gets an attached behavior by name
  441. * @param name defines the name of the behavior to look for
  442. * @see http://doc.babylonjs.com/features/behaviour
  443. * @returns null if behavior was not found else the requested behavior
  444. */
  445. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  446. /**
  447. * Returns the world matrix of the node
  448. * @returns a matrix containing the node's world matrix
  449. */
  450. getWorldMatrix(): Matrix;
  451. /** @ignore */
  452. _initCache(): void;
  453. /** @ignore */
  454. updateCache(force?: boolean): void;
  455. /** @ignore */
  456. _updateCache(ignoreParentClass?: boolean): void;
  457. /** @ignore */
  458. _isSynchronized(): boolean;
  459. /** @ignore */
  460. _markSyncedWithParent(): void;
  461. /** @ignore */
  462. isSynchronizedWithParent(): boolean;
  463. /** @ignore */
  464. isSynchronized(updateCache?: boolean): boolean;
  465. /** @ignore */
  466. hasNewParent(update?: boolean): boolean;
  467. /**
  468. * Is this node ready to be used/rendered
  469. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  470. * @return true if the node is ready
  471. */
  472. isReady(completeCheck?: boolean): boolean;
  473. /**
  474. * Is this node enabled?
  475. * 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
  476. * @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
  477. * @return whether this node (and its parent) is enabled
  478. */
  479. isEnabled(checkAncestors?: boolean): boolean;
  480. /**
  481. * Set the enabled state of this node
  482. * @param value defines the new enabled state
  483. */
  484. setEnabled(value: boolean): void;
  485. /**
  486. * Is this node a descendant of the given node?
  487. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  488. * @param ancestor defines the parent node to inspect
  489. * @returns a boolean indicating if this node is a descendant of the given node
  490. */
  491. isDescendantOf(ancestor: Node): boolean;
  492. /** @ignore */
  493. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  494. /**
  495. * Will return all nodes that have this node as ascendant
  496. * @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
  497. * @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
  498. * @return all children nodes of all types
  499. */
  500. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  501. /**
  502. * Get all child-meshes of this node
  503. * @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
  504. * @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
  505. * @returns an array of {BABYLON.AbstractMesh}
  506. */
  507. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  508. /**
  509. * Get all child-transformNodes of this node
  510. * @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
  511. * @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
  512. * @returns an array of {BABYLON.TransformNode}
  513. */
  514. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  515. /**
  516. * Get all direct children of this node
  517. * @param predicate defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored
  518. * @returns an array of {BABYLON.Node}
  519. */
  520. getChildren(predicate?: (node: Node) => boolean): Node[];
  521. /** @ignore */
  522. _setReady(state: boolean): void;
  523. /**
  524. * Get an animation by name
  525. * @param name defines the name of the animation to look for
  526. * @returns null if not found else the requested animation
  527. */
  528. getAnimationByName(name: string): Nullable<Animation>;
  529. /**
  530. * Creates an animation range for this node
  531. * @param name defines the name of the range
  532. * @param from defines the starting key
  533. * @param to defines the end key
  534. */
  535. createAnimationRange(name: string, from: number, to: number): void;
  536. /**
  537. * Delete a specific animation range
  538. * @param name defines the name of the range to delete
  539. * @param deleteFrames defines if animation frames from the range must be deleted as well
  540. */
  541. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  542. /**
  543. * Get an animation range by name
  544. * @param name defines the name of the animation range to look for
  545. * @returns null if not found else the requested animation range
  546. */
  547. getAnimationRange(name: string): Nullable<AnimationRange>;
  548. /**
  549. * Will start the animation sequence
  550. * @param name defines the range frames for animation sequence
  551. * @param loop defines if the animation should loop (false by default)
  552. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  553. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  554. * @returns the object created for this animation. If range does not exist, it will return null
  555. */
  556. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  557. /**
  558. * Serialize animation ranges into a JSON compatible object
  559. * @returns serialization object
  560. */
  561. serializeAnimationRanges(): any;
  562. /**
  563. * Computes the world matrix of the node
  564. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  565. * @returns the world matrix
  566. */
  567. computeWorldMatrix(force?: boolean): Matrix;
  568. /**
  569. * Releases resources associated with this node.
  570. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  571. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  572. */
  573. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  574. /**
  575. * Parse animation range data from a serialization object and store them into a given node
  576. * @param node defines where to store the animation ranges
  577. * @param parsedNode defines the serialization object to read data from
  578. * @param scene defines the hosting scene
  579. */
  580. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  581. }
  582. }
  583. declare module BABYLON {
  584. interface IDisposable {
  585. dispose(): void;
  586. }
  587. interface IActiveMeshCandidateProvider {
  588. getMeshes(scene: Scene): AbstractMesh[];
  589. readonly checksIsEnabled: boolean;
  590. }
  591. /**
  592. * This class is used by the onRenderingGroupObservable
  593. */
  594. class RenderingGroupInfo {
  595. /**
  596. * The Scene that being rendered
  597. */
  598. scene: Scene;
  599. /**
  600. * The camera currently used for the rendering pass
  601. */
  602. camera: Nullable<Camera>;
  603. /**
  604. * The ID of the renderingGroup being processed
  605. */
  606. renderingGroupId: number;
  607. /**
  608. * The rendering stage, can be either STAGE_PRECLEAR, STAGE_PREOPAQUE, STAGE_PRETRANSPARENT, STAGE_POSTTRANSPARENT
  609. */
  610. renderStage: number;
  611. /**
  612. * Stage corresponding to the very first hook in the renderingGroup phase: before the render buffer may be cleared
  613. * This stage will be fired no matter what
  614. */
  615. static STAGE_PRECLEAR: number;
  616. /**
  617. * Called before opaque object are rendered.
  618. * This stage will be fired only if there's 3D Opaque content to render
  619. */
  620. static STAGE_PREOPAQUE: number;
  621. /**
  622. * Called after the opaque objects are rendered and before the transparent ones
  623. * This stage will be fired only if there's 3D transparent content to render
  624. */
  625. static STAGE_PRETRANSPARENT: number;
  626. /**
  627. * Called after the transparent object are rendered, last hook of the renderingGroup phase
  628. * This stage will be fired no matter what
  629. */
  630. static STAGE_POSTTRANSPARENT: number;
  631. }
  632. /**
  633. * Represents a scene to be rendered by the engine.
  634. * @see http://doc.babylonjs.com/features/scene
  635. */
  636. class Scene implements IAnimatable {
  637. private static _FOGMODE_NONE;
  638. private static _FOGMODE_EXP;
  639. private static _FOGMODE_EXP2;
  640. private static _FOGMODE_LINEAR;
  641. private static _uniqueIdCounter;
  642. static MinDeltaTime: number;
  643. static MaxDeltaTime: number;
  644. /** The fog is deactivated */
  645. static readonly FOGMODE_NONE: number;
  646. /** The fog density is following an exponential function */
  647. static readonly FOGMODE_EXP: number;
  648. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  649. static readonly FOGMODE_EXP2: number;
  650. /** The fog density is following a linear function. */
  651. static readonly FOGMODE_LINEAR: number;
  652. autoClear: boolean;
  653. autoClearDepthAndStencil: boolean;
  654. clearColor: Color4;
  655. ambientColor: Color3;
  656. _environmentBRDFTexture: BaseTexture;
  657. protected _environmentTexture: BaseTexture;
  658. /**
  659. * Texture used in all pbr material as the reflection texture.
  660. * As in the majority of the scene they are the same (exception for multi room and so on),
  661. * this is easier to reference from here than from all the materials.
  662. */
  663. /**
  664. * Texture used in all pbr material as the reflection texture.
  665. * As in the majority of the scene they are the same (exception for multi room and so on),
  666. * this is easier to set here than in all the materials.
  667. */
  668. environmentTexture: BaseTexture;
  669. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  670. /**
  671. * Default image processing configuration used either in the rendering
  672. * Forward main pass or through the imageProcessingPostProcess if present.
  673. * As in the majority of the scene they are the same (exception for multi camera),
  674. * this is easier to reference from here than from all the materials and post process.
  675. *
  676. * No setter as we it is a shared configuration, you can set the values instead.
  677. */
  678. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  679. private _forceWireframe;
  680. forceWireframe: boolean;
  681. private _forcePointsCloud;
  682. forcePointsCloud: boolean;
  683. forceShowBoundingBoxes: boolean;
  684. clipPlane: Nullable<Plane>;
  685. animationsEnabled: boolean;
  686. useConstantAnimationDeltaTime: boolean;
  687. constantlyUpdateMeshUnderPointer: boolean;
  688. hoverCursor: string;
  689. defaultCursor: string;
  690. /**
  691. * This is used to call preventDefault() on pointer down
  692. * in order to block unwanted artifacts like system double clicks
  693. */
  694. preventDefaultOnPointerDown: boolean;
  695. metadata: any;
  696. loadingPluginName: string;
  697. /**
  698. * Use this array to add regular expressions used to disable offline support for specific urls
  699. */
  700. disableOfflineSupportExceptionRules: RegExp[];
  701. private _spritePredicate;
  702. /**
  703. * An event triggered when the scene is disposed.
  704. */
  705. onDisposeObservable: Observable<Scene>;
  706. private _onDisposeObserver;
  707. /** A function to be executed when this scene is disposed. */
  708. onDispose: () => void;
  709. /**
  710. * An event triggered before rendering the scene (right after animations and physics)
  711. */
  712. onBeforeRenderObservable: Observable<Scene>;
  713. private _onBeforeRenderObserver;
  714. /** A function to be executed before rendering this scene */
  715. beforeRender: Nullable<() => void>;
  716. /**
  717. * An event triggered after rendering the scene
  718. */
  719. onAfterRenderObservable: Observable<Scene>;
  720. private _onAfterRenderObserver;
  721. /** A function to be executed after rendering this scene */
  722. afterRender: Nullable<() => void>;
  723. /**
  724. * An event triggered before animating the scene
  725. */
  726. onBeforeAnimationsObservable: Observable<Scene>;
  727. /**
  728. * An event triggered after animations processing
  729. */
  730. onAfterAnimationsObservable: Observable<Scene>;
  731. /**
  732. * An event triggered before draw calls are ready to be sent
  733. */
  734. onBeforeDrawPhaseObservable: Observable<Scene>;
  735. /**
  736. * An event triggered after draw calls have been sent
  737. */
  738. onAfterDrawPhaseObservable: Observable<Scene>;
  739. /**
  740. * An event triggered when physic simulation is about to be run
  741. */
  742. onBeforePhysicsObservable: Observable<Scene>;
  743. /**
  744. * An event triggered when physic simulation has been done
  745. */
  746. onAfterPhysicsObservable: Observable<Scene>;
  747. /**
  748. * An event triggered when the scene is ready
  749. */
  750. onReadyObservable: Observable<Scene>;
  751. /**
  752. * An event triggered before rendering a camera
  753. */
  754. onBeforeCameraRenderObservable: Observable<Camera>;
  755. private _onBeforeCameraRenderObserver;
  756. beforeCameraRender: () => void;
  757. /**
  758. * An event triggered after rendering a camera
  759. */
  760. onAfterCameraRenderObservable: Observable<Camera>;
  761. private _onAfterCameraRenderObserver;
  762. afterCameraRender: () => void;
  763. /**
  764. * An event triggered when active meshes evaluation is about to start
  765. */
  766. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  767. /**
  768. * An event triggered when active meshes evaluation is done
  769. */
  770. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  771. /**
  772. * An event triggered when particles rendering is about to start
  773. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  774. */
  775. onBeforeParticlesRenderingObservable: Observable<Scene>;
  776. /**
  777. * An event triggered when particles rendering is done
  778. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  779. */
  780. onAfterParticlesRenderingObservable: Observable<Scene>;
  781. /**
  782. * An event triggered when sprites rendering is about to start
  783. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  784. */
  785. onBeforeSpritesRenderingObservable: Observable<Scene>;
  786. /**
  787. * An event triggered when sprites rendering is done
  788. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  789. */
  790. onAfterSpritesRenderingObservable: Observable<Scene>;
  791. /**
  792. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  793. */
  794. onDataLoadedObservable: Observable<Scene>;
  795. /**
  796. * An event triggered when a camera is created
  797. */
  798. onNewCameraAddedObservable: Observable<Camera>;
  799. /**
  800. * An event triggered when a camera is removed
  801. */
  802. onCameraRemovedObservable: Observable<Camera>;
  803. /**
  804. * An event triggered when a light is created
  805. */
  806. onNewLightAddedObservable: Observable<Light>;
  807. /**
  808. * An event triggered when a light is removed
  809. */
  810. onLightRemovedObservable: Observable<Light>;
  811. /**
  812. * An event triggered when a geometry is created
  813. */
  814. onNewGeometryAddedObservable: Observable<Geometry>;
  815. /**
  816. * An event triggered when a geometry is removed
  817. */
  818. onGeometryRemovedObservable: Observable<Geometry>;
  819. /**
  820. * An event triggered when a transform node is created
  821. */
  822. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  823. /**
  824. * An event triggered when a transform node is removed
  825. */
  826. onTransformNodeRemovedObservable: Observable<TransformNode>;
  827. /**
  828. * An event triggered when a mesh is created
  829. */
  830. onNewMeshAddedObservable: Observable<AbstractMesh>;
  831. /**
  832. * An event triggered when a mesh is removed
  833. */
  834. onMeshRemovedObservable: Observable<AbstractMesh>;
  835. /**
  836. * An event triggered when render targets are about to be rendered
  837. * Can happen multiple times per frame.
  838. */
  839. OnBeforeRenderTargetsRenderObservable: Observable<Scene>;
  840. /**
  841. * An event triggered when render targets were rendered.
  842. * Can happen multiple times per frame.
  843. */
  844. OnAfterRenderTargetsRenderObservable: Observable<Scene>;
  845. /**
  846. * An event triggered before calculating deterministic simulation step
  847. */
  848. onBeforeStepObservable: Observable<Scene>;
  849. /**
  850. * An event triggered after calculating deterministic simulation step
  851. */
  852. onAfterStepObservable: Observable<Scene>;
  853. /**
  854. * This Observable will be triggered for each stage of each renderingGroup of each rendered camera.
  855. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  856. * 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)
  857. */
  858. onRenderingGroupObservable: Observable<RenderingGroupInfo>;
  859. animations: Animation[];
  860. private _registeredForLateAnimationBindings;
  861. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  862. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  863. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  864. private _onPointerMove;
  865. private _onPointerDown;
  866. private _onPointerUp;
  867. /** Deprecated. Use onPointerObservable instead */
  868. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  869. /** Deprecated. Use onPointerObservable instead */
  870. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  871. /** Deprecated. Use onPointerObservable instead */
  872. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  873. /** Deprecated. Use onPointerObservable instead */
  874. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  875. private _gamepadManager;
  876. readonly gamepadManager: GamepadManager;
  877. /**
  878. * 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).
  879. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  880. */
  881. onPrePointerObservable: Observable<PointerInfoPre>;
  882. /**
  883. * Observable event triggered each time an input event is received from the rendering canvas
  884. */
  885. onPointerObservable: Observable<PointerInfo>;
  886. readonly unTranslatedPointer: Vector2;
  887. /** The distance in pixel that you have to move to prevent some events */
  888. static DragMovementThreshold: number;
  889. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  890. static LongPressDelay: number;
  891. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  892. static DoubleClickDelay: number;
  893. /** If you need to check double click without raising a single click at first click, enable this flag */
  894. static ExclusiveDoubleClickMode: boolean;
  895. private _initClickEvent;
  896. private _initActionManager;
  897. private _delayedSimpleClick;
  898. private _delayedSimpleClickTimeout;
  899. private _previousDelayedSimpleClickTimeout;
  900. private _meshPickProceed;
  901. private _previousButtonPressed;
  902. private _currentPickResult;
  903. private _previousPickResult;
  904. private _totalPointersPressed;
  905. private _doubleClickOccured;
  906. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  907. cameraToUseForPointers: Nullable<Camera>;
  908. private _pointerX;
  909. private _pointerY;
  910. private _unTranslatedPointerX;
  911. private _unTranslatedPointerY;
  912. private _startingPointerPosition;
  913. private _previousStartingPointerPosition;
  914. private _startingPointerTime;
  915. private _previousStartingPointerTime;
  916. private _timeAccumulator;
  917. private _currentStepId;
  918. private _currentInternalStep;
  919. _mirroredCameraPosition: Nullable<Vector3>;
  920. /**
  921. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  922. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  923. */
  924. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  925. /**
  926. * Observable event triggered each time an keyboard event is received from the hosting window
  927. */
  928. onKeyboardObservable: Observable<KeyboardInfo>;
  929. private _onKeyDown;
  930. private _onKeyUp;
  931. private _onCanvasFocusObserver;
  932. private _onCanvasBlurObserver;
  933. /**
  934. * use right-handed coordinate system on this scene.
  935. */
  936. private _useRightHandedSystem;
  937. useRightHandedSystem: boolean;
  938. setStepId(newStepId: number): void;
  939. getStepId(): number;
  940. getInternalStep(): number;
  941. private _fogEnabled;
  942. /**
  943. * is fog enabled on this scene.
  944. */
  945. fogEnabled: boolean;
  946. private _fogMode;
  947. fogMode: number;
  948. fogColor: Color3;
  949. fogDensity: number;
  950. fogStart: number;
  951. fogEnd: number;
  952. /**
  953. * is shadow enabled on this scene.
  954. */
  955. private _shadowsEnabled;
  956. shadowsEnabled: boolean;
  957. /**
  958. * is light enabled on this scene.
  959. */
  960. private _lightsEnabled;
  961. lightsEnabled: boolean;
  962. /**
  963. * All of the lights added to this scene.
  964. */
  965. lights: Light[];
  966. /** All of the cameras added to this scene. */
  967. cameras: Camera[];
  968. /** All of the active cameras added to this scene. */
  969. activeCameras: Camera[];
  970. /** The current active camera */
  971. activeCamera: Nullable<Camera>;
  972. /**
  973. * All of the tranform nodes added to this scene.
  974. */
  975. transformNodes: TransformNode[];
  976. /**
  977. * All of the (abstract) meshes added to this scene.
  978. */
  979. meshes: AbstractMesh[];
  980. /**
  981. * All of the animation groups added to this scene.
  982. */
  983. animationGroups: AnimationGroup[];
  984. private _geometries;
  985. materials: Material[];
  986. multiMaterials: MultiMaterial[];
  987. private _defaultMaterial;
  988. /** The default material used on meshes when no material is affected */
  989. /** The default material used on meshes when no material is affected */
  990. defaultMaterial: Material;
  991. private _texturesEnabled;
  992. texturesEnabled: boolean;
  993. textures: BaseTexture[];
  994. particlesEnabled: boolean;
  995. particleSystems: IParticleSystem[];
  996. spritesEnabled: boolean;
  997. spriteManagers: SpriteManager[];
  998. /**
  999. * The list of layers (background and foreground) of the scene.
  1000. */
  1001. layers: Layer[];
  1002. /**
  1003. * The list of effect layers (highlights/glow) contained in the scene.
  1004. */
  1005. effectLayers: EffectLayer[];
  1006. private _skeletonsEnabled;
  1007. skeletonsEnabled: boolean;
  1008. skeletons: Skeleton[];
  1009. morphTargetManagers: MorphTargetManager[];
  1010. lensFlaresEnabled: boolean;
  1011. lensFlareSystems: LensFlareSystem[];
  1012. collisionsEnabled: boolean;
  1013. private _workerCollisions;
  1014. collisionCoordinator: ICollisionCoordinator;
  1015. /** Defines the gravity applied to this scene */
  1016. gravity: Vector3;
  1017. postProcesses: PostProcess[];
  1018. postProcessesEnabled: boolean;
  1019. postProcessManager: PostProcessManager;
  1020. private _postProcessRenderPipelineManager;
  1021. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  1022. renderTargetsEnabled: boolean;
  1023. dumpNextRenderTargets: boolean;
  1024. customRenderTargets: RenderTargetTexture[];
  1025. useDelayedTextureLoading: boolean;
  1026. importedMeshesFiles: String[];
  1027. probesEnabled: boolean;
  1028. reflectionProbes: ReflectionProbe[];
  1029. database: Database;
  1030. /**
  1031. * This scene's action manager
  1032. */
  1033. actionManager: ActionManager;
  1034. _actionManagers: ActionManager[];
  1035. private _meshesForIntersections;
  1036. proceduralTexturesEnabled: boolean;
  1037. _proceduralTextures: ProceduralTexture[];
  1038. private _mainSoundTrack;
  1039. soundTracks: SoundTrack[];
  1040. private _audioEnabled;
  1041. private _headphone;
  1042. readonly mainSoundTrack: SoundTrack;
  1043. VRHelper: VRExperienceHelper;
  1044. simplificationQueue: SimplificationQueue;
  1045. private _engine;
  1046. private _totalVertices;
  1047. _activeIndices: PerfCounter;
  1048. _activeParticles: PerfCounter;
  1049. _activeBones: PerfCounter;
  1050. private _animationRatio;
  1051. private _animationTimeLast;
  1052. private _animationTime;
  1053. animationTimeScale: number;
  1054. _cachedMaterial: Nullable<Material>;
  1055. _cachedEffect: Nullable<Effect>;
  1056. _cachedVisibility: Nullable<number>;
  1057. private _renderId;
  1058. private _executeWhenReadyTimeoutId;
  1059. private _intermediateRendering;
  1060. private _viewUpdateFlag;
  1061. private _projectionUpdateFlag;
  1062. private _alternateViewUpdateFlag;
  1063. private _alternateProjectionUpdateFlag;
  1064. _toBeDisposed: SmartArray<Nullable<IDisposable>>;
  1065. private _activeRequests;
  1066. private _pendingData;
  1067. private _isDisposed;
  1068. dispatchAllSubMeshesOfActiveMeshes: boolean;
  1069. private _activeMeshes;
  1070. private _processedMaterials;
  1071. private _renderTargets;
  1072. _activeParticleSystems: SmartArray<IParticleSystem>;
  1073. private _activeSkeletons;
  1074. private _softwareSkinnedMeshes;
  1075. private _renderingManager;
  1076. private _physicsEngine;
  1077. _activeAnimatables: Animatable[];
  1078. private _transformMatrix;
  1079. private _sceneUbo;
  1080. private _alternateSceneUbo;
  1081. private _pickWithRayInverseMatrix;
  1082. private _boundingBoxRenderer;
  1083. private _outlineRenderer;
  1084. private _viewMatrix;
  1085. private _projectionMatrix;
  1086. private _alternateViewMatrix;
  1087. private _alternateProjectionMatrix;
  1088. private _alternateTransformMatrix;
  1089. private _useAlternateCameraConfiguration;
  1090. private _alternateRendering;
  1091. _forcedViewPosition: Nullable<Vector3>;
  1092. readonly _isAlternateRenderingEnabled: boolean;
  1093. private _frustumPlanes;
  1094. readonly frustumPlanes: Plane[];
  1095. requireLightSorting: boolean;
  1096. private _selectionOctree;
  1097. private _pointerOverMesh;
  1098. private _pointerOverSprite;
  1099. private _debugLayer;
  1100. private _depthRenderer;
  1101. private _geometryBufferRenderer;
  1102. /**
  1103. * Gets the current geometry buffer associated to the scene.
  1104. */
  1105. /**
  1106. * Sets the current geometry buffer for the scene.
  1107. */
  1108. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  1109. private _pickedDownMesh;
  1110. private _pickedUpMesh;
  1111. private _pickedDownSprite;
  1112. private _externalData;
  1113. private _uid;
  1114. /**
  1115. * @constructor
  1116. * @param {BABYLON.Engine} engine - the engine to be used to render this scene.
  1117. */
  1118. constructor(engine: Engine);
  1119. readonly debugLayer: DebugLayer;
  1120. workerCollisions: boolean;
  1121. readonly selectionOctree: Octree<AbstractMesh>;
  1122. /**
  1123. * The mesh that is currently under the pointer.
  1124. * @return {BABYLON.AbstractMesh} mesh under the pointer/mouse cursor or null if none.
  1125. */
  1126. readonly meshUnderPointer: Nullable<AbstractMesh>;
  1127. /**
  1128. * Current on-screen X position of the pointer
  1129. * @return {number} X position of the pointer
  1130. */
  1131. readonly pointerX: number;
  1132. /**
  1133. * Current on-screen Y position of the pointer
  1134. * @return {number} Y position of the pointer
  1135. */
  1136. readonly pointerY: number;
  1137. getCachedMaterial(): Nullable<Material>;
  1138. getCachedEffect(): Nullable<Effect>;
  1139. getCachedVisibility(): Nullable<number>;
  1140. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  1141. getBoundingBoxRenderer(): BoundingBoxRenderer;
  1142. getOutlineRenderer(): OutlineRenderer;
  1143. getEngine(): Engine;
  1144. getTotalVertices(): number;
  1145. readonly totalVerticesPerfCounter: PerfCounter;
  1146. getActiveIndices(): number;
  1147. readonly totalActiveIndicesPerfCounter: PerfCounter;
  1148. getActiveParticles(): number;
  1149. readonly activeParticlesPerfCounter: PerfCounter;
  1150. getActiveBones(): number;
  1151. readonly activeBonesPerfCounter: PerfCounter;
  1152. getInterFramePerfCounter(): number;
  1153. readonly interFramePerfCounter: Nullable<PerfCounter>;
  1154. getLastFrameDuration(): number;
  1155. readonly lastFramePerfCounter: Nullable<PerfCounter>;
  1156. getEvaluateActiveMeshesDuration(): number;
  1157. readonly evaluateActiveMeshesDurationPerfCounter: Nullable<PerfCounter>;
  1158. getActiveMeshes(): SmartArray<AbstractMesh>;
  1159. getRenderTargetsDuration(): number;
  1160. getRenderDuration(): number;
  1161. readonly renderDurationPerfCounter: Nullable<PerfCounter>;
  1162. getParticlesDuration(): number;
  1163. readonly particlesDurationPerfCounter: Nullable<PerfCounter>;
  1164. getSpritesDuration(): number;
  1165. readonly spriteDuractionPerfCounter: Nullable<PerfCounter>;
  1166. getAnimationRatio(): number;
  1167. getRenderId(): number;
  1168. incrementRenderId(): void;
  1169. private _updatePointerPosition(evt);
  1170. private _createUbo();
  1171. private _createAlternateUbo();
  1172. /**
  1173. * Use this method to simulate a pointer move on a mesh
  1174. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  1175. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  1176. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  1177. */
  1178. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  1179. private _processPointerMove(pickResult, evt);
  1180. /**
  1181. * Use this method to simulate a pointer down on a mesh
  1182. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  1183. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  1184. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  1185. */
  1186. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  1187. private _processPointerDown(pickResult, evt);
  1188. /**
  1189. * Use this method to simulate a pointer up on a mesh
  1190. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  1191. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  1192. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  1193. */
  1194. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  1195. private _processPointerUp(pickResult, evt, clickInfo);
  1196. /**
  1197. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  1198. * @param attachUp defines if you want to attach events to pointerup
  1199. * @param attachDown defines if you want to attach events to pointerdown
  1200. * @param attachMove defines if you want to attach events to pointermove
  1201. */
  1202. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  1203. detachControl(): void;
  1204. /**
  1205. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  1206. * Delay loaded resources are not taking in account
  1207. * @return true if all required resources are ready
  1208. */
  1209. isReady(): boolean;
  1210. resetCachedMaterial(): void;
  1211. registerBeforeRender(func: () => void): void;
  1212. unregisterBeforeRender(func: () => void): void;
  1213. registerAfterRender(func: () => void): void;
  1214. unregisterAfterRender(func: () => void): void;
  1215. private _executeOnceBeforeRender(func);
  1216. /**
  1217. * The provided function will run before render once and will be disposed afterwards.
  1218. * A timeout delay can be provided so that the function will be executed in N ms.
  1219. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  1220. * @param func The function to be executed.
  1221. * @param timeout optional delay in ms
  1222. */
  1223. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  1224. _addPendingData(data: any): void;
  1225. _removePendingData(data: any): void;
  1226. getWaitingItemsCount(): number;
  1227. readonly isLoading: boolean;
  1228. /**
  1229. * Registers a function to be executed when the scene is ready.
  1230. * @param {Function} func - the function to be executed.
  1231. */
  1232. executeWhenReady(func: () => void): void;
  1233. /**
  1234. * Returns a promise that resolves when the scene is ready.
  1235. * @returns A promise that resolves when the scene is ready.
  1236. */
  1237. whenReadyAsync(): Promise<void>;
  1238. _checkIsReady(): void;
  1239. /**
  1240. * Will start the animation sequence of a given target
  1241. * @param target defines the target
  1242. * @param from defines from which frame should animation start
  1243. * @param to defines until which frame should animation run.
  1244. * @param weight defines the weight to apply to the animation (1.0 by default)
  1245. * @param loop defines if the animation loops
  1246. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  1247. * @param onAnimationEnd defines the function to be executed when the animation ends
  1248. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  1249. * @returns the animatable object created for this animation
  1250. */
  1251. beginWeightedAnimation(target: any, from: number, to: number, weight?: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable): Animatable;
  1252. /**
  1253. * Will start the animation sequence of a given target
  1254. * @param target defines the target
  1255. * @param from defines from which frame should animation start
  1256. * @param to defines until which frame should animation run.
  1257. * @param loop defines if the animation loops
  1258. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  1259. * @param onAnimationEnd defines the function to be executed when the animation ends
  1260. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  1261. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  1262. * @returns the animatable object created for this animation
  1263. */
  1264. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean): Animatable;
  1265. /**
  1266. * Begin a new animation on a given node
  1267. * @param {BABYLON.Node} node defines the root node where the animation will take place
  1268. * @param {BABYLON.Animation[]} defines the list of animations to start
  1269. * @param {number} from defines the initial value
  1270. * @param {number} to defines the final value
  1271. * @param {boolean} loop defines if you want animation to loop (off by default)
  1272. * @param {number} speedRatio defines the speed ratio to apply to all animations
  1273. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  1274. * @returns the list of created animatables
  1275. */
  1276. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Animatable;
  1277. /**
  1278. * Begin a new animation on a given node and its hierarchy
  1279. * @param {BABYLON.Node} node defines the root node where the animation will take place
  1280. * @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.
  1281. * @param {BABYLON.Animation[]} defines the list of animations to start
  1282. * @param {number} from defines the initial value
  1283. * @param {number} to defines the final value
  1284. * @param {boolean} loop defines if you want animation to loop (off by default)
  1285. * @param {number} speedRatio defines the speed ratio to apply to all animations
  1286. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  1287. * @returns the list of animatables created for all nodes
  1288. */
  1289. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Animatable[];
  1290. getAnimatableByTarget(target: any): Nullable<Animatable>;
  1291. /**
  1292. * Gets all animatables associated with a given target
  1293. * @param target defines the target to look animatables for
  1294. * @returns an array of Animatables
  1295. */
  1296. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  1297. readonly animatables: Animatable[];
  1298. /**
  1299. * Will stop the animation of the given target
  1300. * @param target - the target
  1301. * @param animationName - the name of the animation to stop (all animations will be stopped if empty)
  1302. */
  1303. stopAnimation(target: any, animationName?: string): void;
  1304. /**
  1305. * Stops and removes all animations that have been applied to the scene
  1306. */
  1307. stopAllAnimations(): void;
  1308. private _animate();
  1309. /** @ignore */
  1310. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation): void;
  1311. private _processLateAnimationBindings();
  1312. _switchToAlternateCameraConfiguration(active: boolean): void;
  1313. getViewMatrix(): Matrix;
  1314. getProjectionMatrix(): Matrix;
  1315. getTransformMatrix(): Matrix;
  1316. setTransformMatrix(view: Matrix, projection: Matrix): void;
  1317. _setAlternateTransformMatrix(view: Matrix, projection: Matrix): void;
  1318. getSceneUniformBuffer(): UniformBuffer;
  1319. getUniqueId(): number;
  1320. addMesh(newMesh: AbstractMesh): void;
  1321. removeMesh(toRemove: AbstractMesh): number;
  1322. addTransformNode(newTransformNode: TransformNode): void;
  1323. removeTransformNode(toRemove: TransformNode): number;
  1324. removeSkeleton(toRemove: Skeleton): number;
  1325. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  1326. removeLight(toRemove: Light): number;
  1327. removeCamera(toRemove: Camera): number;
  1328. removeParticleSystem(toRemove: IParticleSystem): number;
  1329. removeAnimation(toRemove: Animation): number;
  1330. /**
  1331. * Removes the given animation group from this scene.
  1332. * @param toRemove The animation group to remove
  1333. * @returns The index of the removed animation group
  1334. */
  1335. removeAnimationGroup(toRemove: AnimationGroup): number;
  1336. removeMultiMaterial(toRemove: MultiMaterial): number;
  1337. removeMaterial(toRemove: Material): number;
  1338. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  1339. removeActionManager(toRemove: ActionManager): number;
  1340. /**
  1341. * Removes the given texture from this scene.
  1342. * @param toRemove The texture to remove
  1343. * @returns The index of the removed texture
  1344. */
  1345. removeTexture(toRemove: BaseTexture): number;
  1346. addLight(newLight: Light): void;
  1347. sortLightsByPriority(): void;
  1348. addCamera(newCamera: Camera): void;
  1349. addSkeleton(newSkeleton: Skeleton): void;
  1350. addParticleSystem(newParticleSystem: IParticleSystem): void;
  1351. addAnimation(newAnimation: Animation): void;
  1352. /**
  1353. * Adds the given animation group to this scene.
  1354. * @param newAnimationGroup The animation group to add
  1355. */
  1356. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  1357. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  1358. addMaterial(newMaterial: Material): void;
  1359. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  1360. addGeometry(newGeometrie: Geometry): void;
  1361. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  1362. addActionManager(newActionManager: ActionManager): void;
  1363. /**
  1364. * Adds the given texture to this scene.
  1365. * @param newTexture The texture to add
  1366. */
  1367. addTexture(newTexture: BaseTexture): void;
  1368. /**
  1369. * Switch active camera
  1370. * @param {Camera} newCamera - new active camera
  1371. * @param {boolean} attachControl - call attachControl for the new active camera (default: true)
  1372. */
  1373. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  1374. /**
  1375. * sets the active camera of the scene using its ID
  1376. * @param {string} id - the camera's ID
  1377. * @return {BABYLON.Camera|null} the new active camera or null if none found.
  1378. */
  1379. setActiveCameraByID(id: string): Nullable<Camera>;
  1380. /**
  1381. * sets the active camera of the scene using its name
  1382. * @param {string} name - the camera's name
  1383. * @return {BABYLON.Camera|null} the new active camera or null if none found.
  1384. */
  1385. setActiveCameraByName(name: string): Nullable<Camera>;
  1386. /**
  1387. * get an animation group using its name
  1388. * @param {string} the material's name
  1389. * @return {BABYLON.AnimationGroup|null} the animation group or null if none found.
  1390. */
  1391. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  1392. /**
  1393. * get a material using its id
  1394. * @param {string} the material's ID
  1395. * @return {BABYLON.Material|null} the material or null if none found.
  1396. */
  1397. getMaterialByID(id: string): Nullable<Material>;
  1398. /**
  1399. * get a material using its name
  1400. * @param {string} the material's name
  1401. * @return {BABYLON.Material|null} the material or null if none found.
  1402. */
  1403. getMaterialByName(name: string): Nullable<Material>;
  1404. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  1405. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  1406. getCameraByID(id: string): Nullable<Camera>;
  1407. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  1408. /**
  1409. * get a camera using its name
  1410. * @param {string} the camera's name
  1411. * @return {BABYLON.Camera|null} the camera or null if none found.
  1412. */
  1413. getCameraByName(name: string): Nullable<Camera>;
  1414. /**
  1415. * get a bone using its id
  1416. * @param {string} the bone's id
  1417. * @return {BABYLON.Bone|null} the bone or null if not found
  1418. */
  1419. getBoneByID(id: string): Nullable<Bone>;
  1420. /**
  1421. * get a bone using its id
  1422. * @param {string} the bone's name
  1423. * @return {BABYLON.Bone|null} the bone or null if not found
  1424. */
  1425. getBoneByName(name: string): Nullable<Bone>;
  1426. /**
  1427. * get a light node using its name
  1428. * @param {string} the light's name
  1429. * @return {BABYLON.Light|null} the light or null if none found.
  1430. */
  1431. getLightByName(name: string): Nullable<Light>;
  1432. /**
  1433. * get a light node using its ID
  1434. * @param {string} the light's id
  1435. * @return {BABYLON.Light|null} the light or null if none found.
  1436. */
  1437. getLightByID(id: string): Nullable<Light>;
  1438. /**
  1439. * get a light node using its scene-generated unique ID
  1440. * @param {number} the light's unique id
  1441. * @return {BABYLON.Light|null} the light or null if none found.
  1442. */
  1443. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  1444. /**
  1445. * get a particle system by id
  1446. * @param id {number} the particle system id
  1447. * @return {BABYLON.IParticleSystem|null} the corresponding system or null if none found.
  1448. */
  1449. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  1450. /**
  1451. * get a geometry using its ID
  1452. * @param {string} the geometry's id
  1453. * @return {BABYLON.Geometry|null} the geometry or null if none found.
  1454. */
  1455. getGeometryByID(id: string): Nullable<Geometry>;
  1456. /**
  1457. * add a new geometry to this scene.
  1458. * @param {BABYLON.Geometry} geometry - the geometry to be added to the scene.
  1459. * @param {boolean} [force] - force addition, even if a geometry with this ID already exists
  1460. * @return {boolean} was the geometry added or not
  1461. */
  1462. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  1463. /**
  1464. * Removes an existing geometry
  1465. * @param {BABYLON.Geometry} geometry - the geometry to be removed from the scene.
  1466. * @return {boolean} was the geometry removed or not
  1467. */
  1468. removeGeometry(geometry: Geometry): boolean;
  1469. getGeometries(): Geometry[];
  1470. /**
  1471. * Get the first added mesh found of a given ID
  1472. * @param {string} id - the id to search for
  1473. * @return {BABYLON.AbstractMesh|null} the mesh found or null if not found at all.
  1474. */
  1475. getMeshByID(id: string): Nullable<AbstractMesh>;
  1476. getMeshesByID(id: string): Array<AbstractMesh>;
  1477. /**
  1478. * Get the first added transform node found of a given ID
  1479. * @param {string} id - the id to search for
  1480. * @return {BABYLON.TransformNode|null} the transform node found or null if not found at all.
  1481. */
  1482. getTransformNodeByID(id: string): Nullable<TransformNode>;
  1483. getTransformNodesByID(id: string): Array<TransformNode>;
  1484. /**
  1485. * Get a mesh with its auto-generated unique id
  1486. * @param {number} uniqueId - the unique id to search for
  1487. * @return {BABYLON.AbstractMesh|null} the mesh found or null if not found at all.
  1488. */
  1489. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  1490. /**
  1491. * Get a the last added mesh found of a given ID
  1492. * @param {string} id - the id to search for
  1493. * @return {BABYLON.AbstractMesh|null} the mesh found or null if not found at all.
  1494. */
  1495. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  1496. /**
  1497. * Get a the last added node (Mesh, Camera, Light) found of a given ID
  1498. * @param {string} id - the id to search for
  1499. * @return {BABYLON.Node|null} the node found or null if not found at all.
  1500. */
  1501. getLastEntryByID(id: string): Nullable<Node>;
  1502. getNodeByID(id: string): Nullable<Node>;
  1503. getNodeByName(name: string): Nullable<Node>;
  1504. getMeshByName(name: string): Nullable<AbstractMesh>;
  1505. getTransformNodeByName(name: string): Nullable<TransformNode>;
  1506. getSoundByName(name: string): Nullable<Sound>;
  1507. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  1508. getSkeletonById(id: string): Nullable<Skeleton>;
  1509. getSkeletonByName(name: string): Nullable<Skeleton>;
  1510. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  1511. isActiveMesh(mesh: AbstractMesh): boolean;
  1512. /**
  1513. * Return a the first highlight layer of the scene with a given name.
  1514. * @param name The name of the highlight layer to look for.
  1515. * @return The highlight layer if found otherwise null.
  1516. */
  1517. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  1518. /**
  1519. * Return a the first highlight layer of the scene with a given name.
  1520. * @param name The name of the highlight layer to look for.
  1521. * @return The highlight layer if found otherwise null.
  1522. */
  1523. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  1524. /**
  1525. * Return a unique id as a string which can serve as an identifier for the scene
  1526. */
  1527. readonly uid: string;
  1528. /**
  1529. * Add an externaly attached data from its key.
  1530. * This method call will fail and return false, if such key already exists.
  1531. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  1532. * @param key the unique key that identifies the data
  1533. * @param data the data object to associate to the key for this Engine instance
  1534. * @return true if no such key were already present and the data was added successfully, false otherwise
  1535. */
  1536. addExternalData<T>(key: string, data: T): boolean;
  1537. /**
  1538. * Get an externaly attached data from its key
  1539. * @param key the unique key that identifies the data
  1540. * @return the associated data, if present (can be null), or undefined if not present
  1541. */
  1542. getExternalData<T>(key: string): Nullable<T>;
  1543. /**
  1544. * Get an externaly attached data from its key, create it using a factory if it's not already present
  1545. * @param key the unique key that identifies the data
  1546. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  1547. * @return the associated data, can be null if the factory returned null.
  1548. */
  1549. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  1550. /**
  1551. * Remove an externaly attached data from the Engine instance
  1552. * @param key the unique key that identifies the data
  1553. * @return true if the data was successfully removed, false if it doesn't exist
  1554. */
  1555. removeExternalData(key: string): boolean;
  1556. private _evaluateSubMesh(subMesh, mesh);
  1557. /**
  1558. * Clear the processed materials smart array preventing retention point in material dispose.
  1559. */
  1560. freeProcessedMaterials(): void;
  1561. /**
  1562. * Clear the active meshes smart array preventing retention point in mesh dispose.
  1563. */
  1564. freeActiveMeshes(): void;
  1565. /**
  1566. * Clear the info related to rendering groups preventing retention points during dispose.
  1567. */
  1568. freeRenderingGroups(): void;
  1569. _isInIntermediateRendering(): boolean;
  1570. private _activeMeshCandidateProvider;
  1571. setActiveMeshCandidateProvider(provider: IActiveMeshCandidateProvider): void;
  1572. getActiveMeshCandidateProvider(): IActiveMeshCandidateProvider;
  1573. private _activeMeshesFrozen;
  1574. /**
  1575. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  1576. */
  1577. freezeActiveMeshes(): Scene;
  1578. /**
  1579. * Use this function to restart evaluating active meshes on every frame
  1580. */
  1581. unfreezeActiveMeshes(): this;
  1582. private _evaluateActiveMeshes();
  1583. private _activeMesh(sourceMesh, mesh);
  1584. updateTransformMatrix(force?: boolean): void;
  1585. updateAlternateTransformMatrix(alternateCamera: Camera): void;
  1586. private _renderForCamera(camera, rigParent?);
  1587. private _processSubCameras(camera);
  1588. private _checkIntersections();
  1589. render(): void;
  1590. private _updateAudioParameters();
  1591. audioEnabled: boolean;
  1592. private _disableAudio();
  1593. private _enableAudio();
  1594. headphone: boolean;
  1595. private _switchAudioModeForHeadphones();
  1596. private _switchAudioModeForNormalSpeakers();
  1597. /**
  1598. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  1599. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  1600. * @returns the created depth renderer
  1601. */
  1602. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  1603. /**
  1604. * Disables a depth renderer for a given camera
  1605. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  1606. */
  1607. disableDepthRenderer(camera?: Nullable<Camera>): void;
  1608. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  1609. disableGeometryBufferRenderer(): void;
  1610. freezeMaterials(): void;
  1611. unfreezeMaterials(): void;
  1612. dispose(): void;
  1613. readonly isDisposed: boolean;
  1614. disposeSounds(): void;
  1615. /**
  1616. * Get the world extend vectors with an optional filter
  1617. *
  1618. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  1619. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  1620. */
  1621. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  1622. min: Vector3;
  1623. max: Vector3;
  1624. };
  1625. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  1626. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  1627. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  1628. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  1629. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  1630. private _internalPick(rayFunction, predicate?, fastCheck?);
  1631. private _internalMultiPick(rayFunction, predicate?);
  1632. private _internalPickSprites(ray, predicate?, fastCheck?, camera?);
  1633. private _tempPickingRay;
  1634. /** Launch a ray to try to pick a mesh in the scene
  1635. * @param x position on screen
  1636. * @param y position on screen
  1637. * @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
  1638. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  1639. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  1640. */
  1641. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  1642. /** Launch a ray to try to pick a sprite in the scene
  1643. * @param x position on screen
  1644. * @param y position on screen
  1645. * @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
  1646. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  1647. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  1648. */
  1649. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  1650. private _cachedRayForTransform;
  1651. /** Use the given ray to pick a mesh in the scene
  1652. * @param ray The ray to use to pick meshes
  1653. * @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
  1654. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  1655. */
  1656. pickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  1657. /**
  1658. * Launch a ray to try to pick a mesh in the scene
  1659. * @param x X position on screen
  1660. * @param y Y position on screen
  1661. * @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
  1662. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  1663. */
  1664. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  1665. /**
  1666. * Launch a ray to try to pick a mesh in the scene
  1667. * @param ray Ray to use
  1668. * @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
  1669. */
  1670. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean): Nullable<PickingInfo[]>;
  1671. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  1672. getPointerOverMesh(): Nullable<AbstractMesh>;
  1673. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  1674. getPointerOverSprite(): Nullable<Sprite>;
  1675. getPhysicsEngine(): Nullable<PhysicsEngine>;
  1676. /**
  1677. * Enables physics to the current scene
  1678. * @param {BABYLON.Vector3} [gravity] - the scene's gravity for the physics engine
  1679. * @param {BABYLON.IPhysicsEnginePlugin} [plugin] - The physics engine to be used. defaults to OimoJS.
  1680. * @return {boolean} was the physics engine initialized
  1681. */
  1682. enablePhysics(gravity?: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  1683. disablePhysicsEngine(): void;
  1684. isPhysicsEnabled(): boolean;
  1685. deleteCompoundImpostor(compound: any): void;
  1686. _rebuildGeometries(): void;
  1687. _rebuildTextures(): void;
  1688. /**
  1689. * Creates a default light for the scene.
  1690. * @param replace Whether to replace the existing lights in the scene.
  1691. */
  1692. createDefaultLight(replace?: boolean): void;
  1693. /**
  1694. * Creates a default camera for the scene.
  1695. * @param createArcRotateCamera Whether to create an arc rotate or a free camera.
  1696. * @param replace Whether to replace the existing active camera in the scene.
  1697. * @param attachCameraControls Whether to attach camera controls to the canvas.
  1698. */
  1699. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  1700. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  1701. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number): Nullable<Mesh>;
  1702. createDefaultEnvironment(options: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  1703. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  1704. private _getByTags(list, tagsQuery, forEach?);
  1705. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  1706. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  1707. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  1708. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  1709. /**
  1710. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  1711. * This allowed control for front to back rendering or reversly depending of the special needs.
  1712. *
  1713. * @param renderingGroupId The rendering group id corresponding to its index
  1714. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  1715. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  1716. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  1717. */
  1718. 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;
  1719. /**
  1720. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  1721. *
  1722. * @param renderingGroupId The rendering group id corresponding to its index
  1723. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  1724. * @param depth Automatically clears depth between groups if true and autoClear is true.
  1725. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  1726. */
  1727. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  1728. /**
  1729. * Will flag all materials as dirty to trigger new shader compilation
  1730. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  1731. */
  1732. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  1733. _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;
  1734. /** @ignore */
  1735. _loadFileAsync(url: string, useDatabase?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  1736. }
  1737. }
  1738. declare module BABYLON {
  1739. type Nullable<T> = T | null;
  1740. type float = number;
  1741. type double = number;
  1742. type int = number;
  1743. type FloatArray = number[] | Float32Array;
  1744. type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  1745. }
  1746. declare module BABYLON {
  1747. /**
  1748. * The action to be carried out following a trigger
  1749. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  1750. */
  1751. class Action {
  1752. triggerOptions: any;
  1753. /**
  1754. * Trigger for the action
  1755. */
  1756. trigger: number;
  1757. /**
  1758. * Internal only - manager for action
  1759. * @ignore
  1760. */
  1761. _actionManager: ActionManager;
  1762. private _nextActiveAction;
  1763. private _child;
  1764. private _condition?;
  1765. private _triggerParameter;
  1766. /**
  1767. * An event triggered prior to action being executed.
  1768. */
  1769. onBeforeExecuteObservable: Observable<Action>;
  1770. /**
  1771. * Creates a new Action
  1772. * @param triggerOptions the trigger, with or without parameters, for the action
  1773. * @param condition an optional determinant of action
  1774. */
  1775. constructor(triggerOptions: any, condition?: Condition);
  1776. /**
  1777. * Internal only
  1778. * @ignore
  1779. */
  1780. _prepare(): void;
  1781. /**
  1782. * Gets the trigger parameters
  1783. * @returns the trigger parameters
  1784. */
  1785. getTriggerParameter(): any;
  1786. /**
  1787. * Internal only - executes current action event
  1788. * @ignore
  1789. */
  1790. _executeCurrent(evt?: ActionEvent): void;
  1791. /**
  1792. * Execute placeholder for child classes
  1793. * @param evt optional action event
  1794. */
  1795. execute(evt?: ActionEvent): void;
  1796. /**
  1797. * Skips to next active action
  1798. */
  1799. skipToNextActiveAction(): void;
  1800. /**
  1801. * Adds action to chain of actions, may be a DoNothingAction
  1802. * @param index The index of the attribute.
  1803. * @returns The action passed in
  1804. * @see https://www.babylonjs-playground.com/#1T30HR#0
  1805. */
  1806. then(action: Action): Action;
  1807. /**
  1808. * Internal only
  1809. * @ignore
  1810. */
  1811. _getProperty(propertyPath: string): string;
  1812. /**
  1813. * Internal only
  1814. * @ignore
  1815. */
  1816. _getEffectiveTarget(target: any, propertyPath: string): any;
  1817. /**
  1818. * Serialize placeholder for child classes
  1819. * @param parent of child
  1820. * @returns the serialized object
  1821. */
  1822. serialize(parent: any): any;
  1823. /**
  1824. * Internal only called by serialize
  1825. * @ignore
  1826. */
  1827. protected _serialize(serializedAction: any, parent?: any): any;
  1828. /**
  1829. * Internal only
  1830. * @ignore
  1831. */
  1832. static _SerializeValueAsString: (value: any) => string;
  1833. /**
  1834. * Internal only
  1835. * @ignore
  1836. */
  1837. static _GetTargetProperty: (target: Scene | Node) => {
  1838. name: string;
  1839. targetType: string;
  1840. value: string;
  1841. };
  1842. }
  1843. }
  1844. declare module BABYLON {
  1845. /**
  1846. * ActionEvent is the event being sent when an action is triggered.
  1847. */
  1848. class ActionEvent {
  1849. source: any;
  1850. pointerX: number;
  1851. pointerY: number;
  1852. meshUnderPointer: Nullable<AbstractMesh>;
  1853. sourceEvent: any;
  1854. additionalData: any;
  1855. /**
  1856. * @param source The mesh or sprite that triggered the action.
  1857. * @param pointerX The X mouse cursor position at the time of the event
  1858. * @param pointerY The Y mouse cursor position at the time of the event
  1859. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  1860. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  1861. */
  1862. constructor(source: any, pointerX: number, pointerY: number, meshUnderPointer: Nullable<AbstractMesh>, sourceEvent?: any, additionalData?: any);
  1863. /**
  1864. * Helper function to auto-create an ActionEvent from a source mesh.
  1865. * @param source The source mesh that triggered the event
  1866. * @param evt {Event} The original (browser) event
  1867. */
  1868. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  1869. /**
  1870. * Helper function to auto-create an ActionEvent from a source mesh.
  1871. * @param source The source sprite that triggered the event
  1872. * @param scene Scene associated with the sprite
  1873. * @param evt {Event} The original (browser) event
  1874. */
  1875. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  1876. /**
  1877. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  1878. * @param scene the scene where the event occurred
  1879. * @param evt {Event} The original (browser) event
  1880. */
  1881. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  1882. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  1883. }
  1884. /**
  1885. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  1886. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  1887. */
  1888. class ActionManager {
  1889. private static _NothingTrigger;
  1890. private static _OnPickTrigger;
  1891. private static _OnLeftPickTrigger;
  1892. private static _OnRightPickTrigger;
  1893. private static _OnCenterPickTrigger;
  1894. private static _OnPickDownTrigger;
  1895. private static _OnDoublePickTrigger;
  1896. private static _OnPickUpTrigger;
  1897. private static _OnLongPressTrigger;
  1898. private static _OnPointerOverTrigger;
  1899. private static _OnPointerOutTrigger;
  1900. private static _OnEveryFrameTrigger;
  1901. private static _OnIntersectionEnterTrigger;
  1902. private static _OnIntersectionExitTrigger;
  1903. private static _OnKeyDownTrigger;
  1904. private static _OnKeyUpTrigger;
  1905. private static _OnPickOutTrigger;
  1906. static readonly NothingTrigger: number;
  1907. static readonly OnPickTrigger: number;
  1908. static readonly OnLeftPickTrigger: number;
  1909. static readonly OnRightPickTrigger: number;
  1910. static readonly OnCenterPickTrigger: number;
  1911. static readonly OnPickDownTrigger: number;
  1912. static readonly OnDoublePickTrigger: number;
  1913. static readonly OnPickUpTrigger: number;
  1914. static readonly OnPickOutTrigger: number;
  1915. static readonly OnLongPressTrigger: number;
  1916. static readonly OnPointerOverTrigger: number;
  1917. static readonly OnPointerOutTrigger: number;
  1918. static readonly OnEveryFrameTrigger: number;
  1919. static readonly OnIntersectionEnterTrigger: number;
  1920. static readonly OnIntersectionExitTrigger: number;
  1921. static readonly OnKeyDownTrigger: number;
  1922. static readonly OnKeyUpTrigger: number;
  1923. static Triggers: {
  1924. [key: string]: number;
  1925. };
  1926. actions: Action[];
  1927. hoverCursor: string;
  1928. private _scene;
  1929. constructor(scene: Scene);
  1930. dispose(): void;
  1931. getScene(): Scene;
  1932. /**
  1933. * Does this action manager handles actions of any of the given triggers
  1934. * @param {number[]} triggers - the triggers to be tested
  1935. * @return {boolean} whether one (or more) of the triggers is handeled
  1936. */
  1937. hasSpecificTriggers(triggers: number[]): boolean;
  1938. /**
  1939. * Does this action manager handles actions of a given trigger
  1940. * @param {number} trigger - the trigger to be tested
  1941. * @return {boolean} whether the trigger is handeled
  1942. */
  1943. hasSpecificTrigger(trigger: number): boolean;
  1944. /**
  1945. * Does this action manager has pointer triggers
  1946. * @return {boolean} whether or not it has pointer triggers
  1947. */
  1948. readonly hasPointerTriggers: boolean;
  1949. /**
  1950. * Does this action manager has pick triggers
  1951. * @return {boolean} whether or not it has pick triggers
  1952. */
  1953. readonly hasPickTriggers: boolean;
  1954. /**
  1955. * Does exist one action manager with at least one trigger
  1956. * @return {boolean} whether or not it exists one action manager with one trigger
  1957. **/
  1958. static readonly HasTriggers: boolean;
  1959. /**
  1960. * Does exist one action manager with at least one pick trigger
  1961. * @return {boolean} whether or not it exists one action manager with one pick trigger
  1962. **/
  1963. static readonly HasPickTriggers: boolean;
  1964. /**
  1965. * Does exist one action manager that handles actions of a given trigger
  1966. * @param {number} trigger - the trigger to be tested
  1967. * @return {boolean} whether the trigger is handeled by at least one action manager
  1968. **/
  1969. static HasSpecificTrigger(trigger: number): boolean;
  1970. /**
  1971. * Registers an action to this action manager
  1972. * @param {BABYLON.Action} action - the action to be registered
  1973. * @return {BABYLON.Action} the action amended (prepared) after registration
  1974. */
  1975. registerAction(action: Action): Nullable<Action>;
  1976. /**
  1977. * Unregisters an action to this action manager
  1978. * @param action The action to be unregistered
  1979. * @return whether the action has been unregistered
  1980. */
  1981. unregisterAction(action: Action): Boolean;
  1982. /**
  1983. * Process a specific trigger
  1984. * @param {number} trigger - the trigger to process
  1985. * @param evt {BABYLON.ActionEvent} the event details to be processed
  1986. */
  1987. processTrigger(trigger: number, evt?: ActionEvent): void;
  1988. _getEffectiveTarget(target: any, propertyPath: string): any;
  1989. _getProperty(propertyPath: string): string;
  1990. serialize(name: string): any;
  1991. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  1992. static GetTriggerName(trigger: number): string;
  1993. }
  1994. }
  1995. declare module BABYLON {
  1996. /**
  1997. * A Condition applied to an Action
  1998. */
  1999. class Condition {
  2000. /**
  2001. * Internal only - manager for action
  2002. * @ignore
  2003. */
  2004. _actionManager: ActionManager;
  2005. /**
  2006. * Internal only
  2007. * @ignore
  2008. */
  2009. _evaluationId: number;
  2010. /**
  2011. * Internal only
  2012. * @ignore
  2013. */
  2014. _currentResult: boolean;
  2015. /**
  2016. * Creates a new Condition
  2017. * @param actionManager the manager of the action the condition is applied to
  2018. */
  2019. constructor(actionManager: ActionManager);
  2020. /**
  2021. * Check if the current condition is valid
  2022. * @returns a boolean
  2023. */
  2024. isValid(): boolean;
  2025. /**
  2026. * Internal only
  2027. * @ignore
  2028. */
  2029. _getProperty(propertyPath: string): string;
  2030. /**
  2031. * Internal only
  2032. * @ignore
  2033. */
  2034. _getEffectiveTarget(target: any, propertyPath: string): any;
  2035. /**
  2036. * Serialize placeholder for child classes
  2037. * @returns the serialized object
  2038. */
  2039. serialize(): any;
  2040. /**
  2041. * Internal only
  2042. * @ignore
  2043. */
  2044. protected _serialize(serializedCondition: any): any;
  2045. }
  2046. /**
  2047. * Defines specific conditional operators as extensions of Condition
  2048. */
  2049. class ValueCondition extends Condition {
  2050. propertyPath: string;
  2051. value: any;
  2052. operator: number;
  2053. /**
  2054. * Internal only
  2055. * @ignore
  2056. */
  2057. private static _IsEqual;
  2058. /**
  2059. * Internal only
  2060. * @ignore
  2061. */
  2062. private static _IsDifferent;
  2063. /**
  2064. * Internal only
  2065. * @ignore
  2066. */
  2067. private static _IsGreater;
  2068. /**
  2069. * Internal only
  2070. * @ignore
  2071. */
  2072. private static _IsLesser;
  2073. /**
  2074. * returns the number for IsEqual
  2075. */
  2076. static readonly IsEqual: number;
  2077. /**
  2078. * Returns the number for IsDifferent
  2079. */
  2080. static readonly IsDifferent: number;
  2081. /**
  2082. * Returns the number for IsGreater
  2083. */
  2084. static readonly IsGreater: number;
  2085. /**
  2086. * Returns the number for IsLesser
  2087. */
  2088. static readonly IsLesser: number;
  2089. /**
  2090. * Internal only The action manager for the condition
  2091. * @ignore
  2092. */
  2093. _actionManager: ActionManager;
  2094. /**
  2095. * Internal only
  2096. * @ignore
  2097. */
  2098. private _target;
  2099. /**
  2100. * Internal only
  2101. * @ignore
  2102. */
  2103. private _effectiveTarget;
  2104. /**
  2105. * Internal only
  2106. * @ignore
  2107. */
  2108. private _property;
  2109. /**
  2110. * Creates a new ValueCondition
  2111. * @param actionManager manager for the action the condition applies to
  2112. * @param target for the action
  2113. * @param propertyPath path to specify the property of the target the conditional operator uses
  2114. * @param value the vale compared by the conditional operator against the current value of the property
  2115. * @param operator the conditional operator, default {BABYLON.ValueCondition.IsEqual}
  2116. */
  2117. constructor(actionManager: ActionManager, target: any, propertyPath: string, value: any, operator?: number);
  2118. /**
  2119. * Compares the given value with the property value for the specified conditional operator
  2120. * @returns the result of the comparison
  2121. */
  2122. isValid(): boolean;
  2123. /**
  2124. * Serialize the ValueCondition into a JSON compatible object
  2125. * @returns serialization object
  2126. */
  2127. serialize(): any;
  2128. /**
  2129. * Gets the name of the conditional operator for the ValueCondition
  2130. * @param operator the conditional operator
  2131. * @returns the name
  2132. */
  2133. static GetOperatorName(operator: number): string;
  2134. }
  2135. /**
  2136. * Defines a predicate condition as an extension of Condition
  2137. */
  2138. class PredicateCondition extends Condition {
  2139. predicate: () => boolean;
  2140. /**
  2141. * Internal only - manager for action
  2142. * @ignore
  2143. */
  2144. _actionManager: ActionManager;
  2145. /**
  2146. * Creates a new {BABYLON.PredicateCondition}
  2147. * @param actionManager manager for the action the condition applies to
  2148. * @param predicate
  2149. */
  2150. constructor(actionManager: ActionManager, predicate: () => boolean);
  2151. /**
  2152. * @returns the validity of the predicate condition
  2153. */
  2154. isValid(): boolean;
  2155. }
  2156. /**
  2157. * Defines a state condition as an extension of {BABYLON.Condition}
  2158. */
  2159. class StateCondition extends Condition {
  2160. value: string;
  2161. /**
  2162. * Internal only - manager for action
  2163. * @ignore
  2164. */
  2165. _actionManager: ActionManager;
  2166. /**
  2167. * Internal only
  2168. * @ignore
  2169. */
  2170. private _target;
  2171. /**
  2172. * Creates a new {BABYLON.StateCondition}
  2173. * @param actionManager manager for the action the condition applies to
  2174. * @param target of the condition
  2175. * @param value to compare with target state
  2176. */
  2177. constructor(actionManager: ActionManager, target: any, value: string);
  2178. /**
  2179. * @returns the validity of the state
  2180. */
  2181. isValid(): boolean;
  2182. /**
  2183. * Serialize the {BABYLON.StateCondition} into a JSON compatible object
  2184. * @returns serialization object
  2185. */
  2186. serialize(): any;
  2187. }
  2188. }
  2189. declare module BABYLON {
  2190. class SwitchBooleanAction extends Action {
  2191. propertyPath: string;
  2192. private _target;
  2193. private _effectiveTarget;
  2194. private _property;
  2195. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  2196. _prepare(): void;
  2197. execute(): void;
  2198. serialize(parent: any): any;
  2199. }
  2200. class SetStateAction extends Action {
  2201. value: string;
  2202. private _target;
  2203. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  2204. execute(): void;
  2205. serialize(parent: any): any;
  2206. }
  2207. class SetValueAction extends Action {
  2208. propertyPath: string;
  2209. value: any;
  2210. private _target;
  2211. private _effectiveTarget;
  2212. private _property;
  2213. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  2214. _prepare(): void;
  2215. execute(): void;
  2216. serialize(parent: any): any;
  2217. }
  2218. class IncrementValueAction extends Action {
  2219. propertyPath: string;
  2220. value: any;
  2221. private _target;
  2222. private _effectiveTarget;
  2223. private _property;
  2224. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  2225. _prepare(): void;
  2226. execute(): void;
  2227. serialize(parent: any): any;
  2228. }
  2229. class PlayAnimationAction extends Action {
  2230. from: number;
  2231. to: number;
  2232. loop: boolean | undefined;
  2233. private _target;
  2234. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean | undefined, condition?: Condition);
  2235. _prepare(): void;
  2236. execute(): void;
  2237. serialize(parent: any): any;
  2238. }
  2239. class StopAnimationAction extends Action {
  2240. private _target;
  2241. constructor(triggerOptions: any, target: any, condition?: Condition);
  2242. _prepare(): void;
  2243. execute(): void;
  2244. serialize(parent: any): any;
  2245. }
  2246. class DoNothingAction extends Action {
  2247. constructor(triggerOptions?: any, condition?: Condition);
  2248. execute(): void;
  2249. serialize(parent: any): any;
  2250. }
  2251. class CombineAction extends Action {
  2252. children: Action[];
  2253. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  2254. _prepare(): void;
  2255. execute(evt: ActionEvent): void;
  2256. serialize(parent: any): any;
  2257. }
  2258. class ExecuteCodeAction extends Action {
  2259. func: (evt: ActionEvent) => void;
  2260. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  2261. execute(evt: ActionEvent): void;
  2262. }
  2263. class SetParentAction extends Action {
  2264. private _parent;
  2265. private _target;
  2266. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  2267. _prepare(): void;
  2268. execute(): void;
  2269. serialize(parent: any): any;
  2270. }
  2271. class PlaySoundAction extends Action {
  2272. private _sound;
  2273. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  2274. _prepare(): void;
  2275. execute(): void;
  2276. serialize(parent: any): any;
  2277. }
  2278. class StopSoundAction extends Action {
  2279. private _sound;
  2280. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  2281. _prepare(): void;
  2282. execute(): void;
  2283. serialize(parent: any): any;
  2284. }
  2285. }
  2286. declare module BABYLON {
  2287. class InterpolateValueAction extends Action {
  2288. propertyPath: string;
  2289. value: any;
  2290. duration: number;
  2291. stopOtherAnimations: boolean | undefined;
  2292. onInterpolationDone: (() => void) | undefined;
  2293. private _target;
  2294. private _effectiveTarget;
  2295. private _property;
  2296. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  2297. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean | undefined, onInterpolationDone?: (() => void) | undefined);
  2298. _prepare(): void;
  2299. execute(): void;
  2300. serialize(parent: any): any;
  2301. }
  2302. }
  2303. declare module BABYLON {
  2304. class Animatable {
  2305. target: any;
  2306. fromFrame: number;
  2307. toFrame: number;
  2308. loopAnimation: boolean;
  2309. onAnimationEnd: (() => void) | null | undefined;
  2310. private _localDelayOffset;
  2311. private _pausedDelay;
  2312. private _runtimeAnimations;
  2313. private _paused;
  2314. private _scene;
  2315. private _speedRatio;
  2316. private _weight;
  2317. private _syncRoot;
  2318. animationStarted: boolean;
  2319. /**
  2320. * Gets the root Animatable used to synchronize and normalize animations
  2321. */
  2322. readonly syncRoot: Animatable;
  2323. /**
  2324. * Gets the current frame of the first RuntimeAnimation
  2325. * Used to synchronize Animatables
  2326. */
  2327. readonly masterFrame: number;
  2328. /**
  2329. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  2330. */
  2331. weight: number;
  2332. /**
  2333. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  2334. */
  2335. speedRatio: number;
  2336. constructor(scene: Scene, target: any, fromFrame?: number, toFrame?: number, loopAnimation?: boolean, speedRatio?: number, onAnimationEnd?: (() => void) | null | undefined, animations?: any);
  2337. /**
  2338. * Synchronize and normalize current Animatable with a source Animatable.
  2339. * This is useful when using animation weights and when animations are not of the same length
  2340. * @param root defines the root Animatable to synchronize with
  2341. * @returns the current Animatable
  2342. */
  2343. syncWith(root: Animatable): Animatable;
  2344. getAnimations(): RuntimeAnimation[];
  2345. appendAnimations(target: any, animations: Animation[]): void;
  2346. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  2347. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  2348. reset(): void;
  2349. enableBlending(blendingSpeed: number): void;
  2350. disableBlending(): void;
  2351. goToFrame(frame: number): void;
  2352. pause(): void;
  2353. restart(): void;
  2354. stop(animationName?: string): void;
  2355. _animate(delay: number): boolean;
  2356. }
  2357. }
  2358. declare module BABYLON {
  2359. class AnimationRange {
  2360. name: string;
  2361. from: number;
  2362. to: number;
  2363. constructor(name: string, from: number, to: number);
  2364. clone(): AnimationRange;
  2365. }
  2366. /**
  2367. * Composed of a frame, and an action function
  2368. */
  2369. class AnimationEvent {
  2370. frame: number;
  2371. action: () => void;
  2372. onlyOnce: boolean | undefined;
  2373. isDone: boolean;
  2374. constructor(frame: number, action: () => void, onlyOnce?: boolean | undefined);
  2375. }
  2376. class PathCursor {
  2377. private path;
  2378. private _onchange;
  2379. value: number;
  2380. animations: Animation[];
  2381. constructor(path: Path2);
  2382. getPoint(): Vector3;
  2383. moveAhead(step?: number): PathCursor;
  2384. moveBack(step?: number): PathCursor;
  2385. move(step: number): PathCursor;
  2386. private ensureLimits();
  2387. private raiseOnChange();
  2388. onchange(f: (cursor: PathCursor) => void): PathCursor;
  2389. }
  2390. interface IAnimationKey {
  2391. frame: number;
  2392. value: any;
  2393. inTangent?: any;
  2394. outTangent?: any;
  2395. interpolation?: AnimationKeyInterpolation;
  2396. }
  2397. enum AnimationKeyInterpolation {
  2398. /**
  2399. * Do not interpolate between keys and use the start key value only. Tangents are ignored.
  2400. */
  2401. STEP = 1,
  2402. }
  2403. class Animation {
  2404. name: string;
  2405. targetProperty: string;
  2406. framePerSecond: number;
  2407. dataType: number;
  2408. loopMode: number | undefined;
  2409. enableBlending: boolean | undefined;
  2410. static AllowMatricesInterpolation: boolean;
  2411. private _keys;
  2412. private _easingFunction;
  2413. _runtimeAnimations: RuntimeAnimation[];
  2414. private _events;
  2415. targetPropertyPath: string[];
  2416. blendingSpeed: number;
  2417. private _ranges;
  2418. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  2419. /**
  2420. * Sets up an animation.
  2421. * @param property the property to animate
  2422. * @param animationType the animation type to apply
  2423. * @param easingFunction the easing function used in the animation
  2424. * @returns The created animation
  2425. */
  2426. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  2427. /**
  2428. * Create and start an animation on a node
  2429. * @param {string} name defines the name of the global animation that will be run on all nodes
  2430. * @param {BABYLON.Node} node defines the root node where the animation will take place
  2431. * @param {string} targetProperty defines property to animate
  2432. * @param {number} framePerSecond defines the number of frame per second yo use
  2433. * @param {number} totalFrame defines the number of frames in total
  2434. * @param {any} from defines the initial value
  2435. * @param {any} to defines the final value
  2436. * @param {number} loopMode defines which loop mode you want to use (off by default)
  2437. * @param {BABYLON.EasingFunction} easingFunction defines the easing function to use (linear by default)
  2438. * @param onAnimationEnd defines the callback to call when animation end
  2439. * @returns the animatable created for this animation
  2440. */
  2441. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  2442. /**
  2443. * Create and start an animation on a node and its descendants
  2444. * @param {string} name defines the name of the global animation that will be run on all nodes
  2445. * @param {BABYLON.Node} node defines the root node where the animation will take place
  2446. * @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.
  2447. * @param {string} targetProperty defines property to animate
  2448. * @param {number} framePerSecond defines the number of frame per second yo use
  2449. * @param {number} totalFrame defines the number of frames in total
  2450. * @param {any} from defines the initial value
  2451. * @param {any} to defines the final value
  2452. * @param {number} loopMode defines which loop mode you want to use (off by default)
  2453. * @param {BABYLON.EasingFunction} easingFunction defines the easing function to use (linear by default)
  2454. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  2455. * @returns the list of animatables created for all nodes
  2456. * @example https://www.babylonjs-playground.com/#MH0VLI
  2457. */
  2458. 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[]>;
  2459. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  2460. /**
  2461. * Transition property of the Camera to the target Value.
  2462. * @param property The property to transition
  2463. * @param targetValue The target Value of the property
  2464. * @param host The object where the property to animate belongs
  2465. * @param scene Scene used to run the animation
  2466. * @param frameRate Framerate (in frame/s) to use
  2467. * @param transition The transition type we want to use
  2468. * @param duration The duration of the animation, in milliseconds
  2469. * @param onAnimationEnd Call back trigger at the end of the animation.
  2470. */
  2471. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  2472. /**
  2473. * Return the array of runtime animations currently using this animation
  2474. */
  2475. readonly runtimeAnimations: RuntimeAnimation[];
  2476. readonly hasRunningRuntimeAnimations: boolean;
  2477. constructor(name: string, targetProperty: string, framePerSecond: number, dataType: number, loopMode?: number | undefined, enableBlending?: boolean | undefined);
  2478. /**
  2479. * @param {boolean} fullDetails - support for multiple levels of logging within scene loading
  2480. */
  2481. toString(fullDetails?: boolean): string;
  2482. /**
  2483. * Add an event to this animation.
  2484. */
  2485. addEvent(event: AnimationEvent): void;
  2486. /**
  2487. * Remove all events found at the given frame
  2488. * @param frame
  2489. */
  2490. removeEvents(frame: number): void;
  2491. getEvents(): AnimationEvent[];
  2492. createRange(name: string, from: number, to: number): void;
  2493. deleteRange(name: string, deleteFrames?: boolean): void;
  2494. getRange(name: string): Nullable<AnimationRange>;
  2495. getKeys(): Array<IAnimationKey>;
  2496. getHighestFrame(): number;
  2497. getEasingFunction(): IEasingFunction;
  2498. setEasingFunction(easingFunction: EasingFunction): void;
  2499. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  2500. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  2501. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  2502. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  2503. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  2504. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  2505. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  2506. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  2507. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  2508. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  2509. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number): Matrix;
  2510. clone(): Animation;
  2511. setKeys(values: Array<IAnimationKey>): void;
  2512. serialize(): any;
  2513. private static _ANIMATIONTYPE_FLOAT;
  2514. private static _ANIMATIONTYPE_VECTOR3;
  2515. private static _ANIMATIONTYPE_QUATERNION;
  2516. private static _ANIMATIONTYPE_MATRIX;
  2517. private static _ANIMATIONTYPE_COLOR3;
  2518. private static _ANIMATIONTYPE_VECTOR2;
  2519. private static _ANIMATIONTYPE_SIZE;
  2520. private static _ANIMATIONLOOPMODE_RELATIVE;
  2521. private static _ANIMATIONLOOPMODE_CYCLE;
  2522. private static _ANIMATIONLOOPMODE_CONSTANT;
  2523. static readonly ANIMATIONTYPE_FLOAT: number;
  2524. static readonly ANIMATIONTYPE_VECTOR3: number;
  2525. static readonly ANIMATIONTYPE_VECTOR2: number;
  2526. static readonly ANIMATIONTYPE_SIZE: number;
  2527. static readonly ANIMATIONTYPE_QUATERNION: number;
  2528. static readonly ANIMATIONTYPE_MATRIX: number;
  2529. static readonly ANIMATIONTYPE_COLOR3: number;
  2530. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  2531. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  2532. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  2533. static Parse(parsedAnimation: any): Animation;
  2534. static AppendSerializedAnimations(source: IAnimatable, destination: any): any;
  2535. }
  2536. }
  2537. declare module BABYLON {
  2538. /**
  2539. * This class defines the direct association between an animation and a target
  2540. */
  2541. class TargetedAnimation {
  2542. animation: Animation;
  2543. target: any;
  2544. }
  2545. /**
  2546. * Use this class to create coordinated animations on multiple targets
  2547. */
  2548. class AnimationGroup implements IDisposable {
  2549. name: string;
  2550. private _scene;
  2551. private _targetedAnimations;
  2552. private _animatables;
  2553. private _from;
  2554. private _to;
  2555. private _isStarted;
  2556. private _speedRatio;
  2557. onAnimationEndObservable: Observable<TargetedAnimation>;
  2558. /**
  2559. * Define if the animations are started
  2560. */
  2561. readonly isStarted: boolean;
  2562. /**
  2563. * Gets or sets the speed ratio to use for all animations
  2564. */
  2565. /**
  2566. * Gets or sets the speed ratio to use for all animations
  2567. */
  2568. speedRatio: number;
  2569. /**
  2570. * Gets the targeted animations for this animation group
  2571. */
  2572. readonly targetedAnimations: Array<TargetedAnimation>;
  2573. /**
  2574. * returning the list of animatables controlled by this animation group.
  2575. */
  2576. readonly animatables: Array<Animatable>;
  2577. constructor(name: string, scene?: Nullable<Scene>);
  2578. /**
  2579. * Add an animation (with its target) in the group
  2580. * @param animation defines the animation we want to add
  2581. * @param target defines the target of the animation
  2582. * @returns the {BABYLON.TargetedAnimation} object
  2583. */
  2584. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  2585. /**
  2586. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  2587. * It can add constant keys at begin or end
  2588. * @param beginFrame defines the new begin frame for all animations. It can't be bigger than the smallest begin frame of all animations
  2589. * @param endFrame defines the new end frame for all animations. It can't be smaller than the largest end frame of all animations
  2590. */
  2591. normalize(beginFrame?: number, endFrame?: number): AnimationGroup;
  2592. /**
  2593. * Start all animations on given targets
  2594. * @param loop defines if animations must loop
  2595. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  2596. * @param from defines the from key (optional)
  2597. * @param to defines the to key (optional)
  2598. * @returns the current animation group
  2599. */
  2600. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  2601. /**
  2602. * Pause all animations
  2603. */
  2604. pause(): AnimationGroup;
  2605. /**
  2606. * Play all animations to initial state
  2607. * This function will start() the animations if they were not started or will restart() them if they were paused
  2608. * @param loop defines if animations must loop
  2609. */
  2610. play(loop?: boolean): AnimationGroup;
  2611. /**
  2612. * Reset all animations to initial state
  2613. */
  2614. reset(): AnimationGroup;
  2615. /**
  2616. * Restart animations from key 0
  2617. */
  2618. restart(): AnimationGroup;
  2619. /**
  2620. * Stop all animations
  2621. */
  2622. stop(): AnimationGroup;
  2623. /**
  2624. * Goes to a specific frame in this animation group
  2625. *
  2626. * @param frame the frame number to go to
  2627. * @return the animationGroup
  2628. */
  2629. goToFrame(frame: number): AnimationGroup;
  2630. /**
  2631. * Dispose all associated resources
  2632. */
  2633. dispose(): void;
  2634. }
  2635. }
  2636. declare module BABYLON {
  2637. /**
  2638. * Class used to override all child animations of a given target
  2639. */
  2640. class AnimationPropertiesOverride {
  2641. /**
  2642. * Gets or sets a value indicating if animation blending must be used
  2643. */
  2644. enableBlending: boolean;
  2645. /**
  2646. * Gets or sets the blending speed to use when enableBlending is true
  2647. */
  2648. blendingSpeed: number;
  2649. /**
  2650. * Gets or sets the default loop mode to use
  2651. */
  2652. loopMode: number;
  2653. }
  2654. }
  2655. declare module BABYLON {
  2656. interface IEasingFunction {
  2657. ease(gradient: number): number;
  2658. }
  2659. class EasingFunction implements IEasingFunction {
  2660. private static _EASINGMODE_EASEIN;
  2661. private static _EASINGMODE_EASEOUT;
  2662. private static _EASINGMODE_EASEINOUT;
  2663. static readonly EASINGMODE_EASEIN: number;
  2664. static readonly EASINGMODE_EASEOUT: number;
  2665. static readonly EASINGMODE_EASEINOUT: number;
  2666. private _easingMode;
  2667. setEasingMode(easingMode: number): void;
  2668. getEasingMode(): number;
  2669. easeInCore(gradient: number): number;
  2670. ease(gradient: number): number;
  2671. }
  2672. class CircleEase extends EasingFunction implements IEasingFunction {
  2673. easeInCore(gradient: number): number;
  2674. }
  2675. class BackEase extends EasingFunction implements IEasingFunction {
  2676. amplitude: number;
  2677. constructor(amplitude?: number);
  2678. easeInCore(gradient: number): number;
  2679. }
  2680. class BounceEase extends EasingFunction implements IEasingFunction {
  2681. bounces: number;
  2682. bounciness: number;
  2683. constructor(bounces?: number, bounciness?: number);
  2684. easeInCore(gradient: number): number;
  2685. }
  2686. class CubicEase extends EasingFunction implements IEasingFunction {
  2687. easeInCore(gradient: number): number;
  2688. }
  2689. class ElasticEase extends EasingFunction implements IEasingFunction {
  2690. oscillations: number;
  2691. springiness: number;
  2692. constructor(oscillations?: number, springiness?: number);
  2693. easeInCore(gradient: number): number;
  2694. }
  2695. class ExponentialEase extends EasingFunction implements IEasingFunction {
  2696. exponent: number;
  2697. constructor(exponent?: number);
  2698. easeInCore(gradient: number): number;
  2699. }
  2700. class PowerEase extends EasingFunction implements IEasingFunction {
  2701. power: number;
  2702. constructor(power?: number);
  2703. easeInCore(gradient: number): number;
  2704. }
  2705. class QuadraticEase extends EasingFunction implements IEasingFunction {
  2706. easeInCore(gradient: number): number;
  2707. }
  2708. class QuarticEase extends EasingFunction implements IEasingFunction {
  2709. easeInCore(gradient: number): number;
  2710. }
  2711. class QuinticEase extends EasingFunction implements IEasingFunction {
  2712. easeInCore(gradient: number): number;
  2713. }
  2714. class SineEase extends EasingFunction implements IEasingFunction {
  2715. easeInCore(gradient: number): number;
  2716. }
  2717. class BezierCurveEase extends EasingFunction implements IEasingFunction {
  2718. x1: number;
  2719. y1: number;
  2720. x2: number;
  2721. y2: number;
  2722. constructor(x1?: number, y1?: number, x2?: number, y2?: number);
  2723. easeInCore(gradient: number): number;
  2724. }
  2725. }
  2726. declare module BABYLON {
  2727. class RuntimeAnimation {
  2728. private _currentFrame;
  2729. private _animation;
  2730. private _target;
  2731. private _host;
  2732. private _originalValue;
  2733. private _originalBlendValue;
  2734. private _offsetsCache;
  2735. private _highLimitsCache;
  2736. private _stopped;
  2737. private _blendingFactor;
  2738. private _scene;
  2739. private _currentValue;
  2740. private _activeTarget;
  2741. private _targetPath;
  2742. private _weight;
  2743. /**
  2744. * Gets the current frame
  2745. */
  2746. readonly currentFrame: number;
  2747. /**
  2748. * Gets the weight of the runtime animation
  2749. */
  2750. readonly weight: number;
  2751. /**
  2752. * Gets the original value of the runtime animation
  2753. */
  2754. readonly originalValue: any;
  2755. /**
  2756. * Gets the current value of the runtime animation
  2757. */
  2758. readonly currentValue: any;
  2759. /**
  2760. * Gets the path where to store the animated value in the target
  2761. */
  2762. readonly targetPath: string;
  2763. /**
  2764. * Gets the actual target of the runtime animation
  2765. */
  2766. readonly target: any;
  2767. /**
  2768. * Create a new RuntimeAnimation object
  2769. * @param target defines the target of the animation
  2770. * @param animation defines the source {BABYLON.Animation} object
  2771. * @param scene defines the hosting scene
  2772. * @param host defines the initiating Animatable
  2773. */
  2774. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  2775. readonly animation: Animation;
  2776. reset(): void;
  2777. isStopped(): boolean;
  2778. dispose(): void;
  2779. private _getKeyValue(value);
  2780. private _interpolate(currentFrame, repeatCount, loopMode?, offsetValue?, highLimitValue?);
  2781. /**
  2782. * Affect the interpolated value to the target
  2783. * @param currentValue defines the value computed by the animation
  2784. * @param weight defines the weight to apply to this value
  2785. */
  2786. setValue(currentValue: any, weight?: number): void;
  2787. private _getCorrectLoopMode();
  2788. /**
  2789. * Move the current animation to a given frame
  2790. * @param frame defines the frame to move to
  2791. */
  2792. goToFrame(frame: number): void;
  2793. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  2794. private _ratioOffset;
  2795. private _previousDelay;
  2796. private _previousRatio;
  2797. /**
  2798. * Execute the current animation
  2799. * @param delay defines the delay to add to the current frame
  2800. * @param from defines the lower bound of the animation range
  2801. * @param to defines the upper bound of the animation range
  2802. * @param loop defines if the current animation must loop
  2803. * @param speedRatio defines the current speed ratio
  2804. * @param weight defines the weight of the animation (default is -1 so no weight)
  2805. * @returns a boolean indicating if the animation has ended
  2806. */
  2807. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  2808. }
  2809. }
  2810. declare module BABYLON {
  2811. class Analyser {
  2812. SMOOTHING: number;
  2813. FFT_SIZE: number;
  2814. BARGRAPHAMPLITUDE: number;
  2815. DEBUGCANVASPOS: {
  2816. x: number;
  2817. y: number;
  2818. };
  2819. DEBUGCANVASSIZE: {
  2820. width: number;
  2821. height: number;
  2822. };
  2823. private _byteFreqs;
  2824. private _byteTime;
  2825. private _floatFreqs;
  2826. private _webAudioAnalyser;
  2827. private _debugCanvas;
  2828. private _debugCanvasContext;
  2829. private _scene;
  2830. private _registerFunc;
  2831. private _audioEngine;
  2832. constructor(scene: Scene);
  2833. getFrequencyBinCount(): number;
  2834. getByteFrequencyData(): Uint8Array;
  2835. getByteTimeDomainData(): Uint8Array;
  2836. getFloatFrequencyData(): Uint8Array;
  2837. drawDebugCanvas(): void;
  2838. stopDebugCanvas(): void;
  2839. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  2840. dispose(): void;
  2841. }
  2842. }
  2843. declare module BABYLON {
  2844. class AudioEngine {
  2845. private _audioContext;
  2846. private _audioContextInitialized;
  2847. canUseWebAudio: boolean;
  2848. masterGain: GainNode;
  2849. private _connectedAnalyser;
  2850. WarnedWebAudioUnsupported: boolean;
  2851. unlocked: boolean;
  2852. onAudioUnlocked: () => any;
  2853. isMP3supported: boolean;
  2854. isOGGsupported: boolean;
  2855. readonly audioContext: Nullable<AudioContext>;
  2856. constructor();
  2857. private _unlockiOSaudio();
  2858. private _initializeAudioContext();
  2859. dispose(): void;
  2860. getGlobalVolume(): number;
  2861. setGlobalVolume(newVolume: number): void;
  2862. connectToAnalyser(analyser: Analyser): void;
  2863. }
  2864. }
  2865. declare module BABYLON {
  2866. class Sound {
  2867. name: string;
  2868. autoplay: boolean;
  2869. loop: boolean;
  2870. useCustomAttenuation: boolean;
  2871. soundTrackId: number;
  2872. spatialSound: boolean;
  2873. refDistance: number;
  2874. rolloffFactor: number;
  2875. maxDistance: number;
  2876. distanceModel: string;
  2877. private _panningModel;
  2878. onended: () => any;
  2879. private _playbackRate;
  2880. private _streaming;
  2881. private _startTime;
  2882. private _startOffset;
  2883. private _position;
  2884. private _localDirection;
  2885. private _volume;
  2886. private _isReadyToPlay;
  2887. isPlaying: boolean;
  2888. isPaused: boolean;
  2889. private _isDirectional;
  2890. private _readyToPlayCallback;
  2891. private _audioBuffer;
  2892. private _soundSource;
  2893. private _streamingSource;
  2894. private _soundPanner;
  2895. private _soundGain;
  2896. private _inputAudioNode;
  2897. private _ouputAudioNode;
  2898. private _coneInnerAngle;
  2899. private _coneOuterAngle;
  2900. private _coneOuterGain;
  2901. private _scene;
  2902. private _connectedMesh;
  2903. private _customAttenuationFunction;
  2904. private _registerFunc;
  2905. private _isOutputConnected;
  2906. private _htmlAudioElement;
  2907. private _urlType;
  2908. /**
  2909. * Create a sound and attach it to a scene
  2910. * @param name Name of your sound
  2911. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer
  2912. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  2913. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  2914. */
  2915. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: any);
  2916. dispose(): void;
  2917. isReady(): boolean;
  2918. private _soundLoaded(audioData);
  2919. setAudioBuffer(audioBuffer: AudioBuffer): void;
  2920. updateOptions(options: any): void;
  2921. private _createSpatialParameters();
  2922. private _updateSpatialParameters();
  2923. switchPanningModelToHRTF(): void;
  2924. switchPanningModelToEqualPower(): void;
  2925. private _switchPanningModel();
  2926. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  2927. /**
  2928. * Transform this sound into a directional source
  2929. * @param coneInnerAngle Size of the inner cone in degree
  2930. * @param coneOuterAngle Size of the outer cone in degree
  2931. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  2932. */
  2933. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  2934. setPosition(newPosition: Vector3): void;
  2935. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  2936. private _updateDirection();
  2937. updateDistanceFromListener(): void;
  2938. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  2939. /**
  2940. * Play the sound
  2941. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  2942. * @param offset (optional) Start the sound setting it at a specific time
  2943. */
  2944. play(time?: number, offset?: number): void;
  2945. private _onended();
  2946. /**
  2947. * Stop the sound
  2948. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  2949. */
  2950. stop(time?: number): void;
  2951. pause(): void;
  2952. setVolume(newVolume: number, time?: number): void;
  2953. setPlaybackRate(newPlaybackRate: number): void;
  2954. getVolume(): number;
  2955. attachToMesh(meshToConnectTo: AbstractMesh): void;
  2956. detachFromMesh(): void;
  2957. private _onRegisterAfterWorldMatrixUpdate(node);
  2958. clone(): Nullable<Sound>;
  2959. getAudioBuffer(): AudioBuffer | null;
  2960. serialize(): any;
  2961. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  2962. }
  2963. }
  2964. declare module BABYLON {
  2965. class SoundTrack {
  2966. private _outputAudioNode;
  2967. private _scene;
  2968. id: number;
  2969. soundCollection: Array<Sound>;
  2970. private _isMainTrack;
  2971. private _connectedAnalyser;
  2972. private _options;
  2973. private _isInitialized;
  2974. constructor(scene: Scene, options?: any);
  2975. private _initializeSoundTrackAudioGraph();
  2976. dispose(): void;
  2977. AddSound(sound: Sound): void;
  2978. RemoveSound(sound: Sound): void;
  2979. setVolume(newVolume: number): void;
  2980. switchPanningModelToHRTF(): void;
  2981. switchPanningModelToEqualPower(): void;
  2982. connectToAnalyser(analyser: Analyser): void;
  2983. }
  2984. }
  2985. declare module BABYLON {
  2986. class Bone extends Node {
  2987. name: string;
  2988. private static _tmpVecs;
  2989. private static _tmpQuat;
  2990. private static _tmpMats;
  2991. children: Bone[];
  2992. animations: Animation[];
  2993. length: number;
  2994. _index: Nullable<number>;
  2995. private _skeleton;
  2996. private _localMatrix;
  2997. private _restPose;
  2998. private _baseMatrix;
  2999. private _worldTransform;
  3000. private _absoluteTransform;
  3001. private _invertedAbsoluteTransform;
  3002. private _parent;
  3003. private _scaleMatrix;
  3004. private _scaleVector;
  3005. private _negateScaleChildren;
  3006. private _scalingDeterminant;
  3007. _matrix: Matrix;
  3008. constructor(name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  3009. getSkeleton(): Skeleton;
  3010. getParent(): Nullable<Bone>;
  3011. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  3012. getLocalMatrix(): Matrix;
  3013. getBaseMatrix(): Matrix;
  3014. getRestPose(): Matrix;
  3015. returnToRest(): void;
  3016. getWorldMatrix(): Matrix;
  3017. getInvertedAbsoluteTransform(): Matrix;
  3018. getAbsoluteTransform(): Matrix;
  3019. position: Vector3;
  3020. rotation: Vector3;
  3021. rotationQuaternion: Quaternion;
  3022. scaling: Vector3;
  3023. /**
  3024. * Gets the animation properties override
  3025. */
  3026. readonly animationPropertiesOverride: AnimationPropertiesOverride;
  3027. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean): void;
  3028. _updateDifferenceMatrix(rootMatrix?: Matrix): void;
  3029. markAsDirty(): void;
  3030. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired?: boolean, skelDimensionsRatio?: Nullable<Vector3>): boolean;
  3031. /**
  3032. * Translate the bone in local or world space.
  3033. * @param vec The amount to translate the bone.
  3034. * @param space The space that the translation is in.
  3035. * @param mesh The mesh that this bone is attached to. This is only used in world space.
  3036. */
  3037. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  3038. /**
  3039. * Set the postion of the bone in local or world space.
  3040. * @param position The position to set the bone.
  3041. * @param space The space that the position is in.
  3042. * @param mesh The mesh that this bone is attached to. This is only used in world space.
  3043. */
  3044. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  3045. /**
  3046. * Set the absolute postion of the bone (world space).
  3047. * @param position The position to set the bone.
  3048. * @param mesh The mesh that this bone is attached to.
  3049. */
  3050. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  3051. /**
  3052. * Set the scale of the bone on the x, y and z axes.
  3053. * @param x The scale of the bone on the x axis.
  3054. * @param x The scale of the bone on the y axis.
  3055. * @param z The scale of the bone on the z axis.
  3056. * @param scaleChildren Set this to true if children of the bone should be scaled.
  3057. */
  3058. setScale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  3059. /**
  3060. * Scale the bone on the x, y and z axes.
  3061. * @param x The amount to scale the bone on the x axis.
  3062. * @param x The amount to scale the bone on the y axis.
  3063. * @param z The amount to scale the bone on the z axis.
  3064. * @param scaleChildren Set this to true if children of the bone should be scaled.
  3065. */
  3066. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  3067. /**
  3068. * Set the yaw, pitch, and roll of the bone in local or world space.
  3069. * @param yaw The rotation of the bone on the y axis.
  3070. * @param pitch The rotation of the bone on the x axis.
  3071. * @param roll The rotation of the bone on the z axis.
  3072. * @param space The space that the axes of rotation are in.
  3073. * @param mesh The mesh that this bone is attached to. This is only used in world space.
  3074. */
  3075. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  3076. /**
  3077. * Rotate the bone on an axis in local or world space.
  3078. * @param axis The axis to rotate the bone on.
  3079. * @param amount The amount to rotate the bone.
  3080. * @param space The space that the axis is in.
  3081. * @param mesh The mesh that this bone is attached to. This is only used in world space.
  3082. */
  3083. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  3084. /**
  3085. * Set the rotation of the bone to a particular axis angle in local or world space.
  3086. * @param axis The axis to rotate the bone on.
  3087. * @param angle The angle that the bone should be rotated to.
  3088. * @param space The space that the axis is in.
  3089. * @param mesh The mesh that this bone is attached to. This is only used in world space.
  3090. */
  3091. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  3092. /**
  3093. * Set the euler rotation of the bone in local of world space.
  3094. * @param rotation The euler rotation that the bone should be set to.
  3095. * @param space The space that the rotation is in.
  3096. * @param mesh The mesh that this bone is attached to. This is only used in world space.
  3097. */
  3098. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  3099. /**
  3100. * Set the quaternion rotation of the bone in local of world space.
  3101. * @param quat The quaternion rotation that the bone should be set to.
  3102. * @param space The space that the rotation is in.
  3103. * @param mesh The mesh that this bone is attached to. This is only used in world space.
  3104. */
  3105. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  3106. /**
  3107. * Set the rotation matrix of the bone in local of world space.
  3108. * @param rotMat The rotation matrix that the bone should be set to.
  3109. * @param space The space that the rotation is in.
  3110. * @param mesh The mesh that this bone is attached to. This is only used in world space.
  3111. */
  3112. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  3113. private _rotateWithMatrix(rmat, space?, mesh?);
  3114. private _getNegativeRotationToRef(rotMatInv, space?, mesh?);
  3115. /**
  3116. * Get the scale of the bone
  3117. * @returns the scale of the bone
  3118. */
  3119. getScale(): Vector3;
  3120. /**
  3121. * Copy the scale of the bone to a vector3.
  3122. * @param result The vector3 to copy the scale to
  3123. */
  3124. getScaleToRef(result: Vector3): void;
  3125. /**
  3126. * Get the position of the bone in local or world space.
  3127. * @param space The space that the returned position is in.
  3128. * @param mesh The mesh that this bone is attached to. This is only used in world space.
  3129. * @returns The position of the bone
  3130. */
  3131. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  3132. /**
  3133. * Copy the position of the bone to a vector3 in local or world space.
  3134. * @param space The space that the returned position is in.
  3135. * @param mesh The mesh that this bone is attached to. This is only used in world space.
  3136. * @param result The vector3 to copy the position to.
  3137. */
  3138. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  3139. /**
  3140. * Get the absolute position of the bone (world space).
  3141. * @param mesh The mesh that this bone is attached to.
  3142. * @returns The absolute position of the bone
  3143. */
  3144. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  3145. /**
  3146. * Copy the absolute position of the bone (world space) to the result param.
  3147. * @param mesh The mesh that this bone is attached to.
  3148. * @param result The vector3 to copy the absolute position to.
  3149. */
  3150. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  3151. /**
  3152. * Compute the absolute transforms of this bone and its children.
  3153. */
  3154. computeAbsoluteTransforms(): void;
  3155. private _syncScaleVector();
  3156. /**
  3157. * Get the world direction from an axis that is in the local space of the bone.
  3158. * @param localAxis The local direction that is used to compute the world direction.
  3159. * @param mesh The mesh that this bone is attached to.
  3160. * @returns The world direction
  3161. */
  3162. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  3163. /**
  3164. * Copy the world direction to a vector3 from an axis that is in the local space of the bone.
  3165. * @param localAxis The local direction that is used to compute the world direction.
  3166. * @param mesh The mesh that this bone is attached to.
  3167. * @param result The vector3 that the world direction will be copied to.
  3168. */
  3169. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  3170. /**
  3171. * Get the euler rotation of the bone in local or world space.
  3172. * @param space The space that the rotation should be in.
  3173. * @param mesh The mesh that this bone is attached to. This is only used in world space.
  3174. * @returns The euler rotation
  3175. */
  3176. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  3177. /**
  3178. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space.
  3179. * @param space The space that the rotation should be in.
  3180. * @param mesh The mesh that this bone is attached to. This is only used in world space.
  3181. * @param result The vector3 that the rotation should be copied to.
  3182. */
  3183. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  3184. /**
  3185. * Get the quaternion rotation of the bone in either local or world space.
  3186. * @param space The space that the rotation should be in.
  3187. * @param mesh The mesh that this bone is attached to. This is only used in world space.
  3188. * @returns The quaternion rotation
  3189. */
  3190. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  3191. /**
  3192. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space.
  3193. * @param space The space that the rotation should be in.
  3194. * @param mesh The mesh that this bone is attached to. This is only used in world space.
  3195. * @param result The quaternion that the rotation should be copied to.
  3196. */
  3197. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  3198. /**
  3199. * Get the rotation matrix of the bone in local or world space.
  3200. * @param space The space that the rotation should be in.
  3201. * @param mesh The mesh that this bone is attached to. This is only used in world space.
  3202. * @returns The rotation matrix
  3203. */
  3204. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  3205. /**
  3206. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space.
  3207. * @param space The space that the rotation should be in.
  3208. * @param mesh The mesh that this bone is attached to. This is only used in world space.
  3209. * @param result The quaternion that the rotation should be copied to.
  3210. */
  3211. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  3212. /**
  3213. * Get the world position of a point that is in the local space of the bone.
  3214. * @param position The local position
  3215. * @param mesh The mesh that this bone is attached to.
  3216. * @returns The world position
  3217. */
  3218. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  3219. /**
  3220. * Get the world position of a point that is in the local space of the bone and copy it to the result param.
  3221. * @param position The local position
  3222. * @param mesh The mesh that this bone is attached to.
  3223. * @param result The vector3 that the world position should be copied to.
  3224. */
  3225. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  3226. /**
  3227. * Get the local position of a point that is in world space.
  3228. * @param position The world position
  3229. * @param mesh The mesh that this bone is attached to.
  3230. * @returns The local position
  3231. */
  3232. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  3233. /**
  3234. * Get the local position of a point that is in world space and copy it to the result param.
  3235. * @param position The world position
  3236. * @param mesh The mesh that this bone is attached to.
  3237. * @param result The vector3 that the local position should be copied to.
  3238. */
  3239. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  3240. }
  3241. }
  3242. declare module BABYLON {
  3243. class BoneIKController {
  3244. private static _tmpVecs;
  3245. private static _tmpQuat;
  3246. private static _tmpMats;
  3247. targetMesh: AbstractMesh;
  3248. poleTargetMesh: AbstractMesh;
  3249. poleTargetBone: Nullable<Bone>;
  3250. targetPosition: Vector3;
  3251. poleTargetPosition: Vector3;
  3252. poleTargetLocalOffset: Vector3;
  3253. poleAngle: number;
  3254. mesh: AbstractMesh;
  3255. slerpAmount: number;
  3256. private _bone1Quat;
  3257. private _bone1Mat;
  3258. private _bone2Ang;
  3259. private _bone1;
  3260. private _bone2;
  3261. private _bone1Length;
  3262. private _bone2Length;
  3263. private _maxAngle;
  3264. private _maxReach;
  3265. private _rightHandedSystem;
  3266. private _bendAxis;
  3267. private _slerping;
  3268. private _adjustRoll;
  3269. maxAngle: number;
  3270. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  3271. targetMesh?: AbstractMesh;
  3272. poleTargetMesh?: AbstractMesh;
  3273. poleTargetBone?: Bone;
  3274. poleTargetLocalOffset?: Vector3;
  3275. poleAngle?: number;
  3276. bendAxis?: Vector3;
  3277. maxAngle?: number;
  3278. slerpAmount?: number;
  3279. });
  3280. private _setMaxAngle(ang);
  3281. update(): void;
  3282. }
  3283. }
  3284. declare module BABYLON {
  3285. class BoneLookController {
  3286. private static _tmpVecs;
  3287. private static _tmpQuat;
  3288. private static _tmpMats;
  3289. /**
  3290. * The target Vector3 that the bone will look at.
  3291. */
  3292. target: Vector3;
  3293. /**
  3294. * The mesh that the bone is attached to.
  3295. */
  3296. mesh: AbstractMesh;
  3297. /**
  3298. * The bone that will be looking to the target.
  3299. */
  3300. bone: Bone;
  3301. /**
  3302. * The up axis of the coordinate system that is used when the bone is rotated.
  3303. */
  3304. upAxis: Vector3;
  3305. /**
  3306. * The space that the up axis is in - BABYLON.Space.BONE, BABYLON.Space.LOCAL (default), or BABYLON.Space.WORLD.
  3307. */
  3308. upAxisSpace: Space;
  3309. /**
  3310. * Used to make an adjustment to the yaw of the bone.
  3311. */
  3312. adjustYaw: number;
  3313. /**
  3314. * Used to make an adjustment to the pitch of the bone.
  3315. */
  3316. adjustPitch: number;
  3317. /**
  3318. * Used to make an adjustment to the roll of the bone.
  3319. */
  3320. adjustRoll: number;
  3321. /**
  3322. * 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).
  3323. */
  3324. slerpAmount: number;
  3325. private _minYaw;
  3326. private _maxYaw;
  3327. private _minPitch;
  3328. private _maxPitch;
  3329. private _minYawSin;
  3330. private _minYawCos;
  3331. private _maxYawSin;
  3332. private _maxYawCos;
  3333. private _midYawConstraint;
  3334. private _minPitchTan;
  3335. private _maxPitchTan;
  3336. private _boneQuat;
  3337. private _slerping;
  3338. private _transformYawPitch;
  3339. private _transformYawPitchInv;
  3340. private _firstFrameSkipped;
  3341. private _yawRange;
  3342. private _fowardAxis;
  3343. /**
  3344. * Get/set the minimum yaw angle that the bone can look to.
  3345. */
  3346. minYaw: number;
  3347. /**
  3348. * Get/set the maximum yaw angle that the bone can look to.
  3349. */
  3350. maxYaw: number;
  3351. /**
  3352. * Get/set the minimum pitch angle that the bone can look to.
  3353. */
  3354. minPitch: number;
  3355. /**
  3356. * Get/set the maximum pitch angle that the bone can look to.
  3357. */
  3358. maxPitch: number;
  3359. /**
  3360. * Create a BoneLookController
  3361. * @param mesh the mesh that the bone belongs to
  3362. * @param bone the bone that will be looking to the target
  3363. * @param target the target Vector3 to look at
  3364. * @param settings optional settings:
  3365. * - maxYaw: the maximum angle the bone will yaw to
  3366. * - minYaw: the minimum angle the bone will yaw to
  3367. * - maxPitch: the maximum angle the bone will pitch to
  3368. * - minPitch: the minimum angle the bone will yaw to
  3369. * - slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  3370. * - upAxis: the up axis of the coordinate system
  3371. * - upAxisSpace: the space that the up axis is in - BABYLON.Space.BONE, BABYLON.Space.LOCAL (default), or BABYLON.Space.WORLD.
  3372. * - yawAxis: set yawAxis if the bone does not yaw on the y axis
  3373. * - pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  3374. * - adjustYaw: used to make an adjustment to the yaw of the bone
  3375. * - adjustPitch: used to make an adjustment to the pitch of the bone
  3376. * - adjustRoll: used to make an adjustment to the roll of the bone
  3377. **/
  3378. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  3379. maxYaw?: number;
  3380. minYaw?: number;
  3381. maxPitch?: number;
  3382. minPitch?: number;
  3383. slerpAmount?: number;
  3384. upAxis?: Vector3;
  3385. upAxisSpace?: Space;
  3386. yawAxis?: Vector3;
  3387. pitchAxis?: Vector3;
  3388. adjustYaw?: number;
  3389. adjustPitch?: number;
  3390. adjustRoll?: number;
  3391. });
  3392. /**
  3393. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender()).
  3394. */
  3395. update(): void;
  3396. private _getAngleDiff(ang1, ang2);
  3397. private _getAngleBetween(ang1, ang2);
  3398. private _isAngleBetween(ang, ang1, ang2);
  3399. }
  3400. }
  3401. declare module BABYLON {
  3402. class Skeleton implements IAnimatable {
  3403. name: string;
  3404. id: string;
  3405. bones: Bone[];
  3406. dimensionsAtRest: Vector3;
  3407. needInitialSkinMatrix: boolean;
  3408. animations: Array<Animation>;
  3409. private _scene;
  3410. private _isDirty;
  3411. private _transformMatrices;
  3412. private _meshesWithPoseMatrix;
  3413. private _animatables;
  3414. private _identity;
  3415. private _synchronizedWithMesh;
  3416. private _ranges;
  3417. private _lastAbsoluteTransformsUpdateId;
  3418. /**
  3419. * Specifies if the skeleton should be serialized.
  3420. */
  3421. doNotSerialize: boolean;
  3422. /**
  3423. * Gets or sets the animation properties override
  3424. */
  3425. animationPropertiesOverride: AnimationPropertiesOverride;
  3426. /**
  3427. * An event triggered before computing the skeleton's matrices
  3428. */
  3429. onBeforeComputeObservable: Observable<Skeleton>;
  3430. constructor(name: string, id: string, scene: Scene);
  3431. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  3432. getScene(): Scene;
  3433. /**
  3434. * @param {boolean} fullDetails - support for multiple levels of logging within scene loading
  3435. */
  3436. toString(fullDetails?: boolean): string;
  3437. /**
  3438. * Get bone's index searching by name
  3439. * @param {string} name is bone's name to search for
  3440. * @return {number} Indice of the bone. Returns -1 if not found
  3441. */
  3442. getBoneIndexByName(name: string): number;
  3443. createAnimationRange(name: string, from: number, to: number): void;
  3444. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  3445. getAnimationRange(name: string): Nullable<AnimationRange>;
  3446. /**
  3447. * Returns as an Array, all AnimationRanges defined on this skeleton
  3448. */
  3449. getAnimationRanges(): Nullable<AnimationRange>[];
  3450. /**
  3451. * note: This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  3452. */
  3453. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  3454. returnToRest(): void;
  3455. private _getHighestAnimationFrame();
  3456. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  3457. _markAsDirty(): void;
  3458. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  3459. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  3460. _computeTransformMatrices(targetMatrix: Float32Array, initialSkinMatrix: Nullable<Matrix>): void;
  3461. prepare(): void;
  3462. getAnimatables(): IAnimatable[];
  3463. clone(name: string, id: string): Skeleton;
  3464. enableBlending(blendingSpeed?: number): void;
  3465. dispose(): void;
  3466. serialize(): any;
  3467. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  3468. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  3469. getPoseMatrix(): Nullable<Matrix>;
  3470. sortBones(): void;
  3471. private _sortBones(index, bones, visited);
  3472. }
  3473. }
  3474. declare module BABYLON {
  3475. interface Behavior<T extends Node> {
  3476. name: string;
  3477. init(): void;
  3478. attach(node: T): void;
  3479. detach(): void;
  3480. }
  3481. }
  3482. declare module BABYLON {
  3483. class Collider {
  3484. /** Define if a collision was found */
  3485. collisionFound: boolean;
  3486. /**
  3487. * Define last intersection point in local space
  3488. */
  3489. intersectionPoint: Vector3;
  3490. /**
  3491. * Define last collided mesh
  3492. */
  3493. collidedMesh: Nullable<AbstractMesh>;
  3494. private _collisionPoint;
  3495. private _planeIntersectionPoint;
  3496. private _tempVector;
  3497. private _tempVector2;
  3498. private _tempVector3;
  3499. private _tempVector4;
  3500. private _edge;
  3501. private _baseToVertex;
  3502. private _destinationPoint;
  3503. private _slidePlaneNormal;
  3504. private _displacementVector;
  3505. _radius: Vector3;
  3506. _retry: number;
  3507. private _velocity;
  3508. private _basePoint;
  3509. private _epsilon;
  3510. _velocityWorldLength: number;
  3511. _basePointWorld: Vector3;
  3512. private _velocityWorld;
  3513. private _normalizedVelocity;
  3514. _initialVelocity: Vector3;
  3515. _initialPosition: Vector3;
  3516. private _nearestDistance;
  3517. private _collisionMask;
  3518. collisionMask: number;
  3519. /**
  3520. * Gets the plane normal used to compute the sliding response (in local space)
  3521. */
  3522. readonly slidePlaneNormal: Vector3;
  3523. _initialize(source: Vector3, dir: Vector3, e: number): void;
  3524. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  3525. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  3526. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  3527. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  3528. _getResponse(pos: Vector3, vel: Vector3): void;
  3529. }
  3530. }
  3531. declare module BABYLON {
  3532. var CollisionWorker: string;
  3533. interface ICollisionCoordinator {
  3534. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  3535. init(scene: Scene): void;
  3536. destroy(): void;
  3537. onMeshAdded(mesh: AbstractMesh): void;
  3538. onMeshUpdated(mesh: AbstractMesh): void;
  3539. onMeshRemoved(mesh: AbstractMesh): void;
  3540. onGeometryAdded(geometry: Geometry): void;
  3541. onGeometryUpdated(geometry: Geometry): void;
  3542. onGeometryDeleted(geometry: Geometry): void;
  3543. }
  3544. interface SerializedMesh {
  3545. id: string;
  3546. name: string;
  3547. uniqueId: number;
  3548. geometryId: Nullable<string>;
  3549. sphereCenter: Array<number>;
  3550. sphereRadius: number;
  3551. boxMinimum: Array<number>;
  3552. boxMaximum: Array<number>;
  3553. worldMatrixFromCache: any;
  3554. subMeshes: Array<SerializedSubMesh>;
  3555. checkCollisions: boolean;
  3556. }
  3557. interface SerializedSubMesh {
  3558. position: number;
  3559. verticesStart: number;
  3560. verticesCount: number;
  3561. indexStart: number;
  3562. indexCount: number;
  3563. hasMaterial: boolean;
  3564. sphereCenter: Array<number>;
  3565. sphereRadius: number;
  3566. boxMinimum: Array<number>;
  3567. boxMaximum: Array<number>;
  3568. }
  3569. /**
  3570. * Interface describing the value associated with a geometry
  3571. */
  3572. interface SerializedGeometry {
  3573. /**
  3574. * Defines the unique ID of the geometry
  3575. */
  3576. id: string;
  3577. /**
  3578. * Defines the array containing the positions
  3579. */
  3580. positions: Float32Array;
  3581. /**
  3582. * Defines the array containing the indices
  3583. */
  3584. indices: Uint32Array;
  3585. /**
  3586. * Defines the array containing the normals
  3587. */
  3588. normals: Float32Array;
  3589. }
  3590. interface BabylonMessage {
  3591. taskType: WorkerTaskType;
  3592. payload: InitPayload | CollidePayload | UpdatePayload;
  3593. }
  3594. interface SerializedColliderToWorker {
  3595. position: Array<number>;
  3596. velocity: Array<number>;
  3597. radius: Array<number>;
  3598. }
  3599. enum WorkerTaskType {
  3600. INIT = 0,
  3601. UPDATE = 1,
  3602. COLLIDE = 2,
  3603. }
  3604. interface WorkerReply {
  3605. error: WorkerReplyType;
  3606. taskType: WorkerTaskType;
  3607. payload?: any;
  3608. }
  3609. interface CollisionReplyPayload {
  3610. newPosition: Array<number>;
  3611. collisionId: number;
  3612. collidedMeshUniqueId: number;
  3613. }
  3614. interface InitPayload {
  3615. }
  3616. interface CollidePayload {
  3617. collisionId: number;
  3618. collider: SerializedColliderToWorker;
  3619. maximumRetry: number;
  3620. excludedMeshUniqueId: Nullable<number>;
  3621. }
  3622. interface UpdatePayload {
  3623. updatedMeshes: {
  3624. [n: number]: SerializedMesh;
  3625. };
  3626. updatedGeometries: {
  3627. [s: string]: SerializedGeometry;
  3628. };
  3629. removedMeshes: Array<number>;
  3630. removedGeometries: Array<string>;
  3631. }
  3632. enum WorkerReplyType {
  3633. SUCCESS = 0,
  3634. UNKNOWN_ERROR = 1,
  3635. }
  3636. class CollisionCoordinatorWorker implements ICollisionCoordinator {
  3637. private _scene;
  3638. private _scaledPosition;
  3639. private _scaledVelocity;
  3640. private _collisionsCallbackArray;
  3641. private _init;
  3642. private _runningUpdated;
  3643. private _worker;
  3644. private _addUpdateMeshesList;
  3645. private _addUpdateGeometriesList;
  3646. private _toRemoveMeshesArray;
  3647. private _toRemoveGeometryArray;
  3648. constructor();
  3649. static SerializeMesh: (mesh: AbstractMesh) => SerializedMesh;
  3650. static SerializeGeometry: (geometry: Geometry) => SerializedGeometry;
  3651. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  3652. init(scene: Scene): void;
  3653. destroy(): void;
  3654. onMeshAdded(mesh: AbstractMesh): void;
  3655. onMeshUpdated: (transformNode: TransformNode) => void;
  3656. onMeshRemoved(mesh: AbstractMesh): void;
  3657. onGeometryAdded(geometry: Geometry): void;
  3658. onGeometryUpdated: (geometry: Geometry) => void;
  3659. onGeometryDeleted(geometry: Geometry): void;
  3660. private _afterRender;
  3661. private _onMessageFromWorker;
  3662. }
  3663. class CollisionCoordinatorLegacy implements ICollisionCoordinator {
  3664. private _scene;
  3665. private _scaledPosition;
  3666. private _scaledVelocity;
  3667. private _finalPosition;
  3668. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  3669. init(scene: Scene): void;
  3670. destroy(): void;
  3671. onMeshAdded(mesh: AbstractMesh): void;
  3672. onMeshUpdated(mesh: AbstractMesh): void;
  3673. onMeshRemoved(mesh: AbstractMesh): void;
  3674. onGeometryAdded(geometry: Geometry): void;
  3675. onGeometryUpdated(geometry: Geometry): void;
  3676. onGeometryDeleted(geometry: Geometry): void;
  3677. private _collideWithWorld(position, velocity, collider, maximumRetry, finalPosition, excludedMesh?);
  3678. }
  3679. }
  3680. declare function importScripts(...urls: string[]): void;
  3681. declare const safePostMessage: any;
  3682. declare module BABYLON {
  3683. var WorkerIncluded: boolean;
  3684. class CollisionCache {
  3685. private _meshes;
  3686. private _geometries;
  3687. getMeshes(): {
  3688. [n: number]: SerializedMesh;
  3689. };
  3690. getGeometries(): {
  3691. [s: number]: SerializedGeometry;
  3692. };
  3693. getMesh(id: any): SerializedMesh;
  3694. addMesh(mesh: SerializedMesh): void;
  3695. removeMesh(uniqueId: number): void;
  3696. getGeometry(id: string): SerializedGeometry;
  3697. addGeometry(geometry: SerializedGeometry): void;
  3698. removeGeometry(id: string): void;
  3699. }
  3700. class CollideWorker {
  3701. collider: Collider;
  3702. private _collisionCache;
  3703. private finalPosition;
  3704. private collisionsScalingMatrix;
  3705. private collisionTranformationMatrix;
  3706. constructor(collider: Collider, _collisionCache: CollisionCache, finalPosition: Vector3);
  3707. collideWithWorld(position: Vector3, velocity: Vector3, maximumRetry: number, excludedMeshUniqueId: Nullable<number>): void;
  3708. private checkCollision(mesh);
  3709. private processCollisionsForSubMeshes(transformMatrix, mesh);
  3710. private collideForSubMesh(subMesh, transformMatrix, meshGeometry);
  3711. private checkSubmeshCollision(subMesh);
  3712. }
  3713. interface ICollisionDetector {
  3714. onInit(payload: InitPayload): void;
  3715. onUpdate(payload: UpdatePayload): void;
  3716. onCollision(payload: CollidePayload): void;
  3717. }
  3718. class CollisionDetectorTransferable implements ICollisionDetector {
  3719. private _collisionCache;
  3720. onInit(payload: InitPayload): void;
  3721. onUpdate(payload: UpdatePayload): void;
  3722. onCollision(payload: CollidePayload): void;
  3723. }
  3724. }
  3725. declare module BABYLON {
  3726. class IntersectionInfo {
  3727. bu: Nullable<number>;
  3728. bv: Nullable<number>;
  3729. distance: number;
  3730. faceId: number;
  3731. subMeshId: number;
  3732. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  3733. }
  3734. class PickingInfo {
  3735. hit: boolean;
  3736. distance: number;
  3737. pickedPoint: Nullable<Vector3>;
  3738. pickedMesh: Nullable<AbstractMesh>;
  3739. bu: number;
  3740. bv: number;
  3741. faceId: number;
  3742. subMeshId: number;
  3743. pickedSprite: Nullable<Sprite>;
  3744. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  3745. getTextureCoordinates(): Nullable<Vector2>;
  3746. }
  3747. }
  3748. declare module BABYLON {
  3749. class ArcRotateCamera extends TargetCamera {
  3750. alpha: number;
  3751. beta: number;
  3752. radius: number;
  3753. protected _target: Vector3;
  3754. protected _targetHost: Nullable<AbstractMesh>;
  3755. target: Vector3;
  3756. inertialAlphaOffset: number;
  3757. inertialBetaOffset: number;
  3758. inertialRadiusOffset: number;
  3759. lowerAlphaLimit: Nullable<number>;
  3760. upperAlphaLimit: Nullable<number>;
  3761. lowerBetaLimit: number;
  3762. upperBetaLimit: number;
  3763. lowerRadiusLimit: Nullable<number>;
  3764. upperRadiusLimit: Nullable<number>;
  3765. inertialPanningX: number;
  3766. inertialPanningY: number;
  3767. pinchToPanMaxDistance: number;
  3768. panningDistanceLimit: Nullable<number>;
  3769. panningOriginTarget: Vector3;
  3770. panningInertia: number;
  3771. angularSensibilityX: number;
  3772. angularSensibilityY: number;
  3773. pinchPrecision: number;
  3774. pinchDeltaPercentage: number;
  3775. panningSensibility: number;
  3776. keysUp: number[];
  3777. keysDown: number[];
  3778. keysLeft: number[];
  3779. keysRight: number[];
  3780. wheelPrecision: number;
  3781. wheelDeltaPercentage: number;
  3782. zoomOnFactor: number;
  3783. targetScreenOffset: Vector2;
  3784. allowUpsideDown: boolean;
  3785. _viewMatrix: Matrix;
  3786. _useCtrlForPanning: boolean;
  3787. _panningMouseButton: number;
  3788. inputs: ArcRotateCameraInputsManager;
  3789. _reset: () => void;
  3790. panningAxis: Vector3;
  3791. protected _localDirection: Vector3;
  3792. protected _transformedDirection: Vector3;
  3793. private _bouncingBehavior;
  3794. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  3795. useBouncingBehavior: boolean;
  3796. private _framingBehavior;
  3797. readonly framingBehavior: Nullable<FramingBehavior>;
  3798. useFramingBehavior: boolean;
  3799. private _autoRotationBehavior;
  3800. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  3801. useAutoRotationBehavior: boolean;
  3802. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  3803. onCollide: (collidedMesh: AbstractMesh) => void;
  3804. checkCollisions: boolean;
  3805. collisionRadius: Vector3;
  3806. protected _collider: Collider;
  3807. protected _previousPosition: Vector3;
  3808. protected _collisionVelocity: Vector3;
  3809. protected _newPosition: Vector3;
  3810. protected _previousAlpha: number;
  3811. protected _previousBeta: number;
  3812. protected _previousRadius: number;
  3813. protected _collisionTriggered: boolean;
  3814. protected _targetBoundingCenter: Nullable<Vector3>;
  3815. private _computationVector;
  3816. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene);
  3817. _initCache(): void;
  3818. _updateCache(ignoreParentClass?: boolean): void;
  3819. protected _getTargetPosition(): Vector3;
  3820. /**
  3821. * Store current camera state (fov, position, etc..)
  3822. */
  3823. private _storedAlpha;
  3824. private _storedBeta;
  3825. private _storedRadius;
  3826. private _storedTarget;
  3827. storeState(): Camera;
  3828. /**
  3829. * Restored camera state. You must call storeState() first
  3830. */
  3831. _restoreStateValues(): boolean;
  3832. _isSynchronizedViewMatrix(): boolean;
  3833. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  3834. detachControl(element: HTMLElement): void;
  3835. _checkInputs(): void;
  3836. protected _checkLimits(): void;
  3837. rebuildAnglesAndRadius(): void;
  3838. setPosition(position: Vector3): void;
  3839. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  3840. _getViewMatrix(): Matrix;
  3841. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  3842. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  3843. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  3844. min: Vector3;
  3845. max: Vector3;
  3846. distance: number;
  3847. }, doNotUpdateMaxZ?: boolean): void;
  3848. /**
  3849. * @override
  3850. * Override Camera.createRigCamera
  3851. */
  3852. createRigCamera(name: string, cameraIndex: number): Camera;
  3853. /**
  3854. * @override
  3855. * Override Camera._updateRigCameras
  3856. */
  3857. _updateRigCameras(): void;
  3858. dispose(): void;
  3859. getClassName(): string;
  3860. }
  3861. }
  3862. declare module BABYLON {
  3863. class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  3864. constructor(camera: ArcRotateCamera);
  3865. addMouseWheel(): ArcRotateCameraInputsManager;
  3866. addPointers(): ArcRotateCameraInputsManager;
  3867. addKeyboard(): ArcRotateCameraInputsManager;
  3868. addGamepad(): ArcRotateCameraInputsManager;
  3869. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  3870. }
  3871. }
  3872. declare module BABYLON {
  3873. class Camera extends Node {
  3874. inputs: CameraInputsManager<Camera>;
  3875. private static _PERSPECTIVE_CAMERA;
  3876. private static _ORTHOGRAPHIC_CAMERA;
  3877. private static _FOVMODE_VERTICAL_FIXED;
  3878. private static _FOVMODE_HORIZONTAL_FIXED;
  3879. private static _RIG_MODE_NONE;
  3880. private static _RIG_MODE_STEREOSCOPIC_ANAGLYPH;
  3881. private static _RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL;
  3882. private static _RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED;
  3883. private static _RIG_MODE_STEREOSCOPIC_OVERUNDER;
  3884. private static _RIG_MODE_VR;
  3885. private static _RIG_MODE_WEBVR;
  3886. static readonly PERSPECTIVE_CAMERA: number;
  3887. static readonly ORTHOGRAPHIC_CAMERA: number;
  3888. /**
  3889. * This is the default FOV mode for perspective cameras.
  3890. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  3891. *
  3892. */
  3893. static readonly FOVMODE_VERTICAL_FIXED: number;
  3894. /**
  3895. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  3896. *
  3897. */
  3898. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  3899. static readonly RIG_MODE_NONE: number;
  3900. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  3901. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  3902. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  3903. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  3904. static readonly RIG_MODE_VR: number;
  3905. static readonly RIG_MODE_WEBVR: number;
  3906. static ForceAttachControlToAlwaysPreventDefault: boolean;
  3907. static UseAlternateWebVRRendering: boolean;
  3908. position: Vector3;
  3909. /**
  3910. * The vector the camera should consider as up.
  3911. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  3912. */
  3913. upVector: Vector3;
  3914. orthoLeft: Nullable<number>;
  3915. orthoRight: Nullable<number>;
  3916. orthoBottom: Nullable<number>;
  3917. orthoTop: Nullable<number>;
  3918. /**
  3919. * FOV is set in Radians. (default is 0.8)
  3920. */
  3921. fov: number;
  3922. minZ: number;
  3923. maxZ: number;
  3924. inertia: number;
  3925. mode: number;
  3926. isIntermediate: boolean;
  3927. viewport: Viewport;
  3928. /**
  3929. * Restricts the camera to viewing objects with the same layerMask.
  3930. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  3931. */
  3932. layerMask: number;
  3933. /**
  3934. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  3935. */
  3936. fovMode: number;
  3937. cameraRigMode: number;
  3938. interaxialDistance: number;
  3939. isStereoscopicSideBySide: boolean;
  3940. _cameraRigParams: any;
  3941. _rigCameras: Camera[];
  3942. _rigPostProcess: Nullable<PostProcess>;
  3943. protected _webvrViewMatrix: Matrix;
  3944. _skipRendering: boolean;
  3945. _alternateCamera: Camera;
  3946. customRenderTargets: RenderTargetTexture[];
  3947. onViewMatrixChangedObservable: Observable<Camera>;
  3948. onProjectionMatrixChangedObservable: Observable<Camera>;
  3949. onAfterCheckInputsObservable: Observable<Camera>;
  3950. onRestoreStateObservable: Observable<Camera>;
  3951. private _computedViewMatrix;
  3952. _projectionMatrix: Matrix;
  3953. private _doNotComputeProjectionMatrix;
  3954. private _worldMatrix;
  3955. _postProcesses: Nullable<PostProcess>[];
  3956. private _transformMatrix;
  3957. _activeMeshes: SmartArray<AbstractMesh>;
  3958. private _globalPosition;
  3959. private _frustumPlanes;
  3960. private _refreshFrustumPlanes;
  3961. constructor(name: string, position: Vector3, scene: Scene);
  3962. private _storedFov;
  3963. private _stateStored;
  3964. /**
  3965. * Store current camera state (fov, position, etc..)
  3966. */
  3967. storeState(): Camera;
  3968. /**
  3969. * Restores the camera state values if it has been stored. You must call storeState() first
  3970. */
  3971. protected _restoreStateValues(): boolean;
  3972. /**
  3973. * Restored camera state. You must call storeState() first
  3974. */
  3975. restoreState(): boolean;
  3976. getClassName(): string;
  3977. /**
  3978. * @param {boolean} fullDetails - support for multiple levels of logging within scene loading
  3979. */
  3980. toString(fullDetails?: boolean): string;
  3981. readonly globalPosition: Vector3;
  3982. getActiveMeshes(): SmartArray<AbstractMesh>;
  3983. isActiveMesh(mesh: Mesh): boolean;
  3984. /**
  3985. * Is this camera ready to be used/rendered
  3986. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  3987. * @return true if the camera is ready
  3988. */
  3989. isReady(completeCheck?: boolean): boolean;
  3990. _initCache(): void;
  3991. _updateCache(ignoreParentClass?: boolean): void;
  3992. _isSynchronized(): boolean;
  3993. _isSynchronizedViewMatrix(): boolean;
  3994. _isSynchronizedProjectionMatrix(): boolean;
  3995. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  3996. detachControl(element: HTMLElement): void;
  3997. update(): void;
  3998. _checkInputs(): void;
  3999. readonly rigCameras: Camera[];
  4000. readonly rigPostProcess: Nullable<PostProcess>;
  4001. /**
  4002. * Internal, gets the first post proces.
  4003. * @returns the first post process to be run on this camera.
  4004. */
  4005. _getFirstPostProcess(): Nullable<PostProcess>;
  4006. private _cascadePostProcessesToRigCams();
  4007. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  4008. detachPostProcess(postProcess: PostProcess): void;
  4009. getWorldMatrix(): Matrix;
  4010. _getViewMatrix(): Matrix;
  4011. getViewMatrix(force?: boolean): Matrix;
  4012. freezeProjectionMatrix(projection?: Matrix): void;
  4013. unfreezeProjectionMatrix(): void;
  4014. getProjectionMatrix(force?: boolean): Matrix;
  4015. getTranformationMatrix(): Matrix;
  4016. private updateFrustumPlanes();
  4017. isInFrustum(target: ICullable): boolean;
  4018. isCompletelyInFrustum(target: ICullable): boolean;
  4019. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  4020. /**
  4021. * Releases resources associated with this node.
  4022. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  4023. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  4024. */
  4025. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  4026. readonly leftCamera: Nullable<FreeCamera>;
  4027. readonly rightCamera: Nullable<FreeCamera>;
  4028. getLeftTarget(): Nullable<Vector3>;
  4029. getRightTarget(): Nullable<Vector3>;
  4030. setCameraRigMode(mode: number, rigParams: any): void;
  4031. private _getVRProjectionMatrix();
  4032. protected _updateCameraRotationMatrix(): void;
  4033. protected _updateWebVRCameraRotationMatrix(): void;
  4034. /**
  4035. * This function MUST be overwritten by the different WebVR cameras available.
  4036. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  4037. */
  4038. protected _getWebVRProjectionMatrix(): Matrix;
  4039. /**
  4040. * This function MUST be overwritten by the different WebVR cameras available.
  4041. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  4042. */
  4043. protected _getWebVRViewMatrix(): Matrix;
  4044. setCameraRigParameter(name: string, value: any): void;
  4045. /**
  4046. * needs to be overridden by children so sub has required properties to be copied
  4047. */
  4048. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  4049. /**
  4050. * May need to be overridden by children
  4051. */
  4052. _updateRigCameras(): void;
  4053. _setupInputs(): void;
  4054. serialize(): any;
  4055. clone(name: string): Camera;
  4056. getDirection(localAxis: Vector3): Vector3;
  4057. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  4058. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  4059. computeWorldMatrix(): Matrix;
  4060. static Parse(parsedCamera: any, scene: Scene): Camera;
  4061. }
  4062. }
  4063. declare module BABYLON {
  4064. var CameraInputTypes: {};
  4065. interface ICameraInput<TCamera extends Camera> {
  4066. camera: Nullable<TCamera>;
  4067. getClassName(): string;
  4068. getSimpleName(): string;
  4069. attachControl: (element: HTMLElement, noPreventDefault?: boolean) => void;
  4070. detachControl: (element: Nullable<HTMLElement>) => void;
  4071. checkInputs?: () => void;
  4072. }
  4073. interface CameraInputsMap<TCamera extends Camera> {
  4074. [name: string]: ICameraInput<TCamera>;
  4075. [idx: number]: ICameraInput<TCamera>;
  4076. }
  4077. class CameraInputsManager<TCamera extends Camera> {
  4078. attached: CameraInputsMap<TCamera>;
  4079. attachedElement: Nullable<HTMLElement>;
  4080. noPreventDefault: boolean;
  4081. camera: TCamera;
  4082. checkInputs: () => void;
  4083. constructor(camera: TCamera);
  4084. /**
  4085. * Add an input method to a camera.
  4086. * builtin inputs example: camera.inputs.addGamepad();
  4087. * custom inputs example: camera.inputs.add(new BABYLON.FreeCameraGamepadInput());
  4088. * @param input camera input method
  4089. */
  4090. add(input: ICameraInput<TCamera>): void;
  4091. /**
  4092. * Remove a specific input method from a camera
  4093. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  4094. * @param inputToRemove camera input method
  4095. */
  4096. remove(inputToRemove: ICameraInput<TCamera>): void;
  4097. removeByType(inputType: string): void;
  4098. private _addCheckInputs(fn);
  4099. attachInput(input: ICameraInput<TCamera>): void;
  4100. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  4101. detachElement(element: HTMLElement, disconnect?: boolean): void;
  4102. rebuildInputCheck(): void;
  4103. /**
  4104. * Remove all attached input methods from a camera
  4105. */
  4106. clear(): void;
  4107. serialize(serializedCamera: any): void;
  4108. parse(parsedCamera: any): void;
  4109. }
  4110. }
  4111. declare module BABYLON {
  4112. /**
  4113. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  4114. * being tilted forward or back and left or right.
  4115. */
  4116. class DeviceOrientationCamera extends FreeCamera {
  4117. private _initialQuaternion;
  4118. private _quaternionCache;
  4119. /**
  4120. * Creates a new device orientation camera
  4121. * @param name The name of the camera
  4122. * @param position The start position camera
  4123. * @param scene The scene the camera belongs to
  4124. */
  4125. constructor(name: string, position: Vector3, scene: Scene);
  4126. /**
  4127. * Gets the current instance class name ("DeviceOrientationCamera").
  4128. * This helps avoiding instanceof at run time.
  4129. * @returns the class name
  4130. */
  4131. getClassName(): string;
  4132. /**
  4133. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  4134. */
  4135. _checkInputs(): void;
  4136. /**
  4137. * Reset the camera to its default orientation on the specified axis only.
  4138. * @param axis The axis to reset
  4139. */
  4140. resetToCurrentRotation(axis?: Axis): void;
  4141. }
  4142. }
  4143. declare module BABYLON {
  4144. class FollowCamera extends TargetCamera {
  4145. radius: number;
  4146. rotationOffset: number;
  4147. heightOffset: number;
  4148. cameraAcceleration: number;
  4149. maxCameraSpeed: number;
  4150. lockedTarget: Nullable<AbstractMesh>;
  4151. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  4152. private getRadians(degrees);
  4153. private follow(cameraTarget);
  4154. _checkInputs(): void;
  4155. getClassName(): string;
  4156. }
  4157. class ArcFollowCamera extends TargetCamera {
  4158. alpha: number;
  4159. beta: number;
  4160. radius: number;
  4161. target: Nullable<AbstractMesh>;
  4162. private _cartesianCoordinates;
  4163. constructor(name: string, alpha: number, beta: number, radius: number, target: Nullable<AbstractMesh>, scene: Scene);
  4164. private follow();
  4165. _checkInputs(): void;
  4166. getClassName(): string;
  4167. }
  4168. }
  4169. declare module BABYLON {
  4170. class FreeCamera extends TargetCamera {
  4171. ellipsoid: Vector3;
  4172. ellipsoidOffset: Vector3;
  4173. checkCollisions: boolean;
  4174. applyGravity: boolean;
  4175. inputs: FreeCameraInputsManager;
  4176. /**
  4177. * Gets the input sensibility for a mouse input. (default is 2000.0)
  4178. * Higher values reduce sensitivity.
  4179. */
  4180. /**
  4181. * Sets the input sensibility for a mouse input. (default is 2000.0)
  4182. * Higher values reduce sensitivity.
  4183. */
  4184. angularSensibility: number;
  4185. keysUp: number[];
  4186. keysDown: number[];
  4187. keysLeft: number[];
  4188. keysRight: number[];
  4189. onCollide: (collidedMesh: AbstractMesh) => void;
  4190. private _collider;
  4191. private _needMoveForGravity;
  4192. private _oldPosition;
  4193. private _diffPosition;
  4194. private _newPosition;
  4195. _localDirection: Vector3;
  4196. _transformedDirection: Vector3;
  4197. constructor(name: string, position: Vector3, scene: Scene);
  4198. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  4199. detachControl(element: HTMLElement): void;
  4200. private _collisionMask;
  4201. collisionMask: number;
  4202. _collideWithWorld(displacement: Vector3): void;
  4203. private _onCollisionPositionChange;
  4204. _checkInputs(): void;
  4205. _decideIfNeedsToMove(): boolean;
  4206. _updatePosition(): void;
  4207. dispose(): void;
  4208. getClassName(): string;
  4209. }
  4210. }
  4211. declare module BABYLON {
  4212. class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  4213. constructor(camera: FreeCamera);
  4214. addKeyboard(): FreeCameraInputsManager;
  4215. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  4216. addGamepad(): FreeCameraInputsManager;
  4217. addDeviceOrientation(): FreeCameraInputsManager;
  4218. addTouch(): FreeCameraInputsManager;
  4219. addVirtualJoystick(): FreeCameraInputsManager;
  4220. }
  4221. }
  4222. declare module BABYLON {
  4223. class GamepadCamera extends UniversalCamera {
  4224. gamepadAngularSensibility: number;
  4225. gamepadMoveSensibility: number;
  4226. constructor(name: string, position: Vector3, scene: Scene);
  4227. getClassName(): string;
  4228. }
  4229. }
  4230. declare module BABYLON {
  4231. class AnaglyphFreeCamera extends FreeCamera {
  4232. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  4233. getClassName(): string;
  4234. }
  4235. class AnaglyphArcRotateCamera extends ArcRotateCamera {
  4236. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  4237. getClassName(): string;
  4238. }
  4239. class AnaglyphGamepadCamera extends GamepadCamera {
  4240. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  4241. getClassName(): string;
  4242. }
  4243. class AnaglyphUniversalCamera extends UniversalCamera {
  4244. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  4245. getClassName(): string;
  4246. }
  4247. class StereoscopicFreeCamera extends FreeCamera {
  4248. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  4249. getClassName(): string;
  4250. }
  4251. class StereoscopicArcRotateCamera extends ArcRotateCamera {
  4252. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  4253. getClassName(): string;
  4254. }
  4255. class StereoscopicGamepadCamera extends GamepadCamera {
  4256. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  4257. getClassName(): string;
  4258. }
  4259. class StereoscopicUniversalCamera extends UniversalCamera {
  4260. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  4261. getClassName(): string;
  4262. }
  4263. }
  4264. declare module BABYLON {
  4265. class TargetCamera extends Camera {
  4266. cameraDirection: Vector3;
  4267. cameraRotation: Vector2;
  4268. rotation: Vector3;
  4269. rotationQuaternion: Quaternion;
  4270. speed: number;
  4271. noRotationConstraint: boolean;
  4272. lockedTarget: any;
  4273. _currentTarget: Vector3;
  4274. _viewMatrix: Matrix;
  4275. _camMatrix: Matrix;
  4276. _cameraTransformMatrix: Matrix;
  4277. _cameraRotationMatrix: Matrix;
  4278. private _rigCamTransformMatrix;
  4279. _referencePoint: Vector3;
  4280. private _currentUpVector;
  4281. _transformedReferencePoint: Vector3;
  4282. _lookAtTemp: Matrix;
  4283. _tempMatrix: Matrix;
  4284. _reset: () => void;
  4285. constructor(name: string, position: Vector3, scene: Scene);
  4286. getFrontPosition(distance: number): Vector3;
  4287. _getLockedTargetPosition(): Nullable<Vector3>;
  4288. /**
  4289. * Store current camera state (fov, position, etc..)
  4290. */
  4291. private _storedPosition;
  4292. private _storedRotation;
  4293. private _storedRotationQuaternion;
  4294. storeState(): Camera;
  4295. /**
  4296. * Restored camera state. You must call storeState() first
  4297. */
  4298. _restoreStateValues(): boolean;
  4299. _initCache(): void;
  4300. _updateCache(ignoreParentClass?: boolean): void;
  4301. _isSynchronizedViewMatrix(): boolean;
  4302. _computeLocalCameraSpeed(): number;
  4303. setTarget(target: Vector3): void;
  4304. /**
  4305. * Return the current target position of the camera. This value is expressed in local space.
  4306. */
  4307. getTarget(): Vector3;
  4308. _decideIfNeedsToMove(): boolean;
  4309. _updatePosition(): void;
  4310. _checkInputs(): void;
  4311. protected _updateCameraRotationMatrix(): void;
  4312. _getViewMatrix(): Matrix;
  4313. /**
  4314. * @override
  4315. * Override Camera.createRigCamera
  4316. */
  4317. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  4318. /**
  4319. * @override
  4320. * Override Camera._updateRigCameras
  4321. */
  4322. _updateRigCameras(): void;
  4323. private _getRigCamPosition(halfSpace, result);
  4324. getClassName(): string;
  4325. }
  4326. }
  4327. declare module BABYLON {
  4328. class TouchCamera extends FreeCamera {
  4329. touchAngularSensibility: number;
  4330. touchMoveSensibility: number;
  4331. constructor(name: string, position: Vector3, scene: Scene);
  4332. getClassName(): string;
  4333. _setupInputs(): void;
  4334. }
  4335. }
  4336. declare module BABYLON {
  4337. class UniversalCamera extends TouchCamera {
  4338. gamepadAngularSensibility: number;
  4339. gamepadMoveSensibility: number;
  4340. constructor(name: string, position: Vector3, scene: Scene);
  4341. getClassName(): string;
  4342. }
  4343. }
  4344. declare module BABYLON {
  4345. class VirtualJoysticksCamera extends FreeCamera {
  4346. constructor(name: string, position: Vector3, scene: Scene);
  4347. getClassName(): string;
  4348. }
  4349. }
  4350. interface VRDisplay extends EventTarget {
  4351. /**
  4352. * Dictionary of capabilities describing the VRDisplay.
  4353. */
  4354. readonly capabilities: VRDisplayCapabilities;
  4355. /**
  4356. * z-depth defining the far plane of the eye view frustum
  4357. * enables mapping of values in the render target depth
  4358. * attachment to scene coordinates. Initially set to 10000.0.
  4359. */
  4360. depthFar: number;
  4361. /**
  4362. * z-depth defining the near plane of the eye view frustum
  4363. * enables mapping of values in the render target depth
  4364. * attachment to scene coordinates. Initially set to 0.01.
  4365. */
  4366. depthNear: number;
  4367. /**
  4368. * An identifier for this distinct VRDisplay. Used as an
  4369. * association point in the Gamepad API.
  4370. */
  4371. readonly displayId: number;
  4372. /**
  4373. * A display name, a user-readable name identifying it.
  4374. */
  4375. readonly displayName: string;
  4376. readonly isConnected: boolean;
  4377. readonly isPresenting: boolean;
  4378. /**
  4379. * If this VRDisplay supports room-scale experiences, the optional
  4380. * stage attribute contains details on the room-scale parameters.
  4381. */
  4382. readonly stageParameters: VRStageParameters | null;
  4383. /**
  4384. * Passing the value returned by `requestAnimationFrame` to
  4385. * `cancelAnimationFrame` will unregister the callback.
  4386. */
  4387. cancelAnimationFrame(handle: number): void;
  4388. /**
  4389. * Stops presenting to the VRDisplay.
  4390. */
  4391. exitPresent(): Promise<void>;
  4392. getEyeParameters(whichEye: string): VREyeParameters;
  4393. /**
  4394. * Populates the passed VRFrameData with the information required to render
  4395. * the current frame.
  4396. */
  4397. getFrameData(frameData: VRFrameData): boolean;
  4398. /**
  4399. * Get the layers currently being presented.
  4400. */
  4401. getLayers(): VRLayer[];
  4402. /**
  4403. * Return a VRPose containing the future predicted pose of the VRDisplay
  4404. * when the current frame will be presented. The value returned will not
  4405. * change until JavaScript has returned control to the browser.
  4406. *
  4407. * The VRPose will contain the position, orientation, velocity,
  4408. * and acceleration of each of these properties.
  4409. */
  4410. getPose(): VRPose;
  4411. /**
  4412. * Return the current instantaneous pose of the VRDisplay, with no
  4413. * prediction applied.
  4414. */
  4415. getImmediatePose(): VRPose;
  4416. /**
  4417. * The callback passed to `requestAnimationFrame` will be called
  4418. * any time a new frame should be rendered. When the VRDisplay is
  4419. * presenting the callback will be called at the native refresh
  4420. * rate of the HMD. When not presenting this function acts
  4421. * identically to how window.requestAnimationFrame acts. Content should
  4422. * make no assumptions of frame rate or vsync behavior as the HMD runs
  4423. * asynchronously from other displays and at differing refresh rates.
  4424. */
  4425. requestAnimationFrame(callback: FrameRequestCallback): number;
  4426. /**
  4427. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  4428. * Repeat calls while already presenting will update the VRLayers being displayed.
  4429. */
  4430. requestPresent(layers: VRLayer[]): Promise<void>;
  4431. /**
  4432. * Reset the pose for this display, treating its current position and
  4433. * orientation as the "origin/zero" values. VRPose.position,
  4434. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  4435. * updated when calling resetPose(). This should be called in only
  4436. * sitting-space experiences.
  4437. */
  4438. resetPose(): void;
  4439. /**
  4440. * The VRLayer provided to the VRDisplay will be captured and presented
  4441. * in the HMD. Calling this function has the same effect on the source
  4442. * canvas as any other operation that uses its source image, and canvases
  4443. * created without preserveDrawingBuffer set to true will be cleared.
  4444. */
  4445. submitFrame(pose?: VRPose): void;
  4446. }
  4447. declare var VRDisplay: {
  4448. prototype: VRDisplay;
  4449. new (): VRDisplay;
  4450. };
  4451. interface VRLayer {
  4452. leftBounds?: number[] | null;
  4453. rightBounds?: number[] | null;
  4454. source?: HTMLCanvasElement | null;
  4455. }
  4456. interface VRDisplayCapabilities {
  4457. readonly canPresent: boolean;
  4458. readonly hasExternalDisplay: boolean;
  4459. readonly hasOrientation: boolean;
  4460. readonly hasPosition: boolean;
  4461. readonly maxLayers: number;
  4462. }
  4463. interface VREyeParameters {
  4464. /** @deprecated */
  4465. readonly fieldOfView: VRFieldOfView;
  4466. readonly offset: Float32Array;
  4467. readonly renderHeight: number;
  4468. readonly renderWidth: number;
  4469. }
  4470. interface VRFieldOfView {
  4471. readonly downDegrees: number;
  4472. readonly leftDegrees: number;
  4473. readonly rightDegrees: number;
  4474. readonly upDegrees: number;
  4475. }
  4476. interface VRFrameData {
  4477. readonly leftProjectionMatrix: Float32Array;
  4478. readonly leftViewMatrix: Float32Array;
  4479. readonly pose: VRPose;
  4480. readonly rightProjectionMatrix: Float32Array;
  4481. readonly rightViewMatrix: Float32Array;
  4482. readonly timestamp: number;
  4483. }
  4484. interface VRPose {
  4485. readonly angularAcceleration: Float32Array | null;
  4486. readonly angularVelocity: Float32Array | null;
  4487. readonly linearAcceleration: Float32Array | null;
  4488. readonly linearVelocity: Float32Array | null;
  4489. readonly orientation: Float32Array | null;
  4490. readonly position: Float32Array | null;
  4491. readonly timestamp: number;
  4492. }
  4493. interface VRStageParameters {
  4494. sittingToStandingTransform?: Float32Array;
  4495. sizeX?: number;
  4496. sizeY?: number;
  4497. }
  4498. interface Navigator {
  4499. getVRDisplays(): Promise<VRDisplay[]>;
  4500. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  4501. }
  4502. interface Window {
  4503. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  4504. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  4505. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  4506. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  4507. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  4508. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  4509. }
  4510. interface Gamepad {
  4511. readonly displayId: number;
  4512. }
  4513. declare module BABYLON {
  4514. class DebugLayer {
  4515. private _scene;
  4516. static InspectorURL: string;
  4517. private _inspector;
  4518. private BJSINSPECTOR;
  4519. constructor(scene: Scene);
  4520. /** Creates the inspector window. */
  4521. private _createInspector(config?);
  4522. isVisible(): boolean;
  4523. hide(): void;
  4524. show(config?: {
  4525. popup?: boolean;
  4526. initialTab?: number;
  4527. parentElement?: HTMLElement;
  4528. newColors?: {
  4529. backgroundColor?: string;
  4530. backgroundColorLighter?: string;
  4531. backgroundColorLighter2?: string;
  4532. backgroundColorLighter3?: string;
  4533. color?: string;
  4534. colorTop?: string;
  4535. colorBot?: string;
  4536. };
  4537. }): void;
  4538. }
  4539. }
  4540. declare module BABYLON {
  4541. class Debug {
  4542. static AxesViewer: {
  4543. new (scene: Scene, scaleLines?: number): {
  4544. _xline: Vector3[];
  4545. _yline: Vector3[];
  4546. _zline: Vector3[];
  4547. _xmesh: Nullable<LinesMesh>;
  4548. _ymesh: Nullable<LinesMesh>;
  4549. _zmesh: Nullable<LinesMesh>;
  4550. scene: Nullable<Scene>;
  4551. scaleLines: number;
  4552. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  4553. dispose(): void;
  4554. };
  4555. };
  4556. static BoneAxesViewer: {
  4557. new (scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number): {
  4558. mesh: Nullable<Mesh>;
  4559. bone: Nullable<Bone>;
  4560. pos: Vector3;
  4561. xaxis: Vector3;
  4562. yaxis: Vector3;
  4563. zaxis: Vector3;
  4564. update(): void;
  4565. dispose(): void;
  4566. _xline: Vector3[];
  4567. _yline: Vector3[];
  4568. _zline: Vector3[];
  4569. _xmesh: Nullable<LinesMesh>;
  4570. _ymesh: Nullable<LinesMesh>;
  4571. _zmesh: Nullable<LinesMesh>;
  4572. scene: Nullable<Scene>;
  4573. scaleLines: number;
  4574. };
  4575. };
  4576. static PhysicsViewer: {
  4577. new (scene: Scene): {
  4578. _impostors: Nullable<PhysicsImpostor>[];
  4579. _meshes: Nullable<AbstractMesh>[];
  4580. _scene: Nullable<Scene>;
  4581. _numMeshes: number;
  4582. _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  4583. _renderFunction: () => void;
  4584. _debugBoxMesh: Mesh;
  4585. _debugSphereMesh: Mesh;
  4586. _debugMaterial: StandardMaterial;
  4587. _updateDebugMeshes(): void;
  4588. showImpostor(impostor: PhysicsImpostor): void;
  4589. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  4590. _getDebugMaterial(scene: Scene): Material;
  4591. _getDebugBoxMesh(scene: Scene): AbstractMesh;
  4592. _getDebugSphereMesh(scene: Scene): AbstractMesh;
  4593. _getDebugMesh(impostor: PhysicsImpostor, scene: Scene): Nullable<AbstractMesh>;
  4594. dispose(): void;
  4595. };
  4596. };
  4597. static SkeletonViewer: {
  4598. new (skeleton: Skeleton, mesh: AbstractMesh, scene: Scene, autoUpdateBonesMatrices?: boolean, renderingGroupId?: number): {
  4599. color: Color3;
  4600. _scene: Scene;
  4601. _debugLines: Vector3[][];
  4602. _debugMesh: Nullable<LinesMesh>;
  4603. _isEnabled: boolean;
  4604. _renderFunction: () => void;
  4605. skeleton: Skeleton;
  4606. mesh: AbstractMesh;
  4607. autoUpdateBonesMatrices: boolean;
  4608. renderingGroupId: number;
  4609. isEnabled: boolean;
  4610. _getBonePosition(position: Vector3, bone: Bone, meshMat: Matrix, x?: number, y?: number, z?: number): void;
  4611. _getLinesForBonesWithLength(bones: Bone[], meshMat: Matrix): void;
  4612. _getLinesForBonesNoLength(bones: Bone[], meshMat: Matrix): void;
  4613. update(): void;
  4614. dispose(): void;
  4615. };
  4616. };
  4617. }
  4618. }
  4619. declare module BABYLON {
  4620. class RayHelper {
  4621. ray: Nullable<Ray>;
  4622. private _renderPoints;
  4623. private _renderLine;
  4624. private _renderFunction;
  4625. private _scene;
  4626. private _updateToMeshFunction;
  4627. private _attachedToMesh;
  4628. private _meshSpaceDirection;
  4629. private _meshSpaceOrigin;
  4630. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  4631. constructor(ray: Ray);
  4632. show(scene: Scene, color: Color3): void;
  4633. hide(): void;
  4634. private _render();
  4635. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  4636. detachFromMesh(): void;
  4637. private _updateToMesh();
  4638. dispose(): void;
  4639. }
  4640. }
  4641. declare module BABYLON {
  4642. class BoundingBox implements ICullable {
  4643. minimum: Vector3;
  4644. maximum: Vector3;
  4645. vectors: Vector3[];
  4646. center: Vector3;
  4647. centerWorld: Vector3;
  4648. extendSize: Vector3;
  4649. extendSizeWorld: Vector3;
  4650. directions: Vector3[];
  4651. vectorsWorld: Vector3[];
  4652. minimumWorld: Vector3;
  4653. maximumWorld: Vector3;
  4654. private _worldMatrix;
  4655. constructor(minimum: Vector3, maximum: Vector3);
  4656. getWorldMatrix(): Matrix;
  4657. setWorldMatrix(matrix: Matrix): BoundingBox;
  4658. _update(world: Matrix): void;
  4659. isInFrustum(frustumPlanes: Plane[]): boolean;
  4660. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  4661. intersectsPoint(point: Vector3): boolean;
  4662. intersectsSphere(sphere: BoundingSphere): boolean;
  4663. intersectsMinMax(min: Vector3, max: Vector3): boolean;
  4664. static Intersects(box0: BoundingBox, box1: BoundingBox): boolean;
  4665. static IntersectsSphere(minPoint: Vector3, maxPoint: Vector3, sphereCenter: Vector3, sphereRadius: number): boolean;
  4666. static IsCompletelyInFrustum(boundingVectors: Vector3[], frustumPlanes: Plane[]): boolean;
  4667. static IsInFrustum(boundingVectors: Vector3[], frustumPlanes: Plane[]): boolean;
  4668. }
  4669. }
  4670. declare module BABYLON {
  4671. interface ICullable {
  4672. isInFrustum(frustumPlanes: Plane[]): boolean;
  4673. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  4674. }
  4675. class BoundingInfo implements ICullable {
  4676. minimum: Vector3;
  4677. maximum: Vector3;
  4678. boundingBox: BoundingBox;
  4679. boundingSphere: BoundingSphere;
  4680. private _isLocked;
  4681. constructor(minimum: Vector3, maximum: Vector3);
  4682. isLocked: boolean;
  4683. update(world: Matrix): void;
  4684. /**
  4685. * Recreate the bounding info to be centered around a specific point given a specific extend.
  4686. * @param center New center of the bounding info
  4687. * @param extend New extend of the bounding info
  4688. */
  4689. centerOn(center: Vector3, extend: Vector3): BoundingInfo;
  4690. isInFrustum(frustumPlanes: Plane[]): boolean;
  4691. /**
  4692. * Gets the world distance between the min and max points of the bounding box
  4693. */
  4694. readonly diagonalLength: number;
  4695. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  4696. _checkCollision(collider: Collider): boolean;
  4697. intersectsPoint(point: Vector3): boolean;
  4698. intersects(boundingInfo: BoundingInfo, precise: boolean): boolean;
  4699. }
  4700. }
  4701. declare module BABYLON {
  4702. class BoundingSphere {
  4703. minimum: Vector3;
  4704. maximum: Vector3;
  4705. center: Vector3;
  4706. radius: number;
  4707. centerWorld: Vector3;
  4708. radiusWorld: number;
  4709. private _tempRadiusVector;
  4710. constructor(minimum: Vector3, maximum: Vector3);
  4711. _update(world: Matrix): void;
  4712. isInFrustum(frustumPlanes: Plane[]): boolean;
  4713. intersectsPoint(point: Vector3): boolean;
  4714. static Intersects(sphere0: BoundingSphere, sphere1: BoundingSphere): boolean;
  4715. }
  4716. }
  4717. declare module BABYLON {
  4718. class Ray {
  4719. origin: Vector3;
  4720. direction: Vector3;
  4721. length: number;
  4722. private _edge1;
  4723. private _edge2;
  4724. private _pvec;
  4725. private _tvec;
  4726. private _qvec;
  4727. private _tmpRay;
  4728. constructor(origin: Vector3, direction: Vector3, length?: number);
  4729. intersectsBoxMinMax(minimum: Vector3, maximum: Vector3): boolean;
  4730. intersectsBox(box: BoundingBox): boolean;
  4731. intersectsSphere(sphere: BoundingSphere): boolean;
  4732. intersectsTriangle(vertex0: Vector3, vertex1: Vector3, vertex2: Vector3): Nullable<IntersectionInfo>;
  4733. intersectsPlane(plane: Plane): Nullable<number>;
  4734. intersectsMesh(mesh: AbstractMesh, fastCheck?: boolean): PickingInfo;
  4735. intersectsMeshes(meshes: Array<AbstractMesh>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  4736. private _comparePickingInfo(pickingInfoA, pickingInfoB);
  4737. private static smallnum;
  4738. private static rayl;
  4739. /**
  4740. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  4741. * @param sega the first point of the segment to test the intersection against
  4742. * @param segb the second point of the segment to test the intersection against
  4743. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  4744. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  4745. */
  4746. intersectionSegment(sega: Vector3, segb: Vector3, threshold: number): number;
  4747. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix): Ray;
  4748. static Zero(): Ray;
  4749. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix): Ray;
  4750. /**
  4751. * 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
  4752. * transformed to the given world matrix.
  4753. * @param origin The origin point
  4754. * @param end The end point
  4755. * @param world a matrix to transform the ray to. Default is the identity matrix.
  4756. */
  4757. static CreateNewFromTo(origin: Vector3, end: Vector3, world?: Matrix): Ray;
  4758. static Transform(ray: Ray, matrix: Matrix): Ray;
  4759. static TransformToRef(ray: Ray, matrix: Matrix, result: Ray): void;
  4760. }
  4761. }
  4762. declare module BABYLON {
  4763. class InstancingAttributeInfo {
  4764. /**
  4765. * Index/offset of the attribute in the vertex shader
  4766. */
  4767. index: number;
  4768. /**
  4769. * size of the attribute, 1, 2, 3 or 4
  4770. */
  4771. attributeSize: number;
  4772. /**
  4773. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  4774. * default is FLOAT
  4775. */
  4776. attribyteType: number;
  4777. /**
  4778. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  4779. */
  4780. normalized: boolean;
  4781. /**
  4782. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  4783. */
  4784. offset: number;
  4785. /**
  4786. * Name of the GLSL attribute, for debugging purpose only
  4787. */
  4788. attributeName: string;
  4789. }
  4790. /**
  4791. * Define options used to create a render target texture
  4792. */
  4793. class RenderTargetCreationOptions {
  4794. /**
  4795. * Specifies is mipmaps must be generated
  4796. */
  4797. generateMipMaps?: boolean;
  4798. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  4799. generateDepthBuffer?: boolean;
  4800. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  4801. generateStencilBuffer?: boolean;
  4802. /** Defines texture type (int by default) */
  4803. type?: number;
  4804. /** Defines sampling mode (trilinear by default) */
  4805. samplingMode?: number;
  4806. /** Defines format (RGBA by default) */
  4807. format?: number;
  4808. }
  4809. /**
  4810. * Define options used to create a depth texture
  4811. */
  4812. class DepthTextureCreationOptions {
  4813. /** Specifies whether or not a stencil should be allocated in the texture */
  4814. generateStencil?: boolean;
  4815. /** Specifies whether or not bilinear filtering is enable on the texture */
  4816. bilinearFiltering?: boolean;
  4817. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  4818. comparisonFunction?: number;
  4819. /** Specifies if the created texture is a cube texture */
  4820. isCube?: boolean;
  4821. }
  4822. /**
  4823. * Regroup several parameters relative to the browser in use
  4824. */
  4825. class EngineCapabilities {
  4826. /** The maximum textures image */
  4827. maxTexturesImageUnits: number;
  4828. maxVertexTextureImageUnits: number;
  4829. maxCombinedTexturesImageUnits: number;
  4830. /** The maximum texture size */
  4831. maxTextureSize: number;
  4832. maxCubemapTextureSize: number;
  4833. maxRenderTextureSize: number;
  4834. maxVertexAttribs: number;
  4835. maxVaryingVectors: number;
  4836. maxVertexUniformVectors: number;
  4837. maxFragmentUniformVectors: number;
  4838. standardDerivatives: boolean;
  4839. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  4840. pvrtc: any;
  4841. etc1: any;
  4842. etc2: any;
  4843. astc: any;
  4844. textureFloat: boolean;
  4845. vertexArrayObject: boolean;
  4846. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  4847. maxAnisotropy: number;
  4848. instancedArrays: boolean;
  4849. uintIndices: boolean;
  4850. highPrecisionShaderSupported: boolean;
  4851. fragmentDepthSupported: boolean;
  4852. textureFloatLinearFiltering: boolean;
  4853. textureFloatRender: boolean;
  4854. textureHalfFloat: boolean;
  4855. textureHalfFloatLinearFiltering: boolean;
  4856. textureHalfFloatRender: boolean;
  4857. textureLOD: boolean;
  4858. drawBuffersExtension: boolean;
  4859. depthTextureExtension: boolean;
  4860. colorBufferFloat: boolean;
  4861. timerQuery: EXT_disjoint_timer_query;
  4862. canUseTimestampForTimerQuery: boolean;
  4863. }
  4864. interface EngineOptions extends WebGLContextAttributes {
  4865. limitDeviceRatio?: number;
  4866. autoEnableWebVR?: boolean;
  4867. disableWebGL2Support?: boolean;
  4868. audioEngine?: boolean;
  4869. deterministicLockstep?: boolean;
  4870. lockstepMaxSteps?: number;
  4871. doNotHandleContextLost?: boolean;
  4872. }
  4873. interface IDisplayChangedEventArgs {
  4874. vrDisplay: Nullable<any>;
  4875. vrSupported: boolean;
  4876. }
  4877. /**
  4878. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio.
  4879. */
  4880. class Engine {
  4881. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  4882. static ExceptionList: ({
  4883. key: string;
  4884. capture: string;
  4885. captureConstraint: number;
  4886. targets: string[];
  4887. } | {
  4888. key: string;
  4889. capture: null;
  4890. captureConstraint: null;
  4891. targets: string[];
  4892. })[];
  4893. static Instances: Engine[];
  4894. static readonly LastCreatedEngine: Nullable<Engine>;
  4895. static readonly LastCreatedScene: Nullable<Scene>;
  4896. /**
  4897. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  4898. */
  4899. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  4900. private static _ALPHA_DISABLE;
  4901. private static _ALPHA_ADD;
  4902. private static _ALPHA_COMBINE;
  4903. private static _ALPHA_SUBTRACT;
  4904. private static _ALPHA_MULTIPLY;
  4905. private static _ALPHA_MAXIMIZED;
  4906. private static _ALPHA_ONEONE;
  4907. private static _ALPHA_PREMULTIPLIED;
  4908. private static _ALPHA_PREMULTIPLIED_PORTERDUFF;
  4909. private static _ALPHA_INTERPOLATE;
  4910. private static _ALPHA_SCREENMODE;
  4911. private static _DELAYLOADSTATE_NONE;
  4912. private static _DELAYLOADSTATE_LOADED;
  4913. private static _DELAYLOADSTATE_LOADING;
  4914. private static _DELAYLOADSTATE_NOTLOADED;
  4915. private static _TEXTUREFORMAT_ALPHA;
  4916. private static _TEXTUREFORMAT_LUMINANCE;
  4917. private static _TEXTUREFORMAT_LUMINANCE_ALPHA;
  4918. private static _TEXTUREFORMAT_RGB;
  4919. private static _TEXTUREFORMAT_RGBA;
  4920. private static _TEXTUREFORMAT_R32F;
  4921. private static _TEXTUREFORMAT_RG32F;
  4922. private static _TEXTUREFORMAT_RGB32F;
  4923. private static _TEXTUREFORMAT_RGBA32F;
  4924. private static _TEXTURETYPE_UNSIGNED_INT;
  4925. private static _TEXTURETYPE_FLOAT;
  4926. private static _TEXTURETYPE_HALF_FLOAT;
  4927. private static _NEVER;
  4928. private static _ALWAYS;
  4929. private static _LESS;
  4930. private static _EQUAL;
  4931. private static _LEQUAL;
  4932. private static _GREATER;
  4933. private static _GEQUAL;
  4934. private static _NOTEQUAL;
  4935. static readonly NEVER: number;
  4936. static readonly ALWAYS: number;
  4937. static readonly LESS: number;
  4938. static readonly EQUAL: number;
  4939. static readonly LEQUAL: number;
  4940. static readonly GREATER: number;
  4941. static readonly GEQUAL: number;
  4942. static readonly NOTEQUAL: number;
  4943. private static _KEEP;
  4944. private static _REPLACE;
  4945. private static _INCR;
  4946. private static _DECR;
  4947. private static _INVERT;
  4948. private static _INCR_WRAP;
  4949. private static _DECR_WRAP;
  4950. static readonly KEEP: number;
  4951. static readonly REPLACE: number;
  4952. static readonly INCR: number;
  4953. static readonly DECR: number;
  4954. static readonly INVERT: number;
  4955. static readonly INCR_WRAP: number;
  4956. static readonly DECR_WRAP: number;
  4957. static readonly ALPHA_DISABLE: number;
  4958. static readonly ALPHA_ONEONE: number;
  4959. static readonly ALPHA_ADD: number;
  4960. static readonly ALPHA_COMBINE: number;
  4961. static readonly ALPHA_SUBTRACT: number;
  4962. static readonly ALPHA_MULTIPLY: number;
  4963. static readonly ALPHA_MAXIMIZED: number;
  4964. static readonly ALPHA_PREMULTIPLIED: number;
  4965. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  4966. static readonly ALPHA_INTERPOLATE: number;
  4967. static readonly ALPHA_SCREENMODE: number;
  4968. static readonly DELAYLOADSTATE_NONE: number;
  4969. static readonly DELAYLOADSTATE_LOADED: number;
  4970. static readonly DELAYLOADSTATE_LOADING: number;
  4971. static readonly DELAYLOADSTATE_NOTLOADED: number;
  4972. static readonly TEXTUREFORMAT_ALPHA: number;
  4973. static readonly TEXTUREFORMAT_LUMINANCE: number;
  4974. /**
  4975. * R32F
  4976. */
  4977. static readonly TEXTUREFORMAT_R32F: number;
  4978. /**
  4979. * RG32F
  4980. */
  4981. static readonly TEXTUREFORMAT_RG32F: number;
  4982. /**
  4983. * RGB32F
  4984. */
  4985. static readonly TEXTUREFORMAT_RGB32F: number;
  4986. /**
  4987. * RGBA32F
  4988. */
  4989. static readonly TEXTUREFORMAT_RGBA32F: number;
  4990. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  4991. static readonly TEXTUREFORMAT_RGB: number;
  4992. static readonly TEXTUREFORMAT_RGBA: number;
  4993. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  4994. static readonly TEXTURETYPE_FLOAT: number;
  4995. static readonly TEXTURETYPE_HALF_FLOAT: number;
  4996. private static _SCALEMODE_FLOOR;
  4997. private static _SCALEMODE_NEAREST;
  4998. private static _SCALEMODE_CEILING;
  4999. static readonly SCALEMODE_FLOOR: number;
  5000. static readonly SCALEMODE_NEAREST: number;
  5001. static readonly SCALEMODE_CEILING: number;
  5002. static readonly Version: string;
  5003. static CollisionsEpsilon: number;
  5004. static CodeRepository: string;
  5005. static ShadersRepository: string;
  5006. forcePOTTextures: boolean;
  5007. isFullscreen: boolean;
  5008. isPointerLock: boolean;
  5009. cullBackFaces: boolean;
  5010. renderEvenInBackground: boolean;
  5011. preventCacheWipeBetweenFrames: boolean;
  5012. /**
  5013. * To enable/disable IDB support and avoid XHR on .manifest
  5014. **/
  5015. enableOfflineSupport: boolean;
  5016. scenes: Scene[];
  5017. postProcesses: PostProcess[];
  5018. /**
  5019. * Observable event triggered each time the rendering canvas is resized
  5020. */
  5021. onResizeObservable: Observable<Engine>;
  5022. /**
  5023. * Observable event triggered each time the canvas loses focus
  5024. */
  5025. onCanvasBlurObservable: Observable<Engine>;
  5026. /**
  5027. * Observable event triggered each time the canvas gains focus
  5028. */
  5029. onCanvasFocusObservable: Observable<Engine>;
  5030. /**
  5031. * Observable event triggered each time the canvas receives pointerout event
  5032. */
  5033. onCanvasPointerOutObservable: Observable<PointerEvent>;
  5034. /**
  5035. * Observable event triggered before each texture is initialized
  5036. */
  5037. onBeforeTextureInitObservable: Observable<Texture>;
  5038. private _vrDisplay;
  5039. private _vrSupported;
  5040. private _oldSize;
  5041. private _oldHardwareScaleFactor;
  5042. private _vrExclusivePointerMode;
  5043. private _webVRInitPromise;
  5044. readonly isInVRExclusivePointerMode: boolean;
  5045. disableUniformBuffers: boolean;
  5046. _uniformBuffers: UniformBuffer[];
  5047. readonly supportsUniformBuffers: boolean;
  5048. /**
  5049. * Observable raised when the engine begins a new frame
  5050. */
  5051. onBeginFrameObservable: Observable<Engine>;
  5052. /**
  5053. * Observable raised when the engine ends the current frame
  5054. */
  5055. onEndFrameObservable: Observable<Engine>;
  5056. /**
  5057. * Observable raised when the engine is about to compile a shader
  5058. */
  5059. onBeforeShaderCompilationObservable: Observable<Engine>;
  5060. /**
  5061. * Observable raised when the engine has jsut compiled a shader
  5062. */
  5063. onAfterShaderCompilationObservable: Observable<Engine>;
  5064. private _gl;
  5065. private _renderingCanvas;
  5066. private _windowIsBackground;
  5067. private _webGLVersion;
  5068. readonly needPOTTextures: boolean;
  5069. private _badOS;
  5070. readonly badOS: boolean;
  5071. private _badDesktopOS;
  5072. readonly badDesktopOS: boolean;
  5073. /**
  5074. * Gets or sets a value indicating if we want to disable texture binding optmization.
  5075. * This could be required on some buggy drivers which wants to have textures bound in a progressive order
  5076. * By default Babylon.js will try to let textures bound where they are and only update the samplers to point where the texture is.
  5077. */
  5078. disableTextureBindingOptimization: boolean;
  5079. static audioEngine: AudioEngine;
  5080. private _onFocus;
  5081. private _onBlur;
  5082. private _onCanvasPointerOut;
  5083. private _onCanvasBlur;
  5084. private _onCanvasFocus;
  5085. private _onFullscreenChange;
  5086. private _onPointerLockChange;
  5087. private _onVRDisplayPointerRestricted;
  5088. private _onVRDisplayPointerUnrestricted;
  5089. private _onVrDisplayConnect;
  5090. private _onVrDisplayDisconnect;
  5091. private _onVrDisplayPresentChange;
  5092. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  5093. onVRRequestPresentComplete: Observable<boolean>;
  5094. onVRRequestPresentStart: Observable<Engine>;
  5095. private _hardwareScalingLevel;
  5096. protected _caps: EngineCapabilities;
  5097. private _pointerLockRequested;
  5098. private _isStencilEnable;
  5099. private _colorWrite;
  5100. private _loadingScreen;
  5101. _drawCalls: PerfCounter;
  5102. _textureCollisions: PerfCounter;
  5103. private _glVersion;
  5104. private _glRenderer;
  5105. private _glVendor;
  5106. private _videoTextureSupported;
  5107. private _renderingQueueLaunched;
  5108. private _activeRenderLoops;
  5109. private _deterministicLockstep;
  5110. private _lockstepMaxSteps;
  5111. onContextLostObservable: Observable<Engine>;
  5112. onContextRestoredObservable: Observable<Engine>;
  5113. private _onContextLost;
  5114. private _onContextRestored;
  5115. private _contextWasLost;
  5116. private _doNotHandleContextLost;
  5117. private _performanceMonitor;
  5118. private _fps;
  5119. private _deltaTime;
  5120. /**
  5121. * Turn this value on if you want to pause FPS computation when in background
  5122. */
  5123. disablePerformanceMonitorInBackground: boolean;
  5124. readonly performanceMonitor: PerformanceMonitor;
  5125. protected _depthCullingState: _DepthCullingState;
  5126. protected _stencilState: _StencilState;
  5127. protected _alphaState: _AlphaState;
  5128. protected _alphaMode: number;
  5129. private _internalTexturesCache;
  5130. protected _activeChannel: number;
  5131. private _currentTextureChannel;
  5132. protected _boundTexturesCache: {
  5133. [key: string]: Nullable<InternalTexture>;
  5134. };
  5135. protected _currentEffect: Nullable<Effect>;
  5136. protected _currentProgram: Nullable<WebGLProgram>;
  5137. private _compiledEffects;
  5138. private _vertexAttribArraysEnabled;
  5139. protected _cachedViewport: Nullable<Viewport>;
  5140. private _cachedVertexArrayObject;
  5141. protected _cachedVertexBuffers: any;
  5142. protected _cachedIndexBuffer: Nullable<WebGLBuffer>;
  5143. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  5144. protected _currentRenderTarget: Nullable<InternalTexture>;
  5145. private _uintIndicesCurrentlySet;
  5146. private _currentBoundBuffer;
  5147. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  5148. private _currentBufferPointers;
  5149. private _currentInstanceLocations;
  5150. private _currentInstanceBuffers;
  5151. private _textureUnits;
  5152. private _firstBoundInternalTextureTracker;
  5153. private _lastBoundInternalTextureTracker;
  5154. private _workingCanvas;
  5155. private _workingContext;
  5156. private _rescalePostProcess;
  5157. private _dummyFramebuffer;
  5158. private _externalData;
  5159. private _bindedRenderFunction;
  5160. private _vaoRecordInProgress;
  5161. private _mustWipeVertexAttributes;
  5162. private _emptyTexture;
  5163. private _emptyCubeTexture;
  5164. private _emptyTexture3D;
  5165. private _frameHandler;
  5166. private _nextFreeTextureSlots;
  5167. private _maxSimultaneousTextures;
  5168. private _activeRequests;
  5169. private _texturesSupported;
  5170. private _textureFormatInUse;
  5171. readonly texturesSupported: Array<string>;
  5172. readonly textureFormatInUse: Nullable<string>;
  5173. readonly currentViewport: Nullable<Viewport>;
  5174. readonly emptyTexture: InternalTexture;
  5175. readonly emptyTexture3D: InternalTexture;
  5176. readonly emptyCubeTexture: InternalTexture;
  5177. /**
  5178. * @constructor
  5179. * @param canvasOrContext defines the canvas or WebGL context to use for rendering
  5180. * @param antialias defines enable antialiasing (default: false)
  5181. * @param options defines further options to be sent to the getContext() function
  5182. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  5183. */
  5184. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  5185. private _rebuildInternalTextures();
  5186. private _rebuildEffects();
  5187. private _rebuildBuffers();
  5188. private _initGLContext();
  5189. readonly webGLVersion: number;
  5190. /**
  5191. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  5192. */
  5193. readonly isStencilEnable: boolean;
  5194. private _prepareWorkingCanvas();
  5195. resetTextureCache(): void;
  5196. isDeterministicLockStep(): boolean;
  5197. getLockstepMaxSteps(): number;
  5198. getGlInfo(): {
  5199. vendor: string;
  5200. renderer: string;
  5201. version: string;
  5202. };
  5203. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  5204. getRenderWidth(useScreen?: boolean): number;
  5205. getRenderHeight(useScreen?: boolean): number;
  5206. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  5207. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  5208. setHardwareScalingLevel(level: number): void;
  5209. getHardwareScalingLevel(): number;
  5210. getLoadedTexturesCache(): InternalTexture[];
  5211. getCaps(): EngineCapabilities;
  5212. /** The number of draw calls submitted last frame */
  5213. readonly drawCalls: number;
  5214. readonly drawCallsPerfCounter: Nullable<PerfCounter>;
  5215. getDepthFunction(): Nullable<number>;
  5216. setDepthFunction(depthFunc: number): void;
  5217. setDepthFunctionToGreater(): void;
  5218. setDepthFunctionToGreaterOrEqual(): void;
  5219. setDepthFunctionToLess(): void;
  5220. setDepthFunctionToLessOrEqual(): void;
  5221. getStencilBuffer(): boolean;
  5222. setStencilBuffer(enable: boolean): void;
  5223. getStencilMask(): number;
  5224. setStencilMask(mask: number): void;
  5225. getStencilFunction(): number;
  5226. getStencilFunctionReference(): number;
  5227. getStencilFunctionMask(): number;
  5228. setStencilFunction(stencilFunc: number): void;
  5229. setStencilFunctionReference(reference: number): void;
  5230. setStencilFunctionMask(mask: number): void;
  5231. getStencilOperationFail(): number;
  5232. getStencilOperationDepthFail(): number;
  5233. getStencilOperationPass(): number;
  5234. setStencilOperationFail(operation: number): void;
  5235. setStencilOperationDepthFail(operation: number): void;
  5236. setStencilOperationPass(operation: number): void;
  5237. setDitheringState(value: boolean): void;
  5238. setRasterizerState(value: boolean): void;
  5239. /**
  5240. * stop executing a render loop function and remove it from the execution array
  5241. * @param {Function} [renderFunction] the function to be removed. If not provided all functions will be removed.
  5242. */
  5243. stopRenderLoop(renderFunction?: () => void): void;
  5244. _renderLoop(): void;
  5245. /**
  5246. * Register and execute a render loop. The engine can have more than one render function.
  5247. * @param {Function} renderFunction - the function to continuously execute starting the next render loop.
  5248. * @example
  5249. * engine.runRenderLoop(function () {
  5250. * scene.render()
  5251. * })
  5252. */
  5253. runRenderLoop(renderFunction: () => void): void;
  5254. /**
  5255. * Toggle full screen mode.
  5256. * @param {boolean} requestPointerLock - should a pointer lock be requested from the user
  5257. * @param {any} options - an options object to be sent to the requestFullscreen function
  5258. */
  5259. switchFullscreen(requestPointerLock: boolean): void;
  5260. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  5261. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  5262. /**
  5263. * Set the WebGL's viewport
  5264. * @param {BABYLON.Viewport} viewport - the viewport element to be used.
  5265. * @param {number} [requiredWidth] - the width required for rendering. If not provided the rendering canvas' width is used.
  5266. * @param {number} [requiredHeight] - the height required for rendering. If not provided the rendering canvas' height is used.
  5267. */
  5268. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  5269. /**
  5270. * Directly set the WebGL Viewport
  5271. * The x, y, width & height are directly passed to the WebGL call
  5272. * @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.
  5273. */
  5274. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  5275. beginFrame(): void;
  5276. endFrame(): void;
  5277. /**
  5278. * resize the view according to the canvas' size.
  5279. * @example
  5280. * window.addEventListener("resize", function () {
  5281. * engine.resize();
  5282. * });
  5283. */
  5284. resize(): void;
  5285. /**
  5286. * force a specific size of the canvas
  5287. * @param {number} width - the new canvas' width
  5288. * @param {number} height - the new canvas' height
  5289. */
  5290. setSize(width: number, height: number): void;
  5291. isVRDevicePresent(): boolean;
  5292. getVRDevice(): any;
  5293. /**
  5294. * Initializes a webVR display and starts listening to display change events.
  5295. * The onVRDisplayChangedObservable will be notified upon these changes.
  5296. * @returns The onVRDisplayChangedObservable.
  5297. */
  5298. initWebVR(): Observable<IDisplayChangedEventArgs>;
  5299. /**
  5300. * Initializes a webVR display and starts listening to display change events.
  5301. * The onVRDisplayChangedObservable will be notified upon these changes.
  5302. * @returns A promise containing a VRDisplay and if vr is supported.
  5303. */
  5304. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  5305. enableVR(): void;
  5306. disableVR(): void;
  5307. private _onVRFullScreenTriggered;
  5308. private _getVRDisplaysAsync();
  5309. /**
  5310. * Binds the frame buffer to the specified texture.
  5311. * @param texture The texture to render to or null for the default canvas
  5312. * @param faceIndex The face of the texture to render to in case of cube texture
  5313. * @param requiredWidth The width of the target to render to
  5314. * @param requiredHeight The height of the target to render to
  5315. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  5316. * @param depthStencilTexture The depth stencil texture to use to render
  5317. */
  5318. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture): void;
  5319. private bindUnboundFramebuffer(framebuffer);
  5320. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  5321. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  5322. generateMipMapsForCubemap(texture: InternalTexture): void;
  5323. flushFramebuffer(): void;
  5324. restoreDefaultFramebuffer(): void;
  5325. createUniformBuffer(elements: FloatArray): WebGLBuffer;
  5326. createDynamicUniformBuffer(elements: FloatArray): WebGLBuffer;
  5327. updateUniformBuffer(uniformBuffer: WebGLBuffer, elements: FloatArray, offset?: number, count?: number): void;
  5328. private _resetVertexBufferBinding();
  5329. createVertexBuffer(vertices: FloatArray): WebGLBuffer;
  5330. createDynamicVertexBuffer(vertices: FloatArray): WebGLBuffer;
  5331. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  5332. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, offset?: number, count?: number): void;
  5333. private _resetIndexBufferBinding();
  5334. createIndexBuffer(indices: IndicesArray, updatable?: boolean): WebGLBuffer;
  5335. bindArrayBuffer(buffer: Nullable<WebGLBuffer>): void;
  5336. bindUniformBuffer(buffer: Nullable<WebGLBuffer>): void;
  5337. bindUniformBufferBase(buffer: WebGLBuffer, location: number): void;
  5338. bindUniformBlock(shaderProgram: WebGLProgram, blockName: string, index: number): void;
  5339. private bindIndexBuffer(buffer);
  5340. private bindBuffer(buffer, target);
  5341. updateArrayBuffer(data: Float32Array): void;
  5342. private vertexAttribPointer(buffer, indx, size, type, normalized, stride, offset);
  5343. private _bindIndexBufferWithCache(indexBuffer);
  5344. private _bindVertexBuffersAttributes(vertexBuffers, effect);
  5345. recordVertexArrayObject(vertexBuffers: {
  5346. [key: string]: VertexBuffer;
  5347. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): WebGLVertexArrayObject;
  5348. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<WebGLBuffer>): void;
  5349. bindBuffersDirectly(vertexBuffer: WebGLBuffer, indexBuffer: WebGLBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  5350. private _unbindVertexArrayObject();
  5351. bindBuffers(vertexBuffers: {
  5352. [key: string]: Nullable<VertexBuffer>;
  5353. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): void;
  5354. unbindInstanceAttributes(): void;
  5355. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  5356. _releaseBuffer(buffer: WebGLBuffer): boolean;
  5357. createInstancesBuffer(capacity: number): WebGLBuffer;
  5358. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  5359. updateAndBindInstancesBuffer(instancesBuffer: WebGLBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  5360. applyStates(): void;
  5361. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  5362. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  5363. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  5364. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  5365. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  5366. private _drawMode(fillMode);
  5367. _releaseEffect(effect: Effect): void;
  5368. _deleteProgram(program: WebGLProgram): void;
  5369. /**
  5370. * @param baseName The base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  5371. * @param samplers An array of string used to represent textures
  5372. */
  5373. 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;
  5374. createEffectForParticles(fragmentName: string, uniformsNames?: string[], samplers?: string[], defines?: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  5375. createRawShaderProgram(vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  5376. createShaderProgram(vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  5377. private _createShaderProgram(vertexShader, fragmentShader, context, transformFeedbackVaryings?);
  5378. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  5379. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  5380. enableEffect(effect: Nullable<Effect>): void;
  5381. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  5382. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  5383. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  5384. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  5385. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  5386. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  5387. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  5388. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  5389. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  5390. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  5391. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  5392. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  5393. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  5394. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  5395. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  5396. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  5397. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  5398. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  5399. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  5400. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  5401. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  5402. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  5403. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  5404. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  5405. /**
  5406. * Sets a Color4 on a uniform variable
  5407. * @param uniform defines the uniform location
  5408. * @param color4 defines the value to be set
  5409. */
  5410. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  5411. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  5412. setZOffset(value: number): void;
  5413. getZOffset(): number;
  5414. setDepthBuffer(enable: boolean): void;
  5415. getDepthWrite(): boolean;
  5416. setDepthWrite(enable: boolean): void;
  5417. setColorWrite(enable: boolean): void;
  5418. getColorWrite(): boolean;
  5419. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  5420. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  5421. getAlphaMode(): number;
  5422. wipeCaches(bruteForce?: boolean): void;
  5423. /**
  5424. * Set the compressed texture format to use, based on the formats you have, and the formats
  5425. * supported by the hardware / browser.
  5426. *
  5427. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  5428. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  5429. * to API arguments needed to compressed textures. This puts the burden on the container
  5430. * generator to house the arcane code for determining these for current & future formats.
  5431. *
  5432. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  5433. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  5434. *
  5435. * Note: The result of this call is not taken into account when a texture is base64.
  5436. *
  5437. * @param {Array<string>} formatsAvailable- The list of those format families you have created
  5438. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  5439. *
  5440. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  5441. * @returns The extension selected.
  5442. */
  5443. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  5444. _createTexture(): WebGLTexture;
  5445. /**
  5446. * Usually called from BABYLON.Texture.ts. Passed information to create a WebGLTexture.
  5447. * @param {string} urlArg- This contains one of the following:
  5448. * 1. A conventional http URL, e.g. 'http://...' or 'file://...'
  5449. * 2. A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  5450. * 3. An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  5451. *
  5452. * @param {boolean} noMipmap- When true, no mipmaps shall be generated. Ignored for compressed textures. They must be in the file.
  5453. * @param {boolean} invertY- When true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file.
  5454. * @param {Scene} scene- Needed for loading to the correct scene.
  5455. * @param {number} samplingMode- Mode with should be used sample / access the texture. Default: TRILINEAR
  5456. * @param {callback} onLoad- Optional callback to be called upon successful completion.
  5457. * @param {callback} onError- Optional callback to be called upon failure.
  5458. * @param {ArrayBuffer | HTMLImageElement} buffer- A source of a file previously fetched as either an ArrayBuffer (compressed or image format) or HTMLImageElement (image format)
  5459. * @param {WebGLTexture} fallback- An internal argument in case the function must be called again, due to etc1 not having alpha capabilities.
  5460. * @param {number} format- Internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures.
  5461. *
  5462. * @returns {WebGLTexture} for assignment back into BABYLON.Texture
  5463. */
  5464. 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;
  5465. private _rescaleTexture(source, destination, scene, internalFormat, onComplete);
  5466. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, type?: number): void;
  5467. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  5468. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  5469. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  5470. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  5471. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  5472. /**
  5473. * Updates a depth texture Comparison Mode and Function.
  5474. * If the comparison Function is equal to 0, the mode will be set to none.
  5475. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  5476. * @param texture The texture to set the comparison function for
  5477. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  5478. */
  5479. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  5480. private _setupDepthStencilTexture(internalTexture, size, generateStencil, bilinearFiltering, comparisonFunction);
  5481. /**
  5482. * Creates a depth stencil texture.
  5483. * This is only available in WebGL 2 or with the depth texture extension available.
  5484. * @param size The size of face edge in the texture.
  5485. * @param options The options defining the texture.
  5486. * @returns The texture
  5487. */
  5488. createDepthStencilTexture(size: number | {
  5489. width: number;
  5490. height: number;
  5491. }, options: DepthTextureCreationOptions): InternalTexture;
  5492. /**
  5493. * Creates a depth stencil texture.
  5494. * This is only available in WebGL 2 or with the depth texture extension available.
  5495. * @param size The size of face edge in the texture.
  5496. * @param options The options defining the texture.
  5497. * @returns The texture
  5498. */
  5499. private _createDepthStencilTexture(size, options);
  5500. /**
  5501. * Creates a depth stencil cube texture.
  5502. * This is only available in WebGL 2.
  5503. * @param size The size of face edge in the cube texture.
  5504. * @param options The options defining the cube texture.
  5505. * @returns The cube texture
  5506. */
  5507. private _createDepthStencilCubeTexture(size, options);
  5508. /**
  5509. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  5510. * @param renderTarget The render target to set the frame buffer for
  5511. */
  5512. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  5513. createRenderTargetTexture(size: number | {
  5514. width: number;
  5515. height: number;
  5516. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  5517. createMultipleRenderTarget(size: any, options: any): InternalTexture[];
  5518. private _setupFramebufferDepthAttachments(generateStencilBuffer, generateDepthBuffer, width, height, samples?);
  5519. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  5520. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  5521. _uploadDataToTexture(target: number, lod: number, internalFormat: number, width: number, height: number, format: number, type: number, data: ArrayBufferView): void;
  5522. _uploadCompressedDataToTexture(target: number, lod: number, internalFormat: number, width: number, height: number, data: ArrayBufferView): void;
  5523. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  5524. 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;
  5525. 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;
  5526. private setCubeMapTextureParams(gl, loadMipmap);
  5527. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>, level?: number): void;
  5528. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  5529. 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;
  5530. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>): void;
  5531. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  5532. private _prepareWebGLTextureContinuation(texture, scene, noMipmap, isCompressed, samplingMode);
  5533. private _prepareWebGLTexture(texture, scene, width, height, invertY, noMipmap, isCompressed, processFunction, samplingMode?);
  5534. private _convertRGBtoRGBATextureData(rgbData, width, height, textureType);
  5535. _releaseFramebufferObjects(texture: InternalTexture): void;
  5536. _releaseTexture(texture: InternalTexture): void;
  5537. private setProgram(program);
  5538. private _boundUniforms;
  5539. bindSamplers(effect: Effect): void;
  5540. private _moveBoundTextureOnTop(internalTexture);
  5541. private _getCorrectTextureChannel(channel, internalTexture);
  5542. private _linkTrackers(previous, next);
  5543. private _removeDesignatedSlot(internalTexture);
  5544. private _activateCurrentTexture();
  5545. protected _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean): void;
  5546. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  5547. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  5548. /**
  5549. * Binds the output of the passed in post process to the texture channel specified
  5550. * @param channel The channel the texture should be bound to
  5551. * @param postProcess The post process which's output should be bound
  5552. */
  5553. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  5554. unbindAllTextures(): void;
  5555. /**
  5556. * Sets a texture to the according uniform.
  5557. * @param channel The texture channel
  5558. * @param uniform The uniform to set
  5559. * @param texture The texture to apply
  5560. */
  5561. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  5562. /**
  5563. * Sets a depth stencil texture from a render target to the according uniform.
  5564. * @param channel The texture channel
  5565. * @param uniform The uniform to set
  5566. * @param texture The render target texture containing the depth stencil texture to apply
  5567. */
  5568. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  5569. private _bindSamplerUniformToChannel(sourceSlot, destination);
  5570. private _setTexture(channel, texture, isPartOfTextureArray?, depthStencilTexture?);
  5571. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  5572. _setAnisotropicLevel(key: number, texture: BaseTexture): void;
  5573. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  5574. /**
  5575. * Add an externaly attached data from its key.
  5576. * This method call will fail and return false, if such key already exists.
  5577. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  5578. * @param key the unique key that identifies the data
  5579. * @param data the data object to associate to the key for this Engine instance
  5580. * @return true if no such key were already present and the data was added successfully, false otherwise
  5581. */
  5582. addExternalData<T>(key: string, data: T): boolean;
  5583. /**
  5584. * Get an externaly attached data from its key
  5585. * @param key the unique key that identifies the data
  5586. * @return the associated data, if present (can be null), or undefined if not present
  5587. */
  5588. getExternalData<T>(key: string): T;
  5589. /**
  5590. * Get an externaly attached data from its key, create it using a factory if it's not already present
  5591. * @param key the unique key that identifies the data
  5592. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  5593. * @return the associated data, can be null if the factory returned null.
  5594. */
  5595. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  5596. /**
  5597. * Remove an externaly attached data from the Engine instance
  5598. * @param key the unique key that identifies the data
  5599. * @return true if the data was successfully removed, false if it doesn't exist
  5600. */
  5601. removeExternalData(key: string): boolean;
  5602. unbindAllAttributes(): void;
  5603. releaseEffects(): void;
  5604. dispose(): void;
  5605. displayLoadingUI(): void;
  5606. hideLoadingUI(): void;
  5607. loadingScreen: ILoadingScreen;
  5608. loadingUIText: string;
  5609. loadingUIBackgroundColor: string;
  5610. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  5611. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  5612. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  5613. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  5614. getError(): number;
  5615. getFps(): number;
  5616. getDeltaTime(): number;
  5617. private _measureFps();
  5618. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number): ArrayBufferView;
  5619. private _canRenderToFloatFramebuffer();
  5620. private _canRenderToHalfFloatFramebuffer();
  5621. private _canRenderToFramebuffer(type);
  5622. _getWebGLTextureType(type: number): number;
  5623. private _getInternalFormat(format);
  5624. /** @ignore */
  5625. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  5626. _getRGBAMultiSampleBufferFormat(type: number): number;
  5627. createQuery(): WebGLQuery;
  5628. deleteQuery(query: WebGLQuery): Engine;
  5629. isQueryResultAvailable(query: WebGLQuery): boolean;
  5630. getQueryResult(query: WebGLQuery): number;
  5631. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  5632. endOcclusionQuery(algorithmType: number): Engine;
  5633. private _createTimeQuery();
  5634. private _deleteTimeQuery(query);
  5635. private _getTimeQueryResult(query);
  5636. private _getTimeQueryAvailability(query);
  5637. private _currentNonTimestampToken;
  5638. startTimeQuery(): Nullable<_TimeToken>;
  5639. endTimeQuery(token: _TimeToken): int;
  5640. private getGlAlgorithmType(algorithmType);
  5641. createTransformFeedback(): WebGLTransformFeedback;
  5642. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  5643. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  5644. beginTransformFeedback(usePoints?: boolean): void;
  5645. endTransformFeedback(): void;
  5646. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  5647. bindTransformFeedbackBuffer(value: Nullable<WebGLBuffer>): void;
  5648. _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;
  5649. /** @ignore */
  5650. _loadFileAsync(url: string, database?: Database, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  5651. private _partialLoadFile(url, index, loadedFiles, scene, onfinish, onErrorCallBack?);
  5652. private _cascadeLoadFiles(scene, onfinish, files, onError?);
  5653. static isSupported(): boolean;
  5654. }
  5655. }
  5656. declare module BABYLON {
  5657. class NullEngineOptions {
  5658. renderWidth: number;
  5659. renderHeight: number;
  5660. textureSize: number;
  5661. deterministicLockstep: boolean;
  5662. lockstepMaxSteps: number;
  5663. }
  5664. /**
  5665. * The null engine class provides support for headless version of babylon.js.
  5666. * This can be used in server side scenario or for testing purposes
  5667. */
  5668. class NullEngine extends Engine {
  5669. private _options;
  5670. isDeterministicLockStep(): boolean;
  5671. getLockstepMaxSteps(): number;
  5672. getHardwareScalingLevel(): number;
  5673. constructor(options?: NullEngineOptions);
  5674. createVertexBuffer(vertices: FloatArray): WebGLBuffer;
  5675. createIndexBuffer(indices: IndicesArray): WebGLBuffer;
  5676. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  5677. getRenderWidth(useScreen?: boolean): number;
  5678. getRenderHeight(useScreen?: boolean): number;
  5679. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  5680. createShaderProgram(vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  5681. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): WebGLUniformLocation[];
  5682. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  5683. bindSamplers(effect: Effect): void;
  5684. enableEffect(effect: Effect): void;
  5685. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  5686. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  5687. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  5688. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  5689. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  5690. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  5691. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  5692. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  5693. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  5694. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  5695. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  5696. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  5697. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  5698. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  5699. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  5700. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  5701. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  5702. setFloat(uniform: WebGLUniformLocation, value: number): void;
  5703. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  5704. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  5705. setBool(uniform: WebGLUniformLocation, bool: number): void;
  5706. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  5707. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  5708. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  5709. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  5710. bindBuffers(vertexBuffers: {
  5711. [key: string]: VertexBuffer;
  5712. }, indexBuffer: WebGLBuffer, effect: Effect): void;
  5713. wipeCaches(bruteForce?: boolean): void;
  5714. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  5715. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  5716. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  5717. _createTexture(): WebGLTexture;
  5718. 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;
  5719. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  5720. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  5721. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  5722. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  5723. createDynamicVertexBuffer(vertices: FloatArray): WebGLBuffer;
  5724. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  5725. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, offset?: number, count?: number): void;
  5726. protected _bindTextureDirectly(target: number, texture: InternalTexture): void;
  5727. _bindTexture(channel: number, texture: InternalTexture): void;
  5728. _releaseBuffer(buffer: WebGLBuffer): boolean;
  5729. }
  5730. }
  5731. interface WebGLRenderingContext {
  5732. readonly RASTERIZER_DISCARD: number;
  5733. readonly DEPTH_COMPONENT24: number;
  5734. readonly TEXTURE_3D: number;
  5735. readonly TEXTURE_2D_ARRAY: number;
  5736. readonly TEXTURE_COMPARE_FUNC: number;
  5737. readonly TEXTURE_COMPARE_MODE: number;
  5738. readonly COMPARE_REF_TO_TEXTURE: number;
  5739. readonly TEXTURE_WRAP_R: number;
  5740. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  5741. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  5742. 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;
  5743. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  5744. readonly TRANSFORM_FEEDBACK: number;
  5745. readonly INTERLEAVED_ATTRIBS: number;
  5746. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  5747. createTransformFeedback(): WebGLTransformFeedback;
  5748. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  5749. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  5750. beginTransformFeedback(primitiveMode: number): void;
  5751. endTransformFeedback(): void;
  5752. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  5753. }
  5754. interface ImageBitmap {
  5755. readonly width: number;
  5756. readonly height: number;
  5757. close(): void;
  5758. }
  5759. interface WebGLQuery extends WebGLObject {
  5760. }
  5761. declare var WebGLQuery: {
  5762. prototype: WebGLQuery;
  5763. new (): WebGLQuery;
  5764. };
  5765. interface WebGLSampler extends WebGLObject {
  5766. }
  5767. declare var WebGLSampler: {
  5768. prototype: WebGLSampler;
  5769. new (): WebGLSampler;
  5770. };
  5771. interface WebGLSync extends WebGLObject {
  5772. }
  5773. declare var WebGLSync: {
  5774. prototype: WebGLSync;
  5775. new (): WebGLSync;
  5776. };
  5777. interface WebGLTransformFeedback extends WebGLObject {
  5778. }
  5779. declare var WebGLTransformFeedback: {
  5780. prototype: WebGLTransformFeedback;
  5781. new (): WebGLTransformFeedback;
  5782. };
  5783. interface WebGLVertexArrayObject extends WebGLObject {
  5784. }
  5785. declare var WebGLVertexArrayObject: {
  5786. prototype: WebGLVertexArrayObject;
  5787. new (): WebGLVertexArrayObject;
  5788. };
  5789. declare module BABYLON {
  5790. class KeyboardEventTypes {
  5791. static _KEYDOWN: number;
  5792. static _KEYUP: number;
  5793. static readonly KEYDOWN: number;
  5794. static readonly KEYUP: number;
  5795. }
  5796. class KeyboardInfo {
  5797. type: number;
  5798. event: KeyboardEvent;
  5799. constructor(type: number, event: KeyboardEvent);
  5800. }
  5801. /**
  5802. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  5803. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  5804. */
  5805. class KeyboardInfoPre extends KeyboardInfo {
  5806. constructor(type: number, event: KeyboardEvent);
  5807. skipOnPointerObservable: boolean;
  5808. }
  5809. }
  5810. declare module BABYLON {
  5811. class PointerEventTypes {
  5812. static _POINTERDOWN: number;
  5813. static _POINTERUP: number;
  5814. static _POINTERMOVE: number;
  5815. static _POINTERWHEEL: number;
  5816. static _POINTERPICK: number;
  5817. static _POINTERTAP: number;
  5818. static _POINTERDOUBLETAP: number;
  5819. static readonly POINTERDOWN: number;
  5820. static readonly POINTERUP: number;
  5821. static readonly POINTERMOVE: number;
  5822. static readonly POINTERWHEEL: number;
  5823. static readonly POINTERPICK: number;
  5824. static readonly POINTERTAP: number;
  5825. static readonly POINTERDOUBLETAP: number;
  5826. }
  5827. class PointerInfoBase {
  5828. type: number;
  5829. event: PointerEvent | MouseWheelEvent;
  5830. constructor(type: number, event: PointerEvent | MouseWheelEvent);
  5831. }
  5832. /**
  5833. * This class is used to store pointer related info for the onPrePointerObservable event.
  5834. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  5835. */
  5836. class PointerInfoPre extends PointerInfoBase {
  5837. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  5838. localPosition: Vector2;
  5839. skipOnPointerObservable: boolean;
  5840. }
  5841. /**
  5842. * This type contains all the data related to a pointer event in Babylon.js.
  5843. * 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.
  5844. */
  5845. class PointerInfo extends PointerInfoBase {
  5846. pickInfo: Nullable<PickingInfo>;
  5847. constructor(type: number, event: PointerEvent | MouseWheelEvent, pickInfo: Nullable<PickingInfo>);
  5848. }
  5849. }
  5850. declare module BABYLON {
  5851. class StickValues {
  5852. x: number;
  5853. y: number;
  5854. constructor(x: number, y: number);
  5855. }
  5856. interface GamepadButtonChanges {
  5857. changed: boolean;
  5858. pressChanged: boolean;
  5859. touchChanged: boolean;
  5860. valueChanged: boolean;
  5861. }
  5862. class Gamepad {
  5863. id: string;
  5864. index: number;
  5865. browserGamepad: any;
  5866. type: number;
  5867. private _leftStick;
  5868. private _rightStick;
  5869. _isConnected: boolean;
  5870. private _leftStickAxisX;
  5871. private _leftStickAxisY;
  5872. private _rightStickAxisX;
  5873. private _rightStickAxisY;
  5874. private _onleftstickchanged;
  5875. private _onrightstickchanged;
  5876. static GAMEPAD: number;
  5877. static GENERIC: number;
  5878. static XBOX: number;
  5879. static POSE_ENABLED: number;
  5880. protected _invertLeftStickY: boolean;
  5881. readonly isConnected: boolean;
  5882. constructor(id: string, index: number, browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  5883. onleftstickchanged(callback: (values: StickValues) => void): void;
  5884. onrightstickchanged(callback: (values: StickValues) => void): void;
  5885. leftStick: StickValues;
  5886. rightStick: StickValues;
  5887. update(): void;
  5888. dispose(): void;
  5889. }
  5890. class GenericPad extends Gamepad {
  5891. private _buttons;
  5892. private _onbuttondown;
  5893. private _onbuttonup;
  5894. onButtonDownObservable: Observable<number>;
  5895. onButtonUpObservable: Observable<number>;
  5896. onbuttondown(callback: (buttonPressed: number) => void): void;
  5897. onbuttonup(callback: (buttonReleased: number) => void): void;
  5898. constructor(id: string, index: number, browserGamepad: any);
  5899. private _setButtonValue(newValue, currentValue, buttonIndex);
  5900. update(): void;
  5901. dispose(): void;
  5902. }
  5903. }
  5904. declare module BABYLON {
  5905. class GamepadManager {
  5906. private _scene;
  5907. private _babylonGamepads;
  5908. private _oneGamepadConnected;
  5909. _isMonitoring: boolean;
  5910. private _gamepadEventSupported;
  5911. private _gamepadSupport;
  5912. onGamepadConnectedObservable: Observable<Gamepad>;
  5913. onGamepadDisconnectedObservable: Observable<Gamepad>;
  5914. private _onGamepadConnectedEvent;
  5915. private _onGamepadDisconnectedEvent;
  5916. constructor(_scene?: Scene | undefined);
  5917. readonly gamepads: Gamepad[];
  5918. getGamepadByType(type?: number): Nullable<Gamepad>;
  5919. dispose(): void;
  5920. private _addNewGamepad(gamepad);
  5921. private _startMonitoringGamepads();
  5922. private _stopMonitoringGamepads();
  5923. _checkGamepadsStatus(): void;
  5924. private _updateGamepadObjects();
  5925. }
  5926. }
  5927. declare module BABYLON {
  5928. enum Xbox360Button {
  5929. A = 0,
  5930. B = 1,
  5931. X = 2,
  5932. Y = 3,
  5933. Start = 4,
  5934. Back = 5,
  5935. LB = 6,
  5936. RB = 7,
  5937. LeftStick = 8,
  5938. RightStick = 9,
  5939. }
  5940. enum Xbox360Dpad {
  5941. Up = 0,
  5942. Down = 1,
  5943. Left = 2,
  5944. Right = 3,
  5945. }
  5946. class Xbox360Pad extends Gamepad {
  5947. private _leftTrigger;
  5948. private _rightTrigger;
  5949. private _onlefttriggerchanged;
  5950. private _onrighttriggerchanged;
  5951. private _onbuttondown;
  5952. private _onbuttonup;
  5953. private _ondpaddown;
  5954. private _ondpadup;
  5955. onButtonDownObservable: Observable<Xbox360Button>;
  5956. onButtonUpObservable: Observable<Xbox360Button>;
  5957. onPadDownObservable: Observable<Xbox360Dpad>;
  5958. onPadUpObservable: Observable<Xbox360Dpad>;
  5959. private _buttonA;
  5960. private _buttonB;
  5961. private _buttonX;
  5962. private _buttonY;
  5963. private _buttonBack;
  5964. private _buttonStart;
  5965. private _buttonLB;
  5966. private _buttonRB;
  5967. private _buttonLeftStick;
  5968. private _buttonRightStick;
  5969. private _dPadUp;
  5970. private _dPadDown;
  5971. private _dPadLeft;
  5972. private _dPadRight;
  5973. private _isXboxOnePad;
  5974. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  5975. onlefttriggerchanged(callback: (value: number) => void): void;
  5976. onrighttriggerchanged(callback: (value: number) => void): void;
  5977. leftTrigger: number;
  5978. rightTrigger: number;
  5979. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  5980. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  5981. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  5982. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  5983. private _setButtonValue(newValue, currentValue, buttonType);
  5984. private _setDPadValue(newValue, currentValue, buttonType);
  5985. buttonA: number;
  5986. buttonB: number;
  5987. buttonX: number;
  5988. buttonY: number;
  5989. buttonStart: number;
  5990. buttonBack: number;
  5991. buttonLB: number;
  5992. buttonRB: number;
  5993. buttonLeftStick: number;
  5994. buttonRightStick: number;
  5995. dPadUp: number;
  5996. dPadDown: number;
  5997. dPadLeft: number;
  5998. dPadRight: number;
  5999. update(): void;
  6000. dispose(): void;
  6001. }
  6002. }
  6003. declare module BABYLON {
  6004. /**
  6005. * Represents the different options available during the creation of
  6006. * a Environment helper.
  6007. *
  6008. * This can control the default ground, skybox and image processing setup of your scene.
  6009. */
  6010. interface IEnvironmentHelperOptions {
  6011. /**
  6012. * Specifies wether or not to create a ground.
  6013. * True by default.
  6014. */
  6015. createGround: boolean;
  6016. /**
  6017. * Specifies the ground size.
  6018. * 15 by default.
  6019. */
  6020. groundSize: number;
  6021. /**
  6022. * The texture used on the ground for the main color.
  6023. * Comes from the BabylonJS CDN by default.
  6024. *
  6025. * Remarks: Can be either a texture or a url.
  6026. */
  6027. groundTexture: string | BaseTexture;
  6028. /**
  6029. * The color mixed in the ground texture by default.
  6030. * BabylonJS clearColor by default.
  6031. */
  6032. groundColor: Color3;
  6033. /**
  6034. * Specifies the ground opacity.
  6035. * 1 by default.
  6036. */
  6037. groundOpacity: number;
  6038. /**
  6039. * Enables the ground to receive shadows.
  6040. * True by default.
  6041. */
  6042. enableGroundShadow: boolean;
  6043. /**
  6044. * Helps preventing the shadow to be fully black on the ground.
  6045. * 0.5 by default.
  6046. */
  6047. groundShadowLevel: number;
  6048. /**
  6049. * Creates a mirror texture attach to the ground.
  6050. * false by default.
  6051. */
  6052. enableGroundMirror: boolean;
  6053. /**
  6054. * Specifies the ground mirror size ratio.
  6055. * 0.3 by default as the default kernel is 64.
  6056. */
  6057. groundMirrorSizeRatio: number;
  6058. /**
  6059. * Specifies the ground mirror blur kernel size.
  6060. * 64 by default.
  6061. */
  6062. groundMirrorBlurKernel: number;
  6063. /**
  6064. * Specifies the ground mirror visibility amount.
  6065. * 1 by default
  6066. */
  6067. groundMirrorAmount: number;
  6068. /**
  6069. * Specifies the ground mirror reflectance weight.
  6070. * This uses the standard weight of the background material to setup the fresnel effect
  6071. * of the mirror.
  6072. * 1 by default.
  6073. */
  6074. groundMirrorFresnelWeight: number;
  6075. /**
  6076. * Specifies the ground mirror Falloff distance.
  6077. * This can helps reducing the size of the reflection.
  6078. * 0 by Default.
  6079. */
  6080. groundMirrorFallOffDistance: number;
  6081. /**
  6082. * Specifies the ground mirror texture type.
  6083. * Unsigned Int by Default.
  6084. */
  6085. groundMirrorTextureType: number;
  6086. /**
  6087. * Specifies a bias applied to the ground vertical position to prevent z-fighyting with
  6088. * the shown objects.
  6089. */
  6090. groundYBias: number;
  6091. /**
  6092. * Specifies wether or not to create a skybox.
  6093. * True by default.
  6094. */
  6095. createSkybox: boolean;
  6096. /**
  6097. * Specifies the skybox size.
  6098. * 20 by default.
  6099. */
  6100. skyboxSize: number;
  6101. /**
  6102. * The texture used on the skybox for the main color.
  6103. * Comes from the BabylonJS CDN by default.
  6104. *
  6105. * Remarks: Can be either a texture or a url.
  6106. */
  6107. skyboxTexture: string | BaseTexture;
  6108. /**
  6109. * The color mixed in the skybox texture by default.
  6110. * BabylonJS clearColor by default.
  6111. */
  6112. skyboxColor: Color3;
  6113. /**
  6114. * The background rotation around the Y axis of the scene.
  6115. * This helps aligning the key lights of your scene with the background.
  6116. * 0 by default.
  6117. */
  6118. backgroundYRotation: number;
  6119. /**
  6120. * Compute automatically the size of the elements to best fit with the scene.
  6121. */
  6122. sizeAuto: boolean;
  6123. /**
  6124. * Default position of the rootMesh if autoSize is not true.
  6125. */
  6126. rootPosition: Vector3;
  6127. /**
  6128. * Sets up the image processing in the scene.
  6129. * true by default.
  6130. */
  6131. setupImageProcessing: boolean;
  6132. /**
  6133. * The texture used as your environment texture in the scene.
  6134. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  6135. *
  6136. * Remarks: Can be either a texture or a url.
  6137. */
  6138. environmentTexture: string | BaseTexture;
  6139. /**
  6140. * The value of the exposure to apply to the scene.
  6141. * 0.6 by default if setupImageProcessing is true.
  6142. */
  6143. cameraExposure: number;
  6144. /**
  6145. * The value of the contrast to apply to the scene.
  6146. * 1.6 by default if setupImageProcessing is true.
  6147. */
  6148. cameraContrast: number;
  6149. /**
  6150. * Specifies wether or not tonemapping should be enabled in the scene.
  6151. * true by default if setupImageProcessing is true.
  6152. */
  6153. toneMappingEnabled: boolean;
  6154. }
  6155. /**
  6156. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  6157. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  6158. * It also helps with the default setup of your imageProcessing configuration.
  6159. */
  6160. class EnvironmentHelper {
  6161. /**
  6162. * Default ground texture URL.
  6163. */
  6164. private static _groundTextureCDNUrl;
  6165. /**
  6166. * Default skybox texture URL.
  6167. */
  6168. private static _skyboxTextureCDNUrl;
  6169. /**
  6170. * Default environment texture URL.
  6171. */
  6172. private static _environmentTextureCDNUrl;
  6173. /**
  6174. * Creates the default options for the helper.
  6175. */
  6176. private static _getDefaultOptions();
  6177. private _rootMesh;
  6178. /**
  6179. * Gets the root mesh created by the helper.
  6180. */
  6181. readonly rootMesh: Mesh;
  6182. private _skybox;
  6183. /**
  6184. * Gets the skybox created by the helper.
  6185. */
  6186. readonly skybox: Nullable<Mesh>;
  6187. private _skyboxTexture;
  6188. /**
  6189. * Gets the skybox texture created by the helper.
  6190. */
  6191. readonly skyboxTexture: Nullable<BaseTexture>;
  6192. private _skyboxMaterial;
  6193. /**
  6194. * Gets the skybox material created by the helper.
  6195. */
  6196. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  6197. private _ground;
  6198. /**
  6199. * Gets the ground mesh created by the helper.
  6200. */
  6201. readonly ground: Nullable<Mesh>;
  6202. private _groundTexture;
  6203. /**
  6204. * Gets the ground texture created by the helper.
  6205. */
  6206. readonly groundTexture: Nullable<BaseTexture>;
  6207. private _groundMirror;
  6208. /**
  6209. * Gets the ground mirror created by the helper.
  6210. */
  6211. readonly groundMirror: Nullable<MirrorTexture>;
  6212. /**
  6213. * Gets the ground mirror render list to helps pushing the meshes
  6214. * you wish in the ground reflection.
  6215. */
  6216. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  6217. private _groundMaterial;
  6218. /**
  6219. * Gets the ground material created by the helper.
  6220. */
  6221. readonly groundMaterial: Nullable<BackgroundMaterial>;
  6222. /**
  6223. * Stores the creation options.
  6224. */
  6225. private readonly _scene;
  6226. private _options;
  6227. /**
  6228. * This observable will be notified with any error during the creation of the environment,
  6229. * mainly texture creation errors.
  6230. */
  6231. onErrorObservable: Observable<{
  6232. message?: string;
  6233. exception?: any;
  6234. }>;
  6235. /**
  6236. * constructor
  6237. * @param options
  6238. * @param scene The scene to add the material to
  6239. */
  6240. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  6241. /**
  6242. * Updates the background according to the new options
  6243. * @param options
  6244. */
  6245. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  6246. /**
  6247. * Sets the primary color of all the available elements.
  6248. * @param color
  6249. */
  6250. setMainColor(color: Color3): void;
  6251. /**
  6252. * Setup the image processing according to the specified options.
  6253. */
  6254. private _setupImageProcessing();
  6255. /**
  6256. * Setup the environment texture according to the specified options.
  6257. */
  6258. private _setupEnvironmentTexture();
  6259. /**
  6260. * Setup the background according to the specified options.
  6261. */
  6262. private _setupBackground();
  6263. /**
  6264. * Get the scene sizes according to the setup.
  6265. */
  6266. private _getSceneSize();
  6267. /**
  6268. * Setup the ground according to the specified options.
  6269. */
  6270. private _setupGround(sceneSize);
  6271. /**
  6272. * Setup the ground material according to the specified options.
  6273. */
  6274. private _setupGroundMaterial();
  6275. /**
  6276. * Setup the ground diffuse texture according to the specified options.
  6277. */
  6278. private _setupGroundDiffuseTexture();
  6279. /**
  6280. * Setup the ground mirror texture according to the specified options.
  6281. */
  6282. private _setupGroundMirrorTexture(sceneSize);
  6283. /**
  6284. * Setup the ground to receive the mirror texture.
  6285. */
  6286. private _setupMirrorInGroundMaterial();
  6287. /**
  6288. * Setup the skybox according to the specified options.
  6289. */
  6290. private _setupSkybox(sceneSize);
  6291. /**
  6292. * Setup the skybox material according to the specified options.
  6293. */
  6294. private _setupSkyboxMaterial();
  6295. /**
  6296. * Setup the skybox reflection texture according to the specified options.
  6297. */
  6298. private _setupSkyboxReflectionTexture();
  6299. private _errorHandler;
  6300. /**
  6301. * Dispose all the elements created by the Helper.
  6302. */
  6303. dispose(): void;
  6304. }
  6305. }
  6306. declare module BABYLON {
  6307. /**
  6308. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  6309. * As a subclass of Node, this allow parenting to the camera or multiple videos with different locations in the scene.
  6310. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  6311. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  6312. */
  6313. class VideoDome extends Node {
  6314. /**
  6315. * The video texture being displayed on the sphere
  6316. */
  6317. protected _videoTexture: VideoTexture;
  6318. /**
  6319. * The skybox material
  6320. */
  6321. protected _material: BackgroundMaterial;
  6322. /**
  6323. * The surface used for the skybox
  6324. */
  6325. protected _mesh: Mesh;
  6326. /**
  6327. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  6328. * Also see the options.resolution property.
  6329. */
  6330. fovMultiplier: number;
  6331. /**
  6332. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  6333. * @param name Element's name, child elements will append suffixes for their own names.
  6334. * @param urlsOrVideo
  6335. * @param options An object containing optional or exposed sub element properties:
  6336. * @param options **resolution=12** Integer, lower resolutions have more artifacts at extreme fovs
  6337. * @param options **clickToPlay=false** Add a click to play listener to the video, does not prevent autoplay.
  6338. * @param options **autoPlay=true** Automatically attempt to being playing the video.
  6339. * @param options **loop=true** Automatically loop video on end.
  6340. * @param options **size=1000** Physical radius to create the dome at, defaults to approximately half the far clip plane.
  6341. */
  6342. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  6343. resolution?: number;
  6344. clickToPlay?: boolean;
  6345. autoPlay?: boolean;
  6346. loop?: boolean;
  6347. size?: number;
  6348. }, scene: Scene);
  6349. /**
  6350. * Releases resources associated with this node.
  6351. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  6352. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  6353. */
  6354. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  6355. }
  6356. }
  6357. declare module BABYLON {
  6358. /**
  6359. * This class can be used to get instrumentation data from a Babylon engine
  6360. */
  6361. class EngineInstrumentation implements IDisposable {
  6362. engine: Engine;
  6363. private _captureGPUFrameTime;
  6364. private _gpuFrameTimeToken;
  6365. private _gpuFrameTime;
  6366. private _captureShaderCompilationTime;
  6367. private _shaderCompilationTime;
  6368. private _onBeginFrameObserver;
  6369. private _onEndFrameObserver;
  6370. private _onBeforeShaderCompilationObserver;
  6371. private _onAfterShaderCompilationObserver;
  6372. /**
  6373. * Gets the perf counter used for GPU frame time
  6374. */
  6375. readonly gpuFrameTimeCounter: PerfCounter;
  6376. /**
  6377. * Gets the GPU frame time capture status
  6378. */
  6379. /**
  6380. * Enable or disable the GPU frame time capture
  6381. */
  6382. captureGPUFrameTime: boolean;
  6383. /**
  6384. * Gets the perf counter used for shader compilation time
  6385. */
  6386. readonly shaderCompilationTimeCounter: PerfCounter;
  6387. /**
  6388. * Gets the shader compilation time capture status
  6389. */
  6390. /**
  6391. * Enable or disable the shader compilation time capture
  6392. */
  6393. captureShaderCompilationTime: boolean;
  6394. constructor(engine: Engine);
  6395. dispose(): void;
  6396. }
  6397. }
  6398. declare module BABYLON {
  6399. /**
  6400. * This class can be used to get instrumentation data from a Babylon engine
  6401. */
  6402. class SceneInstrumentation implements IDisposable {
  6403. scene: Scene;
  6404. private _captureActiveMeshesEvaluationTime;
  6405. private _activeMeshesEvaluationTime;
  6406. private _captureRenderTargetsRenderTime;
  6407. private _renderTargetsRenderTime;
  6408. private _captureFrameTime;
  6409. private _frameTime;
  6410. private _captureRenderTime;
  6411. private _renderTime;
  6412. private _captureInterFrameTime;
  6413. private _interFrameTime;
  6414. private _captureParticlesRenderTime;
  6415. private _particlesRenderTime;
  6416. private _captureSpritesRenderTime;
  6417. private _spritesRenderTime;
  6418. private _capturePhysicsTime;
  6419. private _physicsTime;
  6420. private _captureAnimationsTime;
  6421. private _animationsTime;
  6422. private _onBeforeActiveMeshesEvaluationObserver;
  6423. private _onAfterActiveMeshesEvaluationObserver;
  6424. private _onBeforeRenderTargetsRenderObserver;
  6425. private _onAfterRenderTargetsRenderObserver;
  6426. private _onAfterRenderObserver;
  6427. private _onBeforeDrawPhaseObserver;
  6428. private _onAfterDrawPhaseObserver;
  6429. private _onBeforeAnimationsObserver;
  6430. private _onBeforeParticlesRenderingObserver;
  6431. private _onAfterParticlesRenderingObserver;
  6432. private _onBeforeSpritesRenderingObserver;
  6433. private _onAfterSpritesRenderingObserver;
  6434. private _onBeforePhysicsObserver;
  6435. private _onAfterPhysicsObserver;
  6436. private _onAfterAnimationsObserver;
  6437. /**
  6438. * Gets the perf counter used for active meshes evaluation time
  6439. */
  6440. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  6441. /**
  6442. * Gets the active meshes evaluation time capture status
  6443. */
  6444. /**
  6445. * Enable or disable the active meshes evaluation time capture
  6446. */
  6447. captureActiveMeshesEvaluationTime: boolean;
  6448. /**
  6449. * Gets the perf counter used for render targets render time
  6450. */
  6451. readonly renderTargetsRenderTimeCounter: PerfCounter;
  6452. /**
  6453. * Gets the render targets render time capture status
  6454. */
  6455. /**
  6456. * Enable or disable the render targets render time capture
  6457. */
  6458. captureRenderTargetsRenderTime: boolean;
  6459. /**
  6460. * Gets the perf counter used for particles render time
  6461. */
  6462. readonly particlesRenderTimeCounter: PerfCounter;
  6463. /**
  6464. * Gets the particles render time capture status
  6465. */
  6466. /**
  6467. * Enable or disable the particles render time capture
  6468. */
  6469. captureParticlesRenderTime: boolean;
  6470. /**
  6471. * Gets the perf counter used for sprites render time
  6472. */
  6473. readonly spritesRenderTimeCounter: PerfCounter;
  6474. /**
  6475. * Gets the sprites render time capture status
  6476. */
  6477. /**
  6478. * Enable or disable the sprites render time capture
  6479. */
  6480. captureSpritesRenderTime: boolean;
  6481. /**
  6482. * Gets the perf counter used for physics time
  6483. */
  6484. readonly physicsTimeCounter: PerfCounter;
  6485. /**
  6486. * Gets the physics time capture status
  6487. */
  6488. /**
  6489. * Enable or disable the physics time capture
  6490. */
  6491. capturePhysicsTime: boolean;
  6492. /**
  6493. * Gets the perf counter used for animations time
  6494. */
  6495. readonly animationsTimeCounter: PerfCounter;
  6496. /**
  6497. * Gets the animations time capture status
  6498. */
  6499. /**
  6500. * Enable or disable the animations time capture
  6501. */
  6502. captureAnimationsTime: boolean;
  6503. /**
  6504. * Gets the perf counter used for frame time capture
  6505. */
  6506. readonly frameTimeCounter: PerfCounter;
  6507. /**
  6508. * Gets the frame time capture status
  6509. */
  6510. /**
  6511. * Enable or disable the frame time capture
  6512. */
  6513. captureFrameTime: boolean;
  6514. /**
  6515. * Gets the perf counter used for inter-frames time capture
  6516. */
  6517. readonly interFrameTimeCounter: PerfCounter;
  6518. /**
  6519. * Gets the inter-frames time capture status
  6520. */
  6521. /**
  6522. * Enable or disable the inter-frames time capture
  6523. */
  6524. captureInterFrameTime: boolean;
  6525. /**
  6526. * Gets the perf counter used for render time capture
  6527. */
  6528. readonly renderTimeCounter: PerfCounter;
  6529. /**
  6530. * Gets the render time capture status
  6531. */
  6532. /**
  6533. * Enable or disable the render time capture
  6534. */
  6535. captureRenderTime: boolean;
  6536. /**
  6537. * Gets the perf counter used for draw calls
  6538. */
  6539. readonly drawCallsCounter: PerfCounter;
  6540. /**
  6541. * Gets the perf counter used for texture collisions
  6542. */
  6543. readonly textureCollisionsCounter: PerfCounter;
  6544. constructor(scene: Scene);
  6545. dispose(): void;
  6546. }
  6547. }
  6548. declare module BABYLON {
  6549. class _TimeToken {
  6550. _startTimeQuery: Nullable<WebGLQuery>;
  6551. _endTimeQuery: Nullable<WebGLQuery>;
  6552. _timeElapsedQuery: Nullable<WebGLQuery>;
  6553. _timeElapsedQueryEnded: boolean;
  6554. }
  6555. }
  6556. declare module BABYLON {
  6557. /**
  6558. * Effect layer options. This helps customizing the behaviour
  6559. * of the effect layer.
  6560. */
  6561. interface IEffectLayerOptions {
  6562. /**
  6563. * Multiplication factor apply to the canvas size to compute the render target size
  6564. * used to generated the objects (the smaller the faster).
  6565. */
  6566. mainTextureRatio: number;
  6567. /**
  6568. * Enforces a fixed size texture to ensure effect stability across devices.
  6569. */
  6570. mainTextureFixedSize?: number;
  6571. /**
  6572. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  6573. */
  6574. alphaBlendingMode: number;
  6575. /**
  6576. * The camera attached to the layer.
  6577. */
  6578. camera: Nullable<Camera>;
  6579. }
  6580. /**
  6581. * The effect layer Helps adding post process effect blended with the main pass.
  6582. *
  6583. * This can be for instance use to generate glow or higlight effects on the scene.
  6584. *
  6585. * The effect layer class can not be used directly and is intented to inherited from to be
  6586. * customized per effects.
  6587. */
  6588. abstract class EffectLayer {
  6589. /** The Friendly of the effect in the scene */
  6590. name: string;
  6591. private _vertexBuffers;
  6592. private _indexBuffer;
  6593. private _cachedDefines;
  6594. private _effectLayerMapGenerationEffect;
  6595. private _effectLayerOptions;
  6596. private _mergeEffect;
  6597. protected _scene: Scene;
  6598. protected _engine: Engine;
  6599. protected _maxSize: number;
  6600. protected _mainTextureDesiredSize: ISize;
  6601. protected _mainTexture: RenderTargetTexture;
  6602. protected _shouldRender: boolean;
  6603. protected _postProcesses: PostProcess[];
  6604. protected _textures: BaseTexture[];
  6605. protected _emissiveTextureAndColor: {
  6606. texture: Nullable<BaseTexture>;
  6607. color: Color4;
  6608. };
  6609. /**
  6610. * The clear color of the texture used to generate the glow map.
  6611. */
  6612. neutralColor: Color4;
  6613. /**
  6614. * Specifies wether the highlight layer is enabled or not.
  6615. */
  6616. isEnabled: boolean;
  6617. /**
  6618. * Gets the camera attached to the layer.
  6619. */
  6620. readonly camera: Nullable<Camera>;
  6621. /**
  6622. * An event triggered when the effect layer has been disposed.
  6623. */
  6624. onDisposeObservable: Observable<EffectLayer>;
  6625. /**
  6626. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  6627. */
  6628. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  6629. /**
  6630. * An event triggered when the generated texture is being merged in the scene.
  6631. */
  6632. onBeforeComposeObservable: Observable<EffectLayer>;
  6633. /**
  6634. * An event triggered when the generated texture has been merged in the scene.
  6635. */
  6636. onAfterComposeObservable: Observable<EffectLayer>;
  6637. /**
  6638. * An event triggered when the efffect layer changes its size.
  6639. */
  6640. onSizeChangedObservable: Observable<EffectLayer>;
  6641. /**
  6642. * Instantiates a new effect Layer and references it in the scene.
  6643. * @param name The name of the layer
  6644. * @param scene The scene to use the layer in
  6645. */
  6646. constructor(
  6647. /** The Friendly of the effect in the scene */
  6648. name: string, scene: Scene);
  6649. /**
  6650. * Get the effect name of the layer.
  6651. * @return The effect name
  6652. */
  6653. abstract getEffectName(): string;
  6654. /**
  6655. * Checks for the readiness of the element composing the layer.
  6656. * @param subMesh the mesh to check for
  6657. * @param useInstances specify wether or not to use instances to render the mesh
  6658. * @return true if ready otherwise, false
  6659. */
  6660. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  6661. /**
  6662. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  6663. * @returns true if the effect requires stencil during the main canvas render pass.
  6664. */
  6665. abstract needStencil(): boolean;
  6666. /**
  6667. * Create the merge effect. This is the shader use to blit the information back
  6668. * to the main canvas at the end of the scene rendering.
  6669. * @returns The effect containing the shader used to merge the effect on the main canvas
  6670. */
  6671. protected abstract _createMergeEffect(): Effect;
  6672. /**
  6673. * Creates the render target textures and post processes used in the effect layer.
  6674. */
  6675. protected abstract _createTextureAndPostProcesses(): void;
  6676. /**
  6677. * Implementation specific of rendering the generating effect on the main canvas.
  6678. * @param effect The effect used to render through
  6679. */
  6680. protected abstract _internalRender(effect: Effect): void;
  6681. /**
  6682. * Sets the required values for both the emissive texture and and the main color.
  6683. */
  6684. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  6685. /**
  6686. * Free any resources and references associated to a mesh.
  6687. * Internal use
  6688. * @param mesh The mesh to free.
  6689. */
  6690. abstract _disposeMesh(mesh: Mesh): void;
  6691. /**
  6692. * Initializes the effect layer with the required options.
  6693. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  6694. */
  6695. protected _init(options: Partial<IEffectLayerOptions>): void;
  6696. /**
  6697. * Generates the index buffer of the full screen quad blending to the main canvas.
  6698. */
  6699. private _generateIndexBuffer();
  6700. /**
  6701. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  6702. */
  6703. private _genrateVertexBuffer();
  6704. /**
  6705. * Sets the main texture desired size which is the closest power of two
  6706. * of the engine canvas size.
  6707. */
  6708. private _setMainTextureSize();
  6709. /**
  6710. * Creates the main texture for the effect layer.
  6711. */
  6712. protected _createMainTexture(): void;
  6713. /**
  6714. * Checks for the readiness of the element composing the layer.
  6715. * @param subMesh the mesh to check for
  6716. * @param useInstances specify wether or not to use instances to render the mesh
  6717. * @param emissiveTexture the associated emissive texture used to generate the glow
  6718. * @return true if ready otherwise, false
  6719. */
  6720. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  6721. /**
  6722. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  6723. */
  6724. render(): void;
  6725. /**
  6726. * Determine if a given mesh will be used in the current effect.
  6727. * @param mesh mesh to test
  6728. * @returns true if the mesh will be used
  6729. */
  6730. hasMesh(mesh: AbstractMesh): boolean;
  6731. /**
  6732. * Returns true if the layer contains information to display, otherwise false.
  6733. * @returns true if the glow layer should be rendered
  6734. */
  6735. shouldRender(): boolean;
  6736. /**
  6737. * Returns true if the mesh should render, otherwise false.
  6738. * @param mesh The mesh to render
  6739. * @returns true if it should render otherwise false
  6740. */
  6741. protected _shouldRenderMesh(mesh: Mesh): boolean;
  6742. /**
  6743. * Returns true if the mesh should render, otherwise false.
  6744. * @param mesh The mesh to render
  6745. * @returns true if it should render otherwise false
  6746. */
  6747. protected _shouldRenderEmissiveTextureForMesh(mesh: Mesh): boolean;
  6748. /**
  6749. * Renders the submesh passed in parameter to the generation map.
  6750. */
  6751. protected _renderSubMesh(subMesh: SubMesh): void;
  6752. /**
  6753. * Rebuild the required buffers.
  6754. * @ignore Internal use only.
  6755. */
  6756. _rebuild(): void;
  6757. /**
  6758. * Dispose only the render target textures and post process.
  6759. */
  6760. private _disposeTextureAndPostProcesses();
  6761. /**
  6762. * Dispose the highlight layer and free resources.
  6763. */
  6764. dispose(): void;
  6765. }
  6766. }
  6767. declare module BABYLON {
  6768. /**
  6769. * Glow layer options. This helps customizing the behaviour
  6770. * of the glow layer.
  6771. */
  6772. interface IGlowLayerOptions {
  6773. /**
  6774. * Multiplication factor apply to the canvas size to compute the render target size
  6775. * used to generated the glowing objects (the smaller the faster).
  6776. */
  6777. mainTextureRatio: number;
  6778. /**
  6779. * Enforces a fixed size texture to ensure resize independant blur.
  6780. */
  6781. mainTextureFixedSize?: number;
  6782. /**
  6783. * How big is the kernel of the blur texture.
  6784. */
  6785. blurKernelSize: number;
  6786. /**
  6787. * The camera attached to the layer.
  6788. */
  6789. camera: Nullable<Camera>;
  6790. /**
  6791. * Enable MSAA by chosing the number of samples.
  6792. */
  6793. mainTextureSamples?: number;
  6794. }
  6795. /**
  6796. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  6797. *
  6798. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  6799. * glowy meshes to your scene.
  6800. *
  6801. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  6802. */
  6803. class GlowLayer extends EffectLayer {
  6804. name: string;
  6805. /**
  6806. * Effect Name of the layer.
  6807. */
  6808. static readonly EffectName: string;
  6809. /**
  6810. * The default blur kernel size used for the glow.
  6811. */
  6812. static DefaultBlurKernelSize: number;
  6813. /**
  6814. * The default texture size ratio used for the glow.
  6815. */
  6816. static DefaultTextureRatio: number;
  6817. /**
  6818. * Gets the kernel size of the blur.
  6819. */
  6820. /**
  6821. * Sets the kernel size of the blur.
  6822. */
  6823. blurKernelSize: number;
  6824. /**
  6825. * Gets the glow intensity.
  6826. */
  6827. /**
  6828. * Sets the glow intensity.
  6829. */
  6830. intensity: number;
  6831. private _options;
  6832. private _intensity;
  6833. private _horizontalBlurPostprocess1;
  6834. private _verticalBlurPostprocess1;
  6835. private _horizontalBlurPostprocess2;
  6836. private _verticalBlurPostprocess2;
  6837. private _blurTexture1;
  6838. private _blurTexture2;
  6839. private _postProcesses1;
  6840. private _postProcesses2;
  6841. private _includedOnlyMeshes;
  6842. private _excludedMeshes;
  6843. /**
  6844. * Callback used to let the user override the color selection on a per mesh basis
  6845. */
  6846. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  6847. /**
  6848. * Callback used to let the user override the texture selection on a per mesh basis
  6849. */
  6850. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  6851. /**
  6852. * Instantiates a new glow Layer and references it to the scene.
  6853. * @param name The name of the layer
  6854. * @param scene The scene to use the layer in
  6855. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  6856. */
  6857. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  6858. /**
  6859. * Get the effect name of the layer.
  6860. * @return The effect name
  6861. */
  6862. getEffectName(): string;
  6863. /**
  6864. * Create the merge effect. This is the shader use to blit the information back
  6865. * to the main canvas at the end of the scene rendering.
  6866. */
  6867. protected _createMergeEffect(): Effect;
  6868. /**
  6869. * Creates the render target textures and post processes used in the glow layer.
  6870. */
  6871. protected _createTextureAndPostProcesses(): void;
  6872. /**
  6873. * Checks for the readiness of the element composing the layer.
  6874. * @param subMesh the mesh to check for
  6875. * @param useInstances specify wether or not to use instances to render the mesh
  6876. * @param emissiveTexture the associated emissive texture used to generate the glow
  6877. * @return true if ready otherwise, false
  6878. */
  6879. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  6880. /**
  6881. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  6882. */
  6883. needStencil(): boolean;
  6884. /**
  6885. * Implementation specific of rendering the generating effect on the main canvas.
  6886. * @param effect The effect used to render through
  6887. */
  6888. protected _internalRender(effect: Effect): void;
  6889. /**
  6890. * Sets the required values for both the emissive texture and and the main color.
  6891. */
  6892. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  6893. /**
  6894. * Returns true if the mesh should render, otherwise false.
  6895. * @param mesh The mesh to render
  6896. * @returns true if it should render otherwise false
  6897. */
  6898. protected _shouldRenderMesh(mesh: Mesh): boolean;
  6899. /**
  6900. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  6901. * @param mesh The mesh to exclude from the glow layer
  6902. */
  6903. addExcludedMesh(mesh: Mesh): void;
  6904. /**
  6905. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  6906. * @param mesh The mesh to remove
  6907. */
  6908. removeExcludedMesh(mesh: Mesh): void;
  6909. /**
  6910. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  6911. * @param mesh The mesh to include in the glow layer
  6912. */
  6913. addIncludedOnlyMesh(mesh: Mesh): void;
  6914. /**
  6915. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  6916. * @param mesh The mesh to remove
  6917. */
  6918. removeIncludedOnlyMesh(mesh: Mesh): void;
  6919. /**
  6920. * Determine if a given mesh will be used in the glow layer
  6921. * @param mesh The mesh to test
  6922. * @returns true if the mesh will be highlighted by the current glow layer
  6923. */
  6924. hasMesh(mesh: AbstractMesh): boolean;
  6925. /**
  6926. * Free any resources and references associated to a mesh.
  6927. * Internal use
  6928. * @param mesh The mesh to free.
  6929. */
  6930. _disposeMesh(mesh: Mesh): void;
  6931. }
  6932. }
  6933. declare module BABYLON {
  6934. /**
  6935. * Highlight layer options. This helps customizing the behaviour
  6936. * of the highlight layer.
  6937. */
  6938. interface IHighlightLayerOptions {
  6939. /**
  6940. * Multiplication factor apply to the canvas size to compute the render target size
  6941. * used to generated the glowing objects (the smaller the faster).
  6942. */
  6943. mainTextureRatio: number;
  6944. /**
  6945. * Enforces a fixed size texture to ensure resize independant blur.
  6946. */
  6947. mainTextureFixedSize?: number;
  6948. /**
  6949. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  6950. * of the picture to blur (the smaller the faster).
  6951. */
  6952. blurTextureSizeRatio: number;
  6953. /**
  6954. * How big in texel of the blur texture is the vertical blur.
  6955. */
  6956. blurVerticalSize: number;
  6957. /**
  6958. * How big in texel of the blur texture is the horizontal blur.
  6959. */
  6960. blurHorizontalSize: number;
  6961. /**
  6962. * Alpha blending mode used to apply the blur. Default is combine.
  6963. */
  6964. alphaBlendingMode: number;
  6965. /**
  6966. * The camera attached to the layer.
  6967. */
  6968. camera: Nullable<Camera>;
  6969. /**
  6970. * Should we display highlight as a solid stroke?
  6971. */
  6972. isStroke?: boolean;
  6973. }
  6974. /**
  6975. * The highlight layer Helps adding a glow effect around a mesh.
  6976. *
  6977. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  6978. * glowy meshes to your scene.
  6979. *
  6980. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  6981. */
  6982. class HighlightLayer extends EffectLayer {
  6983. name: string;
  6984. /**
  6985. * Effect Name of the highlight layer.
  6986. */
  6987. static readonly EffectName: string;
  6988. /**
  6989. * The neutral color used during the preparation of the glow effect.
  6990. * This is black by default as the blend operation is a blend operation.
  6991. */
  6992. static NeutralColor: Color4;
  6993. /**
  6994. * Stencil value used for glowing meshes.
  6995. */
  6996. static GlowingMeshStencilReference: number;
  6997. /**
  6998. * Stencil value used for the other meshes in the scene.
  6999. */
  7000. static NormalMeshStencilReference: number;
  7001. /**
  7002. * Specifies whether or not the inner glow is ACTIVE in the layer.
  7003. */
  7004. innerGlow: boolean;
  7005. /**
  7006. * Specifies whether or not the outer glow is ACTIVE in the layer.
  7007. */
  7008. outerGlow: boolean;
  7009. /**
  7010. * Gets the horizontal size of the blur.
  7011. */
  7012. /**
  7013. * Specifies the horizontal size of the blur.
  7014. */
  7015. blurHorizontalSize: number;
  7016. /**
  7017. * Gets the vertical size of the blur.
  7018. */
  7019. /**
  7020. * Specifies the vertical size of the blur.
  7021. */
  7022. blurVerticalSize: number;
  7023. /**
  7024. * An event triggered when the highlight layer is being blurred.
  7025. */
  7026. onBeforeBlurObservable: Observable<HighlightLayer>;
  7027. /**
  7028. * An event triggered when the highlight layer has been blurred.
  7029. */
  7030. onAfterBlurObservable: Observable<HighlightLayer>;
  7031. private _instanceGlowingMeshStencilReference;
  7032. private _options;
  7033. private _downSamplePostprocess;
  7034. private _horizontalBlurPostprocess;
  7035. private _verticalBlurPostprocess;
  7036. private _blurTexture;
  7037. private _meshes;
  7038. private _excludedMeshes;
  7039. /**
  7040. * Instantiates a new highlight Layer and references it to the scene..
  7041. * @param name The name of the layer
  7042. * @param scene The scene to use the layer in
  7043. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  7044. */
  7045. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  7046. /**
  7047. * Get the effect name of the layer.
  7048. * @return The effect name
  7049. */
  7050. getEffectName(): string;
  7051. /**
  7052. * Create the merge effect. This is the shader use to blit the information back
  7053. * to the main canvas at the end of the scene rendering.
  7054. */
  7055. protected _createMergeEffect(): Effect;
  7056. /**
  7057. * Creates the render target textures and post processes used in the highlight layer.
  7058. */
  7059. protected _createTextureAndPostProcesses(): void;
  7060. /**
  7061. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  7062. */
  7063. needStencil(): boolean;
  7064. /**
  7065. * Checks for the readiness of the element composing the layer.
  7066. * @param subMesh the mesh to check for
  7067. * @param useInstances specify wether or not to use instances to render the mesh
  7068. * @param emissiveTexture the associated emissive texture used to generate the glow
  7069. * @return true if ready otherwise, false
  7070. */
  7071. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  7072. /**
  7073. * Implementation specific of rendering the generating effect on the main canvas.
  7074. * @param effect The effect used to render through
  7075. */
  7076. protected _internalRender(effect: Effect): void;
  7077. /**
  7078. * Returns true if the layer contains information to display, otherwise false.
  7079. */
  7080. shouldRender(): boolean;
  7081. /**
  7082. * Returns true if the mesh should render, otherwise false.
  7083. * @param mesh The mesh to render
  7084. * @returns true if it should render otherwise false
  7085. */
  7086. protected _shouldRenderMesh(mesh: Mesh): boolean;
  7087. /**
  7088. * Sets the required values for both the emissive texture and and the main color.
  7089. */
  7090. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  7091. /**
  7092. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  7093. * @param mesh The mesh to exclude from the highlight layer
  7094. */
  7095. addExcludedMesh(mesh: Mesh): void;
  7096. /**
  7097. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  7098. * @param mesh The mesh to highlight
  7099. */
  7100. removeExcludedMesh(mesh: Mesh): void;
  7101. /**
  7102. * Determine if a given mesh will be highlighted by the current HighlightLayer
  7103. * @param mesh mesh to test
  7104. * @returns true if the mesh will be highlighted by the current HighlightLayer
  7105. */
  7106. hasMesh(mesh: AbstractMesh): boolean;
  7107. /**
  7108. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  7109. * @param mesh The mesh to highlight
  7110. * @param color The color of the highlight
  7111. * @param glowEmissiveOnly Extract the glow from the emissive texture
  7112. */
  7113. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  7114. /**
  7115. * Remove a mesh from the highlight layer in order to make it stop glowing.
  7116. * @param mesh The mesh to highlight
  7117. */
  7118. removeMesh(mesh: Mesh): void;
  7119. /**
  7120. * Force the stencil to the normal expected value for none glowing parts
  7121. */
  7122. private _defaultStencilReference(mesh);
  7123. /**
  7124. * Free any resources and references associated to a mesh.
  7125. * Internal use
  7126. * @param mesh The mesh to free.
  7127. */
  7128. _disposeMesh(mesh: Mesh): void;
  7129. /**
  7130. * Dispose the highlight layer and free resources.
  7131. */
  7132. dispose(): void;
  7133. }
  7134. }
  7135. declare module BABYLON {
  7136. class Layer {
  7137. name: string;
  7138. texture: Nullable<Texture>;
  7139. isBackground: boolean;
  7140. color: Color4;
  7141. scale: Vector2;
  7142. offset: Vector2;
  7143. alphaBlendingMode: number;
  7144. alphaTest: boolean;
  7145. layerMask: number;
  7146. private _scene;
  7147. private _vertexBuffers;
  7148. private _indexBuffer;
  7149. private _effect;
  7150. private _alphaTestEffect;
  7151. /**
  7152. * An event triggered when the layer is disposed.
  7153. */
  7154. onDisposeObservable: Observable<Layer>;
  7155. private _onDisposeObserver;
  7156. onDispose: () => void;
  7157. /**
  7158. * An event triggered before rendering the scene
  7159. */
  7160. onBeforeRenderObservable: Observable<Layer>;
  7161. private _onBeforeRenderObserver;
  7162. onBeforeRender: () => void;
  7163. /**
  7164. * An event triggered after rendering the scene
  7165. */
  7166. onAfterRenderObservable: Observable<Layer>;
  7167. private _onAfterRenderObserver;
  7168. onAfterRender: () => void;
  7169. constructor(name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  7170. private _createIndexBuffer();
  7171. _rebuild(): void;
  7172. render(): void;
  7173. dispose(): void;
  7174. }
  7175. }
  7176. declare module BABYLON {
  7177. class LensFlare {
  7178. size: number;
  7179. position: number;
  7180. color: Color3;
  7181. texture: Nullable<Texture>;
  7182. alphaMode: number;
  7183. private _system;
  7184. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  7185. constructor(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  7186. dispose(): void;
  7187. }
  7188. }
  7189. declare module BABYLON {
  7190. class LensFlareSystem {
  7191. name: string;
  7192. lensFlares: LensFlare[];
  7193. borderLimit: number;
  7194. viewportBorder: number;
  7195. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  7196. layerMask: number;
  7197. id: string;
  7198. private _scene;
  7199. private _emitter;
  7200. private _vertexBuffers;
  7201. private _indexBuffer;
  7202. private _effect;
  7203. private _positionX;
  7204. private _positionY;
  7205. private _isEnabled;
  7206. constructor(name: string, emitter: any, scene: Scene);
  7207. isEnabled: boolean;
  7208. getScene(): Scene;
  7209. getEmitter(): any;
  7210. setEmitter(newEmitter: any): void;
  7211. getEmitterPosition(): Vector3;
  7212. computeEffectivePosition(globalViewport: Viewport): boolean;
  7213. _isVisible(): boolean;
  7214. render(): boolean;
  7215. dispose(): void;
  7216. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  7217. serialize(): any;
  7218. }
  7219. }
  7220. declare module BABYLON {
  7221. /**
  7222. * A directional light is defined by a direction (what a surprise!).
  7223. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  7224. * 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.
  7225. * Documentation: https://doc.babylonjs.com/babylon101/lights
  7226. */
  7227. class DirectionalLight extends ShadowLight {
  7228. private _shadowFrustumSize;
  7229. /**
  7230. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  7231. */
  7232. /**
  7233. * Specifies a fix frustum size for the shadow generation.
  7234. */
  7235. shadowFrustumSize: number;
  7236. private _shadowOrthoScale;
  7237. /**
  7238. * Gets the shadow projection scale against the optimal computed one.
  7239. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  7240. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  7241. */
  7242. /**
  7243. * Sets the shadow projection scale against the optimal computed one.
  7244. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  7245. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  7246. */
  7247. shadowOrthoScale: number;
  7248. /**
  7249. * Automatically compute the projection matrix to best fit (including all the casters)
  7250. * on each frame.
  7251. */
  7252. autoUpdateExtends: boolean;
  7253. private _orthoLeft;
  7254. private _orthoRight;
  7255. private _orthoTop;
  7256. private _orthoBottom;
  7257. /**
  7258. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  7259. * The directional light is emitted from everywhere in the given direction.
  7260. * It can cast shawdows.
  7261. * Documentation : http://doc.babylonjs.com/tutorials/lights
  7262. * @param name The friendly name of the light
  7263. * @param direction The direction of the light
  7264. * @param scene The scene the light belongs to
  7265. */
  7266. constructor(name: string, direction: Vector3, scene: Scene);
  7267. /**
  7268. * Returns the string "DirectionalLight".
  7269. * @return The class name
  7270. */
  7271. getClassName(): string;
  7272. /**
  7273. * Returns the integer 1.
  7274. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  7275. */
  7276. getTypeID(): number;
  7277. /**
  7278. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  7279. * Returns the DirectionalLight Shadow projection matrix.
  7280. */
  7281. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  7282. /**
  7283. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  7284. * Returns the DirectionalLight Shadow projection matrix.
  7285. */
  7286. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix): void;
  7287. /**
  7288. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  7289. * Returns the DirectionalLight Shadow projection matrix.
  7290. */
  7291. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  7292. protected _buildUniformLayout(): void;
  7293. /**
  7294. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  7295. * @param effect The effect to update
  7296. * @param lightIndex The index of the light in the effect to update
  7297. * @returns The directional light
  7298. */
  7299. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  7300. /**
  7301. * Gets the minZ used for shadow according to both the scene and the light.
  7302. *
  7303. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  7304. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  7305. * @param activeCamera The camera we are returning the min for
  7306. * @returns the depth min z
  7307. */
  7308. getDepthMinZ(activeCamera: Camera): number;
  7309. /**
  7310. * Gets the maxZ used for shadow according to both the scene and the light.
  7311. *
  7312. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  7313. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  7314. * @param activeCamera The camera we are returning the max for
  7315. * @returns the depth max z
  7316. */
  7317. getDepthMaxZ(activeCamera: Camera): number;
  7318. }
  7319. }
  7320. declare module BABYLON {
  7321. /**
  7322. * The HemisphericLight simulates the ambient environment light,
  7323. * so the passed direction is the light reflection direction, not the incoming direction.
  7324. */
  7325. class HemisphericLight extends Light {
  7326. /**
  7327. * The groundColor is the light in the opposite direction to the one specified during creation.
  7328. * 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.
  7329. */
  7330. groundColor: Color3;
  7331. /**
  7332. * The light reflection direction, not the incoming direction.
  7333. */
  7334. direction: Vector3;
  7335. private _worldMatrix;
  7336. /**
  7337. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  7338. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  7339. * The HemisphericLight can't cast shadows.
  7340. * Documentation : http://doc.babylonjs.com/tutorials/lights
  7341. * @param name The friendly name of the light
  7342. * @param direction The direction of the light reflection
  7343. * @param scene The scene the light belongs to
  7344. */
  7345. constructor(name: string, direction: Vector3, scene: Scene);
  7346. protected _buildUniformLayout(): void;
  7347. /**
  7348. * Returns the string "HemisphericLight".
  7349. * @return The class name
  7350. */
  7351. getClassName(): string;
  7352. /**
  7353. * Sets the HemisphericLight direction towards the passed target (Vector3).
  7354. * Returns the updated direction.
  7355. * @param target The target the direction should point to
  7356. * @return The computed direction
  7357. */
  7358. setDirectionToTarget(target: Vector3): Vector3;
  7359. /**
  7360. * Returns the shadow generator associated to the light.
  7361. * @returns Always null for hemispheric lights because it does not support shadows.
  7362. */
  7363. getShadowGenerator(): Nullable<ShadowGenerator>;
  7364. /**
  7365. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  7366. * @param effect The effect to update
  7367. * @param lightIndex The index of the light in the effect to update
  7368. * @returns The hemispheric light
  7369. */
  7370. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  7371. /**
  7372. * @ignore internal use only.
  7373. */
  7374. _getWorldMatrix(): Matrix;
  7375. /**
  7376. * Returns the integer 3.
  7377. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  7378. */
  7379. getTypeID(): number;
  7380. }
  7381. }
  7382. declare module BABYLON {
  7383. /**
  7384. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  7385. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  7386. * 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.
  7387. */
  7388. abstract class Light extends Node {
  7389. private static _LIGHTMAP_DEFAULT;
  7390. private static _LIGHTMAP_SPECULAR;
  7391. private static _LIGHTMAP_SHADOWSONLY;
  7392. /**
  7393. * If every light affecting the material is in this lightmapMode,
  7394. * material.lightmapTexture adds or multiplies
  7395. * (depends on material.useLightmapAsShadowmap)
  7396. * after every other light calculations.
  7397. */
  7398. static readonly LIGHTMAP_DEFAULT: number;
  7399. /**
  7400. * material.lightmapTexture as only diffuse lighting from this light
  7401. * adds only specular lighting from this light
  7402. * adds dynamic shadows
  7403. */
  7404. static readonly LIGHTMAP_SPECULAR: number;
  7405. /**
  7406. * material.lightmapTexture as only lighting
  7407. * no light calculation from this light
  7408. * only adds dynamic shadows from this light
  7409. */
  7410. static readonly LIGHTMAP_SHADOWSONLY: number;
  7411. private static _INTENSITYMODE_AUTOMATIC;
  7412. private static _INTENSITYMODE_LUMINOUSPOWER;
  7413. private static _INTENSITYMODE_LUMINOUSINTENSITY;
  7414. private static _INTENSITYMODE_ILLUMINANCE;
  7415. private static _INTENSITYMODE_LUMINANCE;
  7416. /**
  7417. * Each light type uses the default quantity according to its type:
  7418. * point/spot lights use luminous intensity
  7419. * directional lights use illuminance
  7420. */
  7421. static readonly INTENSITYMODE_AUTOMATIC: number;
  7422. /**
  7423. * lumen (lm)
  7424. */
  7425. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  7426. /**
  7427. * candela (lm/sr)
  7428. */
  7429. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  7430. /**
  7431. * lux (lm/m^2)
  7432. */
  7433. static readonly INTENSITYMODE_ILLUMINANCE: number;
  7434. /**
  7435. * nit (cd/m^2)
  7436. */
  7437. static readonly INTENSITYMODE_LUMINANCE: number;
  7438. private static _LIGHTTYPEID_POINTLIGHT;
  7439. private static _LIGHTTYPEID_DIRECTIONALLIGHT;
  7440. private static _LIGHTTYPEID_SPOTLIGHT;
  7441. private static _LIGHTTYPEID_HEMISPHERICLIGHT;
  7442. /**
  7443. * Light type const id of the point light.
  7444. */
  7445. static readonly LIGHTTYPEID_POINTLIGHT: number;
  7446. /**
  7447. * Light type const id of the directional light.
  7448. */
  7449. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  7450. /**
  7451. * Light type const id of the spot light.
  7452. */
  7453. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  7454. /**
  7455. * Light type const id of the hemispheric light.
  7456. */
  7457. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  7458. /**
  7459. * Diffuse gives the basic color to an object.
  7460. */
  7461. diffuse: Color3;
  7462. /**
  7463. * Specular produces a highlight color on an object.
  7464. * Note: This is note affecting PBR materials.
  7465. */
  7466. specular: Color3;
  7467. /**
  7468. * Strength of the light.
  7469. * Note: By default it is define in the framework own unit.
  7470. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  7471. */
  7472. intensity: number;
  7473. /**
  7474. * Defines how far from the source the light is impacting in scene units.
  7475. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  7476. */
  7477. range: number;
  7478. /**
  7479. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  7480. * of light.
  7481. */
  7482. private _photometricScale;
  7483. private _intensityMode;
  7484. /**
  7485. * Gets the photometric scale used to interpret the intensity.
  7486. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  7487. */
  7488. /**
  7489. * Sets the photometric scale used to interpret the intensity.
  7490. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  7491. */
  7492. intensityMode: number;
  7493. private _radius;
  7494. /**
  7495. * Gets the light radius used by PBR Materials to simulate soft area lights.
  7496. */
  7497. /**
  7498. * sets the light radius used by PBR Materials to simulate soft area lights.
  7499. */
  7500. radius: number;
  7501. private _renderPriority;
  7502. /**
  7503. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  7504. * exceeding the number allowed of the materials.
  7505. */
  7506. renderPriority: number;
  7507. /**
  7508. * Defines wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  7509. * the current shadow generator.
  7510. */
  7511. shadowEnabled: boolean;
  7512. private _includedOnlyMeshes;
  7513. /**
  7514. * Gets the only meshes impacted by this light.
  7515. */
  7516. /**
  7517. * Sets the only meshes impacted by this light.
  7518. */
  7519. includedOnlyMeshes: AbstractMesh[];
  7520. private _excludedMeshes;
  7521. /**
  7522. * Gets the meshes not impacted by this light.
  7523. */
  7524. /**
  7525. * Sets the meshes not impacted by this light.
  7526. */
  7527. excludedMeshes: AbstractMesh[];
  7528. private _excludeWithLayerMask;
  7529. /**
  7530. * Gets the layer id use to find what meshes are not impacted by the light.
  7531. * Inactive if 0
  7532. */
  7533. /**
  7534. * Sets the layer id use to find what meshes are not impacted by the light.
  7535. * Inactive if 0
  7536. */
  7537. excludeWithLayerMask: number;
  7538. private _includeOnlyWithLayerMask;
  7539. /**
  7540. * Gets the layer id use to find what meshes are impacted by the light.
  7541. * Inactive if 0
  7542. */
  7543. /**
  7544. * Sets the layer id use to find what meshes are impacted by the light.
  7545. * Inactive if 0
  7546. */
  7547. includeOnlyWithLayerMask: number;
  7548. private _lightmapMode;
  7549. /**
  7550. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  7551. */
  7552. /**
  7553. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  7554. */
  7555. lightmapMode: number;
  7556. private _parentedWorldMatrix;
  7557. /**
  7558. * Shadow generator associted to the light.
  7559. * Internal use only.
  7560. */
  7561. _shadowGenerator: Nullable<IShadowGenerator>;
  7562. /**
  7563. * @ignore Internal use only.
  7564. */
  7565. _excludedMeshesIds: string[];
  7566. /**
  7567. * @ignore Internal use only.
  7568. */
  7569. _includedOnlyMeshesIds: string[];
  7570. /**
  7571. * The current light unifom buffer.
  7572. * @ignore Internal use only.
  7573. */
  7574. _uniformBuffer: UniformBuffer;
  7575. /**
  7576. * Creates a Light object in the scene.
  7577. * Documentation : http://doc.babylonjs.com/tutorials/lights
  7578. * @param name The firendly name of the light
  7579. * @param scene The scene the light belongs too
  7580. */
  7581. constructor(name: string, scene: Scene);
  7582. protected abstract _buildUniformLayout(): void;
  7583. /**
  7584. * Sets the passed Effect "effect" with the Light information.
  7585. * @param effect The effect to update
  7586. * @param lightIndex The index of the light in the effect to update
  7587. * @returns The light
  7588. */
  7589. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  7590. /**
  7591. * @ignore internal use only.
  7592. */
  7593. abstract _getWorldMatrix(): Matrix;
  7594. /**
  7595. * Returns the string "Light".
  7596. * @returns the class name
  7597. */
  7598. getClassName(): string;
  7599. /**
  7600. * Converts the light information to a readable string for debug purpose.
  7601. * @param fullDetails Supports for multiple levels of logging within scene loading
  7602. * @returns the human readable light info
  7603. */
  7604. toString(fullDetails?: boolean): string;
  7605. /**
  7606. * Set the enabled state of this node.
  7607. * @param value - the new enabled state
  7608. */
  7609. setEnabled(value: boolean): void;
  7610. /**
  7611. * Returns the Light associated shadow generator if any.
  7612. * @return the associated shadow generator.
  7613. */
  7614. getShadowGenerator(): Nullable<IShadowGenerator>;
  7615. /**
  7616. * Returns a Vector3, the absolute light position in the World.
  7617. * @returns the world space position of the light
  7618. */
  7619. getAbsolutePosition(): Vector3;
  7620. /**
  7621. * Specifies if the light will affect the passed mesh.
  7622. * @param mesh The mesh to test against the light
  7623. * @return true the mesh is affected otherwise, false.
  7624. */
  7625. canAffectMesh(mesh: AbstractMesh): boolean;
  7626. /**
  7627. * Computes and Returns the light World matrix.
  7628. * @returns the world matrix
  7629. */
  7630. getWorldMatrix(): Matrix;
  7631. /**
  7632. * Sort function to order lights for rendering.
  7633. * @param a First Light object to compare to second.
  7634. * @param b Second Light object to compare first.
  7635. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  7636. */
  7637. static CompareLightsPriority(a: Light, b: Light): number;
  7638. /**
  7639. * Releases resources associated with this node.
  7640. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  7641. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  7642. */
  7643. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  7644. /**
  7645. * Returns the light type ID (integer).
  7646. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  7647. */
  7648. getTypeID(): number;
  7649. /**
  7650. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  7651. * @returns the scaled intensity in intensity mode unit
  7652. */
  7653. getScaledIntensity(): number;
  7654. /**
  7655. * Returns a new Light object, named "name", from the current one.
  7656. * @param name The name of the cloned light
  7657. * @returns the new created light
  7658. */
  7659. clone(name: string): Nullable<Light>;
  7660. /**
  7661. * Serializes the current light into a Serialization object.
  7662. * @returns the serialized object.
  7663. */
  7664. serialize(): any;
  7665. /**
  7666. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  7667. * This new light is named "name" and added to the passed scene.
  7668. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  7669. * @param name The friendly name of the light
  7670. * @param scene The scene the new light will belong to
  7671. * @returns the constructor function
  7672. */
  7673. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  7674. /**
  7675. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  7676. * @param parsedLight The JSON representation of the light
  7677. * @param scene The scene to create the parsed light in
  7678. * @returns the created light after parsing
  7679. */
  7680. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  7681. private _hookArrayForExcluded(array);
  7682. private _hookArrayForIncludedOnly(array);
  7683. private _resyncMeshes();
  7684. /**
  7685. * Forces the meshes to update their light related information in their rendering used effects
  7686. * @ignore Internal Use Only
  7687. */
  7688. _markMeshesAsLightDirty(): void;
  7689. /**
  7690. * Recomputes the cached photometric scale if needed.
  7691. */
  7692. private _computePhotometricScale();
  7693. /**
  7694. * Returns the Photometric Scale according to the light type and intensity mode.
  7695. */
  7696. private _getPhotometricScale();
  7697. /**
  7698. * Reorder the light in the scene according to their defined priority.
  7699. * @ignore Internal Use Only
  7700. */
  7701. _reorderLightsInScene(): void;
  7702. }
  7703. }
  7704. declare module BABYLON {
  7705. /**
  7706. * A point light is a light defined by an unique point in world space.
  7707. * The light is emitted in every direction from this point.
  7708. * A good example of a point light is a standard light bulb.
  7709. * Documentation: https://doc.babylonjs.com/babylon101/lights
  7710. */
  7711. class PointLight extends ShadowLight {
  7712. private _shadowAngle;
  7713. /**
  7714. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  7715. * This specifies what angle the shadow will use to be created.
  7716. *
  7717. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  7718. */
  7719. /**
  7720. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  7721. * This specifies what angle the shadow will use to be created.
  7722. *
  7723. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  7724. */
  7725. shadowAngle: number;
  7726. /**
  7727. * Gets the direction if it has been set.
  7728. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  7729. */
  7730. /**
  7731. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  7732. */
  7733. direction: Vector3;
  7734. /**
  7735. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  7736. * A PointLight emits the light in every direction.
  7737. * It can cast shadows.
  7738. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  7739. * ```javascript
  7740. * var pointLight = new BABYLON.PointLight("pl", camera.position, scene);
  7741. * ```
  7742. * Documentation : http://doc.babylonjs.com/tutorials/lights
  7743. * @param name The light friendly name
  7744. * @param position The position of the point light in the scene
  7745. * @param scene The scene the lights belongs to
  7746. */
  7747. constructor(name: string, position: Vector3, scene: Scene);
  7748. /**
  7749. * Returns the string "PointLight"
  7750. * @returns the class name
  7751. */
  7752. getClassName(): string;
  7753. /**
  7754. * Returns the integer 0.
  7755. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  7756. */
  7757. getTypeID(): number;
  7758. /**
  7759. * Specifies wether or not the shadowmap should be a cube texture.
  7760. * @returns true if the shadowmap needs to be a cube texture.
  7761. */
  7762. needCube(): boolean;
  7763. /**
  7764. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  7765. * @param faceIndex The index of the face we are computed the direction to generate shadow
  7766. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  7767. */
  7768. getShadowDirection(faceIndex?: number): Vector3;
  7769. /**
  7770. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  7771. * - fov = PI / 2
  7772. * - aspect ratio : 1.0
  7773. * - z-near and far equal to the active camera minZ and maxZ.
  7774. * Returns the PointLight.
  7775. */
  7776. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  7777. protected _buildUniformLayout(): void;
  7778. /**
  7779. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  7780. * @param effect The effect to update
  7781. * @param lightIndex The index of the light in the effect to update
  7782. * @returns The point light
  7783. */
  7784. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  7785. }
  7786. }
  7787. declare module BABYLON {
  7788. /**
  7789. * Interface describing all the common properties and methods a shadow light needs to implement.
  7790. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  7791. * as well as binding the different shadow properties to the effects.
  7792. */
  7793. interface IShadowLight extends Light {
  7794. /**
  7795. * The light id in the scene (used in scene.findLighById for instance)
  7796. */
  7797. id: string;
  7798. /**
  7799. * The position the shdow will be casted from.
  7800. */
  7801. position: Vector3;
  7802. /**
  7803. * In 2d mode (needCube being false), the direction used to cast the shadow.
  7804. */
  7805. direction: Vector3;
  7806. /**
  7807. * The transformed position. Position of the light in world space taking parenting in account.
  7808. */
  7809. transformedPosition: Vector3;
  7810. /**
  7811. * The transformed direction. Direction of the light in world space taking parenting in account.
  7812. */
  7813. transformedDirection: Vector3;
  7814. /**
  7815. * The friendly name of the light in the scene.
  7816. */
  7817. name: string;
  7818. /**
  7819. * Defines the shadow projection clipping minimum z value.
  7820. */
  7821. shadowMinZ: number;
  7822. /**
  7823. * Defines the shadow projection clipping maximum z value.
  7824. */
  7825. shadowMaxZ: number;
  7826. /**
  7827. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  7828. * @returns true if the information has been computed, false if it does not need to (no parenting)
  7829. */
  7830. computeTransformedInformation(): boolean;
  7831. /**
  7832. * Gets the scene the light belongs to.
  7833. * @returns The scene
  7834. */
  7835. getScene(): Scene;
  7836. /**
  7837. * Callback defining a custom Projection Matrix Builder.
  7838. * This can be used to override the default projection matrix computation.
  7839. */
  7840. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  7841. /**
  7842. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  7843. * @param matrix The materix to updated with the projection information
  7844. * @param viewMatrix The transform matrix of the light
  7845. * @param renderList The list of mesh to render in the map
  7846. * @returns The current light
  7847. */
  7848. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  7849. /**
  7850. * Gets the current depth scale used in ESM.
  7851. * @returns The scale
  7852. */
  7853. getDepthScale(): number;
  7854. /**
  7855. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  7856. * @returns true if a cube texture needs to be use
  7857. */
  7858. needCube(): boolean;
  7859. /**
  7860. * Detects if the projection matrix requires to be recomputed this frame.
  7861. * @returns true if it requires to be recomputed otherwise, false.
  7862. */
  7863. needProjectionMatrixCompute(): boolean;
  7864. /**
  7865. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  7866. */
  7867. forceProjectionMatrixCompute(): void;
  7868. /**
  7869. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  7870. * @param faceIndex The index of the face we are computed the direction to generate shadow
  7871. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  7872. */
  7873. getShadowDirection(faceIndex?: number): Vector3;
  7874. /**
  7875. * Gets the minZ used for shadow according to both the scene and the light.
  7876. * @param activeCamera The camera we are returning the min for
  7877. * @returns the depth min z
  7878. */
  7879. getDepthMinZ(activeCamera: Camera): number;
  7880. /**
  7881. * Gets the maxZ used for shadow according to both the scene and the light.
  7882. * @param activeCamera The camera we are returning the max for
  7883. * @returns the depth max z
  7884. */
  7885. getDepthMaxZ(activeCamera: Camera): number;
  7886. }
  7887. /**
  7888. * Base implementation IShadowLight
  7889. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  7890. */
  7891. abstract class ShadowLight extends Light implements IShadowLight {
  7892. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  7893. protected _position: Vector3;
  7894. protected _setPosition(value: Vector3): void;
  7895. /**
  7896. * Sets the position the shadow will be casted from. Also use as the light position for both
  7897. * point and spot lights.
  7898. */
  7899. /**
  7900. * Sets the position the shadow will be casted from. Also use as the light position for both
  7901. * point and spot lights.
  7902. */
  7903. position: Vector3;
  7904. protected _direction: Vector3;
  7905. protected _setDirection(value: Vector3): void;
  7906. /**
  7907. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  7908. * Also use as the light direction on spot and directional lights.
  7909. */
  7910. /**
  7911. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  7912. * Also use as the light direction on spot and directional lights.
  7913. */
  7914. direction: Vector3;
  7915. private _shadowMinZ;
  7916. /**
  7917. * Gets the shadow projection clipping minimum z value.
  7918. */
  7919. /**
  7920. * Sets the shadow projection clipping minimum z value.
  7921. */
  7922. shadowMinZ: number;
  7923. private _shadowMaxZ;
  7924. /**
  7925. * Sets the shadow projection clipping maximum z value.
  7926. */
  7927. /**
  7928. * Gets the shadow projection clipping maximum z value.
  7929. */
  7930. shadowMaxZ: number;
  7931. /**
  7932. * Callback defining a custom Projection Matrix Builder.
  7933. * This can be used to override the default projection matrix computation.
  7934. */
  7935. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  7936. /**
  7937. * The transformed position. Position of the light in world space taking parenting in account.
  7938. */
  7939. transformedPosition: Vector3;
  7940. /**
  7941. * The transformed direction. Direction of the light in world space taking parenting in account.
  7942. */
  7943. transformedDirection: Vector3;
  7944. private _worldMatrix;
  7945. private _needProjectionMatrixCompute;
  7946. /**
  7947. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  7948. * @returns true if the information has been computed, false if it does not need to (no parenting)
  7949. */
  7950. computeTransformedInformation(): boolean;
  7951. /**
  7952. * Return the depth scale used for the shadow map.
  7953. * @returns the depth scale.
  7954. */
  7955. getDepthScale(): number;
  7956. /**
  7957. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  7958. * @param faceIndex The index of the face we are computed the direction to generate shadow
  7959. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  7960. */
  7961. getShadowDirection(faceIndex?: number): Vector3;
  7962. /**
  7963. * Returns the ShadowLight absolute position in the World.
  7964. * @returns the position vector in world space
  7965. */
  7966. getAbsolutePosition(): Vector3;
  7967. /**
  7968. * Sets the ShadowLight direction toward the passed target.
  7969. * @param target The point tot target in local space
  7970. * @returns the updated ShadowLight direction
  7971. */
  7972. setDirectionToTarget(target: Vector3): Vector3;
  7973. /**
  7974. * Returns the light rotation in euler definition.
  7975. * @returns the x y z rotation in local space.
  7976. */
  7977. getRotation(): Vector3;
  7978. /**
  7979. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  7980. * @returns true if a cube texture needs to be use
  7981. */
  7982. needCube(): boolean;
  7983. /**
  7984. * Detects if the projection matrix requires to be recomputed this frame.
  7985. * @returns true if it requires to be recomputed otherwise, false.
  7986. */
  7987. needProjectionMatrixCompute(): boolean;
  7988. /**
  7989. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  7990. */
  7991. forceProjectionMatrixCompute(): void;
  7992. /**
  7993. * Get the world matrix of the sahdow lights.
  7994. * @ignore Internal Use Only
  7995. */
  7996. _getWorldMatrix(): Matrix;
  7997. /**
  7998. * Gets the minZ used for shadow according to both the scene and the light.
  7999. * @param activeCamera The camera we are returning the min for
  8000. * @returns the depth min z
  8001. */
  8002. getDepthMinZ(activeCamera: Camera): number;
  8003. /**
  8004. * Gets the maxZ used for shadow according to both the scene and the light.
  8005. * @param activeCamera The camera we are returning the max for
  8006. * @returns the depth max z
  8007. */
  8008. getDepthMaxZ(activeCamera: Camera): number;
  8009. /**
  8010. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8011. * @param matrix The materix to updated with the projection information
  8012. * @param viewMatrix The transform matrix of the light
  8013. * @param renderList The list of mesh to render in the map
  8014. * @returns The current light
  8015. */
  8016. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8017. }
  8018. }
  8019. declare module BABYLON {
  8020. /**
  8021. * A spot light is defined by a position, a direction, an angle, and an exponent.
  8022. * These values define a cone of light starting from the position, emitting toward the direction.
  8023. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  8024. * and the exponent defines the speed of the decay of the light with distance (reach).
  8025. * Documentation: https://doc.babylonjs.com/babylon101/lights
  8026. */
  8027. class SpotLight extends ShadowLight {
  8028. private _angle;
  8029. /**
  8030. * Gets the cone angle of the spot light in Radians.
  8031. */
  8032. /**
  8033. * Sets the cone angle of the spot light in Radians.
  8034. */
  8035. angle: number;
  8036. private _shadowAngleScale;
  8037. /**
  8038. * Allows scaling the angle of the light for shadow generation only.
  8039. */
  8040. /**
  8041. * Allows scaling the angle of the light for shadow generation only.
  8042. */
  8043. shadowAngleScale: number;
  8044. /**
  8045. * The light decay speed with the distance from the emission spot.
  8046. */
  8047. exponent: number;
  8048. private _projectionTextureMatrix;
  8049. /**
  8050. * Allows reading the projecton texture
  8051. */
  8052. readonly projectionTextureMatrix: Matrix;
  8053. protected _projectionTextureLightNear: number;
  8054. /**
  8055. * Gets the near clip of the Spotlight for texture projection.
  8056. */
  8057. /**
  8058. * Sets the near clip of the Spotlight for texture projection.
  8059. */
  8060. projectionTextureLightNear: number;
  8061. protected _projectionTextureLightFar: number;
  8062. /**
  8063. * Gets the far clip of the Spotlight for texture projection.
  8064. */
  8065. /**
  8066. * Sets the far clip of the Spotlight for texture projection.
  8067. */
  8068. projectionTextureLightFar: number;
  8069. protected _projectionTextureUpDirection: Vector3;
  8070. /**
  8071. * Gets the Up vector of the Spotlight for texture projection.
  8072. */
  8073. /**
  8074. * Sets the Up vector of the Spotlight for texture projection.
  8075. */
  8076. projectionTextureUpDirection: Vector3;
  8077. private _projectionTexture;
  8078. /**
  8079. * Gets the projection texture of the light.
  8080. */
  8081. /**
  8082. * Sets the projection texture of the light.
  8083. */
  8084. projectionTexture: Nullable<BaseTexture>;
  8085. private _projectionTextureViewLightDirty;
  8086. private _projectionTextureProjectionLightDirty;
  8087. private _projectionTextureDirty;
  8088. private _projectionTextureViewTargetVector;
  8089. private _projectionTextureViewLightMatrix;
  8090. private _projectionTextureProjectionLightMatrix;
  8091. private _projectionTextureScalingMatrix;
  8092. /**
  8093. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  8094. * It can cast shadows.
  8095. * Documentation : http://doc.babylonjs.com/tutorials/lights
  8096. * @param name The light friendly name
  8097. * @param position The position of the spot light in the scene
  8098. * @param direction The direction of the light in the scene
  8099. * @param angle The cone angle of the light in Radians
  8100. * @param exponent The light decay speed with the distance from the emission spot
  8101. * @param scene The scene the lights belongs to
  8102. */
  8103. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  8104. /**
  8105. * Returns the string "SpotLight".
  8106. * @returns the class name
  8107. */
  8108. getClassName(): string;
  8109. /**
  8110. * Returns the integer 2.
  8111. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  8112. */
  8113. getTypeID(): number;
  8114. /**
  8115. * Overrides the direction setter to recompute the projection texture view light Matrix.
  8116. */
  8117. protected _setDirection(value: Vector3): void;
  8118. /**
  8119. * Overrides the position setter to recompute the projection texture view light Matrix.
  8120. */
  8121. protected _setPosition(value: Vector3): void;
  8122. /**
  8123. * 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.
  8124. * Returns the SpotLight.
  8125. */
  8126. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  8127. protected _computeProjectionTextureViewLightMatrix(): void;
  8128. protected _computeProjectionTextureProjectionLightMatrix(): void;
  8129. /**
  8130. * Main function for light texture projection matrix computing.
  8131. */
  8132. protected _computeProjectionTextureMatrix(): void;
  8133. protected _buildUniformLayout(): void;
  8134. /**
  8135. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  8136. * @param effect The effect to update
  8137. * @param lightIndex The index of the light in the effect to update
  8138. * @returns The spot light
  8139. */
  8140. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  8141. /**
  8142. * Disposes the light and the associated resources.
  8143. */
  8144. dispose(): void;
  8145. }
  8146. }
  8147. declare module BABYLON {
  8148. interface ILoadingScreen {
  8149. displayLoadingUI: () => void;
  8150. hideLoadingUI: () => void;
  8151. loadingUIBackgroundColor: string;
  8152. loadingUIText: string;
  8153. }
  8154. class DefaultLoadingScreen implements ILoadingScreen {
  8155. private _renderingCanvas;
  8156. private _loadingText;
  8157. private _loadingDivBackgroundColor;
  8158. private _loadingDiv;
  8159. private _loadingTextDiv;
  8160. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  8161. displayLoadingUI(): void;
  8162. hideLoadingUI(): void;
  8163. loadingUIText: string;
  8164. loadingUIBackgroundColor: string;
  8165. private _resizeLoadingUI;
  8166. }
  8167. }
  8168. declare module BABYLON {
  8169. class SceneLoaderProgressEvent {
  8170. readonly lengthComputable: boolean;
  8171. readonly loaded: number;
  8172. readonly total: number;
  8173. constructor(lengthComputable: boolean, loaded: number, total: number);
  8174. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  8175. }
  8176. interface ISceneLoaderPluginExtensions {
  8177. [extension: string]: {
  8178. isBinary: boolean;
  8179. };
  8180. }
  8181. interface ISceneLoaderPluginFactory {
  8182. name: string;
  8183. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  8184. canDirectLoad?: (data: string) => boolean;
  8185. }
  8186. interface ISceneLoaderPlugin {
  8187. /**
  8188. * The friendly name of this plugin.
  8189. */
  8190. name: string;
  8191. /**
  8192. * The file extensions supported by this plugin.
  8193. */
  8194. extensions: string | ISceneLoaderPluginExtensions;
  8195. /**
  8196. * Import meshes into a scene.
  8197. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  8198. * @param scene The scene to import into
  8199. * @param data The data to import
  8200. * @param rootUrl The root url for scene and resources
  8201. * @param meshes The meshes array to import into
  8202. * @param particleSystems The particle systems array to import into
  8203. * @param skeletons The skeletons array to import into
  8204. * @param onError The callback when import fails
  8205. * @returns True if successful or false otherwise
  8206. */
  8207. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: ParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  8208. /**
  8209. * Load into a scene.
  8210. * @param scene The scene to load into
  8211. * @param data The data to import
  8212. * @param rootUrl The root url for scene and resources
  8213. * @param onError The callback when import fails
  8214. * @returns true if successful or false otherwise
  8215. */
  8216. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  8217. /**
  8218. * The callback that returns true if the data can be directly loaded.
  8219. */
  8220. canDirectLoad?: (data: string) => boolean;
  8221. /**
  8222. * The callback that allows custom handling of the root url based on the response url.
  8223. */
  8224. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  8225. /**
  8226. * Load into an asset container.
  8227. * @param scene The scene to load into
  8228. * @param data The data to import
  8229. * @param rootUrl The root url for scene and resources
  8230. * @param onError The callback when import fails
  8231. * @returns The loaded asset container
  8232. */
  8233. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  8234. }
  8235. interface ISceneLoaderPluginAsync {
  8236. /**
  8237. * The friendly name of this plugin.
  8238. */
  8239. name: string;
  8240. /**
  8241. * The file extensions supported by this plugin.
  8242. */
  8243. extensions: string | ISceneLoaderPluginExtensions;
  8244. /**
  8245. * Import meshes into a scene.
  8246. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  8247. * @param scene The scene to import into
  8248. * @param data The data to import
  8249. * @param rootUrl The root url for scene and resources
  8250. * @param onProgress The callback when the load progresses
  8251. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  8252. */
  8253. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<{
  8254. meshes: AbstractMesh[];
  8255. particleSystems: ParticleSystem[];
  8256. skeletons: Skeleton[];
  8257. animationGroups: AnimationGroup[];
  8258. }>;
  8259. /**
  8260. * Load into a scene.
  8261. * @param scene The scene to load into
  8262. * @param data The data to import
  8263. * @param rootUrl The root url for scene and resources
  8264. * @param onProgress The callback when the load progresses
  8265. * @returns Nothing
  8266. */
  8267. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<void>;
  8268. /**
  8269. * The callback that returns true if the data can be directly loaded.
  8270. */
  8271. canDirectLoad?: (data: string) => boolean;
  8272. /**
  8273. * The callback that allows custom handling of the root url based on the response url.
  8274. */
  8275. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  8276. /**
  8277. * Load into an asset container.
  8278. * @param scene The scene to load into
  8279. * @param data The data to import
  8280. * @param rootUrl The root url for scene and resources
  8281. * @param onProgress The callback when the load progresses
  8282. * @returns The loaded asset container
  8283. */
  8284. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<AssetContainer>;
  8285. }
  8286. class SceneLoader {
  8287. private static _ForceFullSceneLoadingForIncremental;
  8288. private static _ShowLoadingScreen;
  8289. private static _CleanBoneMatrixWeights;
  8290. static readonly NO_LOGGING: number;
  8291. static readonly MINIMAL_LOGGING: number;
  8292. static readonly SUMMARY_LOGGING: number;
  8293. static readonly DETAILED_LOGGING: number;
  8294. private static _loggingLevel;
  8295. static ForceFullSceneLoadingForIncremental: boolean;
  8296. static ShowLoadingScreen: boolean;
  8297. static loggingLevel: number;
  8298. static CleanBoneMatrixWeights: boolean;
  8299. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  8300. private static _registeredPlugins;
  8301. private static _getDefaultPlugin();
  8302. private static _getPluginForExtension(extension);
  8303. private static _getPluginForDirectLoad(data);
  8304. private static _getPluginForFilename(sceneFilename);
  8305. private static _getDirectLoad(sceneFilename);
  8306. private static _loadData(rootUrl, sceneFilename, scene, onSuccess, onProgress, onError, onDispose, pluginExtension);
  8307. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  8308. static IsPluginForExtensionAvailable(extension: string): boolean;
  8309. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  8310. /**
  8311. * Import meshes into a scene
  8312. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  8313. * @param rootUrl a string that defines the root url for scene and resources
  8314. * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene
  8315. * @param scene the instance of BABYLON.Scene to append to
  8316. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  8317. * @param onProgress a callback with a progress event for each file being loaded
  8318. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  8319. * @param pluginExtension the extension used to determine the plugin
  8320. * @returns The loaded plugin
  8321. */
  8322. static ImportMesh(meshNames: any, rootUrl: string, sceneFilename: string, scene: Scene, onSuccess?: Nullable<(meshes: AbstractMesh[], particleSystems: ParticleSystem[], skeletons: Skeleton[], animationGroups: AnimationGroup[]) => void>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>, pluginExtension?: Nullable<string>): Nullable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  8323. /**
  8324. * Import meshes into a scene
  8325. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  8326. * @param rootUrl a string that defines the root url for scene and resources
  8327. * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene
  8328. * @param scene the instance of BABYLON.Scene to append to
  8329. * @param onProgress a callback with a progress event for each file being loaded
  8330. * @param pluginExtension the extension used to determine the plugin
  8331. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  8332. */
  8333. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename: string, scene: Scene, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  8334. meshes: AbstractMesh[];
  8335. particleSystems: ParticleSystem[];
  8336. skeletons: Skeleton[];
  8337. animationGroups: AnimationGroup[];
  8338. }>;
  8339. /**
  8340. * Load a scene
  8341. * @param rootUrl a string that defines the root url for scene and resources
  8342. * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene
  8343. * @param engine is the instance of BABYLON.Engine to use to create the scene
  8344. * @param onSuccess a callback with the scene when import succeeds
  8345. * @param onProgress a callback with a progress event for each file being loaded
  8346. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  8347. * @param pluginExtension the extension used to determine the plugin
  8348. * @returns The loaded plugin
  8349. */
  8350. 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>;
  8351. /**
  8352. * Load a scene
  8353. * @param rootUrl a string that defines the root url for scene and resources
  8354. * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene
  8355. * @param engine is the instance of BABYLON.Engine to use to create the scene
  8356. * @param onProgress a callback with a progress event for each file being loaded
  8357. * @param pluginExtension the extension used to determine the plugin
  8358. * @returns The loaded scene
  8359. */
  8360. static LoadAsync(rootUrl: string, sceneFilename: any, engine: Engine, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  8361. /**
  8362. * Append a scene
  8363. * @param rootUrl a string that defines the root url for scene and resources
  8364. * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene
  8365. * @param scene is the instance of BABYLON.Scene to append to
  8366. * @param onSuccess a callback with the scene when import succeeds
  8367. * @param onProgress a callback with a progress event for each file being loaded
  8368. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  8369. * @param pluginExtension the extension used to determine the plugin
  8370. * @returns The loaded plugin
  8371. */
  8372. 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>;
  8373. /**
  8374. * Append a scene
  8375. * @param rootUrl a string that defines the root url for scene and resources
  8376. * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene
  8377. * @param scene is the instance of BABYLON.Scene to append to
  8378. * @param onProgress a callback with a progress event for each file being loaded
  8379. * @param pluginExtension the extension used to determine the plugin
  8380. * @returns The given scene
  8381. */
  8382. static AppendAsync(rootUrl: string, sceneFilename: any, scene: Scene, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  8383. /**
  8384. * Load a scene into an asset container
  8385. * @param rootUrl a string that defines the root url for scene and resources
  8386. * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene
  8387. * @param scene is the instance of BABYLON.Scene to append to
  8388. * @param onSuccess a callback with the scene when import succeeds
  8389. * @param onProgress a callback with a progress event for each file being loaded
  8390. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  8391. * @param pluginExtension the extension used to determine the plugin
  8392. * @returns The loaded plugin
  8393. */
  8394. 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>;
  8395. /**
  8396. * Load a scene into an asset container
  8397. * @param rootUrl a string that defines the root url for scene and resources
  8398. * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene
  8399. * @param scene is the instance of BABYLON.Scene to append to
  8400. * @param onProgress a callback with a progress event for each file being loaded
  8401. * @param pluginExtension the extension used to determine the plugin
  8402. * @returns The loaded asset container
  8403. */
  8404. static LoadAssetContainerAsync(rootUrl: string, sceneFilename: any, scene: Scene, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  8405. }
  8406. }
  8407. declare module BABYLON {
  8408. class Scalar {
  8409. /**
  8410. * Two pi constants convenient for computation.
  8411. */
  8412. static TwoPi: number;
  8413. /**
  8414. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  8415. */
  8416. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  8417. /**
  8418. * Returns a string : the upper case translation of the number i to hexadecimal.
  8419. */
  8420. static ToHex(i: number): string;
  8421. /**
  8422. * Returns -1 if value is negative and +1 is value is positive.
  8423. * Returns the value itself if it's equal to zero.
  8424. */
  8425. static Sign(value: number): number;
  8426. /**
  8427. * Returns the value itself if it's between min and max.
  8428. * Returns min if the value is lower than min.
  8429. * Returns max if the value is greater than max.
  8430. */
  8431. static Clamp(value: number, min?: number, max?: number): number;
  8432. /**
  8433. * Returns the log2 of value.
  8434. */
  8435. static Log2(value: number): number;
  8436. /**
  8437. * Loops the value, so that it is never larger than length and never smaller than 0.
  8438. *
  8439. * This is similar to the modulo operator but it works with floating point numbers.
  8440. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  8441. * With t = 5 and length = 2.5, the result would be 0.0.
  8442. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  8443. */
  8444. static Repeat(value: number, length: number): number;
  8445. /**
  8446. * Normalize the value between 0.0 and 1.0 using min and max values
  8447. */
  8448. static Normalize(value: number, min: number, max: number): number;
  8449. /**
  8450. * Denormalize the value from 0.0 and 1.0 using min and max values
  8451. */
  8452. static Denormalize(normalized: number, min: number, max: number): number;
  8453. /**
  8454. * Calculates the shortest difference between two given angles given in degrees.
  8455. */
  8456. static DeltaAngle(current: number, target: number): number;
  8457. /**
  8458. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  8459. *
  8460. * The returned value will move back and forth between 0 and length
  8461. */
  8462. static PingPong(tx: number, length: number): number;
  8463. /**
  8464. * Interpolates between min and max with smoothing at the limits.
  8465. *
  8466. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  8467. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  8468. */
  8469. static SmoothStep(from: number, to: number, tx: number): number;
  8470. /**
  8471. * Moves a value current towards target.
  8472. *
  8473. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  8474. * Negative values of maxDelta pushes the value away from target.
  8475. */
  8476. static MoveTowards(current: number, target: number, maxDelta: number): number;
  8477. /**
  8478. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  8479. *
  8480. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  8481. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  8482. */
  8483. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  8484. /**
  8485. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  8486. */
  8487. static Lerp(start: number, end: number, amount: number): number;
  8488. /**
  8489. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  8490. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  8491. */
  8492. static LerpAngle(start: number, end: number, amount: number): number;
  8493. /**
  8494. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  8495. */
  8496. static InverseLerp(a: number, b: number, value: number): number;
  8497. /**
  8498. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  8499. */
  8500. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  8501. /**
  8502. * Returns a random float number between and min and max values
  8503. */
  8504. static RandomRange(min: number, max: number): number;
  8505. /**
  8506. * This function returns percentage of a number in a given range.
  8507. *
  8508. * RangeToPercent(40,20,60) will return 0.5 (50%)
  8509. * RangeToPercent(34,0,100) will return 0.34 (34%)
  8510. */
  8511. static RangeToPercent(number: number, min: number, max: number): number;
  8512. /**
  8513. * This function returns number that corresponds to the percentage in a given range.
  8514. *
  8515. * PercentToRange(0.34,0,100) will return 34.
  8516. */
  8517. static PercentToRange(percent: number, min: number, max: number): number;
  8518. /**
  8519. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  8520. * @param angle The angle to normalize in radian.
  8521. * @return The converted angle.
  8522. */
  8523. static NormalizeRadians(angle: number): number;
  8524. }
  8525. }
  8526. declare module BABYLON {
  8527. const ToGammaSpace: number;
  8528. const ToLinearSpace = 2.2;
  8529. const Epsilon = 0.001;
  8530. /**
  8531. * Class used to hold a RBG color
  8532. */
  8533. class Color3 {
  8534. /**
  8535. * Defines the red component (between 0 and 1, default is 0)
  8536. */
  8537. r: number;
  8538. /**
  8539. * Defines the green component (between 0 and 1, default is 0)
  8540. */
  8541. g: number;
  8542. /**
  8543. * Defines the blue component (between 0 and 1, default is 0)
  8544. */
  8545. b: number;
  8546. /**
  8547. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  8548. * @param r defines the red component (between 0 and 1, default is 0)
  8549. * @param g defines the green component (between 0 and 1, default is 0)
  8550. * @param b defines the blue component (between 0 and 1, default is 0)
  8551. */
  8552. constructor(
  8553. /**
  8554. * Defines the red component (between 0 and 1, default is 0)
  8555. */
  8556. r?: number,
  8557. /**
  8558. * Defines the green component (between 0 and 1, default is 0)
  8559. */
  8560. g?: number,
  8561. /**
  8562. * Defines the blue component (between 0 and 1, default is 0)
  8563. */
  8564. b?: number);
  8565. /**
  8566. * Creates a string with the Color3 current values
  8567. * @returns the string representation of the Color3 object
  8568. */
  8569. toString(): string;
  8570. /**
  8571. * Returns the string "Color3"
  8572. * @returns "Color3"
  8573. */
  8574. getClassName(): string;
  8575. /**
  8576. * Compute the Color3 hash code
  8577. * @returns an unique number that can be used to hash Color3 objects
  8578. */
  8579. getHashCode(): number;
  8580. /**
  8581. * Stores in the passed array from the passed starting index the red, green, blue values as successive elements
  8582. * @param array defines the array where to store the r,g,b components
  8583. * @param index defines an optional index in the target array to define where to start storing values
  8584. * @returns the current Color3 object
  8585. */
  8586. toArray(array: FloatArray, index?: number): Color3;
  8587. /**
  8588. * Returns a new {BABYLON.Color4} object from the current Color3 and the passed alpha
  8589. * @param alpha defines the alpha component on the new {BABYLON.Color4} object (default is 1)
  8590. * @returns a new {BABYLON.Color4} object
  8591. */
  8592. toColor4(alpha?: number): Color4;
  8593. /**
  8594. * Returns a new array populated with 3 numeric elements : red, green and blue values
  8595. * @returns the new array
  8596. */
  8597. asArray(): number[];
  8598. /**
  8599. * Returns the luminance value
  8600. * @returns a float value
  8601. */
  8602. toLuminance(): number;
  8603. /**
  8604. * Multiply each Color3 rgb values by the passed Color3 rgb values in a new Color3 object
  8605. * @param otherColor defines the second operand
  8606. * @returns the new Color3 object
  8607. */
  8608. multiply(otherColor: Color3): Color3;
  8609. /**
  8610. * Multiply the rgb values of the Color3 and the passed Color3 and stores the result in the object "result"
  8611. * @param otherColor defines the second operand
  8612. * @param result defines the Color3 object where to store the result
  8613. * @returns the current Color3
  8614. */
  8615. multiplyToRef(otherColor: Color3, result: Color3): Color3;
  8616. /**
  8617. * Determines equality between Color3 objects
  8618. * @param otherColor defines the second operand
  8619. * @returns true if the rgb values are equal to the passed ones
  8620. */
  8621. equals(otherColor: Color3): boolean;
  8622. /**
  8623. * Determines equality between the current Color3 object and a set of r,b,g values
  8624. * @param r defines the red component to check
  8625. * @param g defines the green component to check
  8626. * @param b defines the blue component to check
  8627. * @returns true if the rgb values are equal to the passed ones
  8628. */
  8629. equalsFloats(r: number, g: number, b: number): boolean;
  8630. /**
  8631. * Multiplies in place each rgb value by scale
  8632. * @param scale defines the scaling factor
  8633. * @returns the updated Color3
  8634. */
  8635. scale(scale: number): Color3;
  8636. /**
  8637. * Multiplies the rgb values by scale and stores the result into "result"
  8638. * @param scale defines the scaling factor
  8639. * @param result defines the Color3 object where to store the result
  8640. * @returns the unmodified current Color3
  8641. */
  8642. scaleToRef(scale: number, result: Color3): Color3;
  8643. /**
  8644. * Scale the current Color3 values by a factor and add the result to a given Color3
  8645. * @param scale defines the scale factor
  8646. * @param result defines color to store the result into
  8647. * @returns the unmodified current Color3
  8648. */
  8649. scaleAndAddToRef(scale: number, result: Color3): Color3;
  8650. /**
  8651. * Clamps the rgb values by the min and max values and stores the result into "result"
  8652. * @param min defines minimum clamping value (default is 0)
  8653. * @param max defines maximum clamping value (default is 1)
  8654. * @param result defines color to store the result into
  8655. * @returns the original Color3
  8656. */
  8657. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  8658. /**
  8659. * Creates a new Color3 set with the added values of the current Color3 and of the passed one
  8660. * @param otherColor defines the second operand
  8661. * @returns the new Color3
  8662. */
  8663. add(otherColor: Color3): Color3;
  8664. /**
  8665. * Stores the result of the addition of the current Color3 and passed one rgb values into "result"
  8666. * @param otherColor defines the second operand
  8667. * @param result defines Color3 object to store the result into
  8668. * @returns the unmodified current Color3
  8669. */
  8670. addToRef(otherColor: Color3, result: Color3): Color3;
  8671. /**
  8672. * Returns a new Color3 set with the subtracted values of the passed one from the current Color3
  8673. * @param otherColor defines the second operand
  8674. * @returns the new Color3
  8675. */
  8676. subtract(otherColor: Color3): Color3;
  8677. /**
  8678. * Stores the result of the subtraction of passed one from the current Color3 rgb values into "result"
  8679. * @param otherColor defines the second operand
  8680. * @param result defines Color3 object to store the result into
  8681. * @returns the unmodified current Color3
  8682. */
  8683. subtractToRef(otherColor: Color3, result: Color3): Color3;
  8684. /**
  8685. * Copy the current object
  8686. * @returns a new Color3 copied the current one
  8687. */
  8688. clone(): Color3;
  8689. /**
  8690. * Copies the rgb values from the source in the current Color3
  8691. * @param source defines the source Color3 object
  8692. * @returns the updated Color3 object
  8693. */
  8694. copyFrom(source: Color3): Color3;
  8695. /**
  8696. * Updates the Color3 rgb values from the passed floats
  8697. * @param r defines the red component to read from
  8698. * @param g defines the green component to read from
  8699. * @param b defines the blue component to read from
  8700. * @returns the current Color3 object
  8701. */
  8702. copyFromFloats(r: number, g: number, b: number): Color3;
  8703. /**
  8704. * Updates the Color3 rgb values from the passed floats
  8705. * @param r defines the red component to read from
  8706. * @param g defines the green component to read from
  8707. * @param b defines the blue component to read from
  8708. * @returns the current Color3 object
  8709. */
  8710. set(r: number, g: number, b: number): Color3;
  8711. /**
  8712. * Compute the Color3 hexadecimal code as a string
  8713. * @returns a string containing the hexadecimal representation of the Color3 object
  8714. */
  8715. toHexString(): string;
  8716. /**
  8717. * Computes a new Color3 converted from the current one to linear space
  8718. * @returns a new Color3 object
  8719. */
  8720. toLinearSpace(): Color3;
  8721. /**
  8722. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  8723. * @param convertedColor defines the Color3 object where to store the linear space version
  8724. * @returns the unmodified Color3
  8725. */
  8726. toLinearSpaceToRef(convertedColor: Color3): Color3;
  8727. /**
  8728. * Computes a new Color3 converted from the current one to gamma space
  8729. * @returns a new Color3 object
  8730. */
  8731. toGammaSpace(): Color3;
  8732. /**
  8733. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  8734. * @param convertedColor defines the Color3 object where to store the gamma space version
  8735. * @returns the unmodified Color3
  8736. */
  8737. toGammaSpaceToRef(convertedColor: Color3): Color3;
  8738. /**
  8739. * Creates a new Color3 from the string containing valid hexadecimal values
  8740. * @param hex defines a string containing valid hexadecimal values
  8741. * @returns a new Color3 object
  8742. */
  8743. static FromHexString(hex: string): Color3;
  8744. /**
  8745. * Creates a new Vector3 from the starting index of the passed array
  8746. * @param array defines the source array
  8747. * @param offset defines an offset in the source array
  8748. * @returns a new Color3 object
  8749. */
  8750. static FromArray(array: ArrayLike<number>, offset?: number): Color3;
  8751. /**
  8752. * Creates a new Color3 from integer values (< 256)
  8753. * @param r defines the red component to read from (value between 0 and 255)
  8754. * @param g defines the green component to read from (value between 0 and 255)
  8755. * @param b defines the blue component to read from (value between 0 and 255)
  8756. * @returns a new Color3 object
  8757. */
  8758. static FromInts(r: number, g: number, b: number): Color3;
  8759. /**
  8760. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  8761. * @param start defines the start Color3 value
  8762. * @param end defines the end Color3 value
  8763. * @param amount defines the gradient value between start and end
  8764. * @returns a new Color3 object
  8765. */
  8766. static Lerp(start: Color3, end: Color3, amount: number): Color3;
  8767. /**
  8768. * Returns a Color3 value containing a red color
  8769. * @returns a new Color3 object
  8770. */
  8771. static Red(): Color3;
  8772. /**
  8773. * Returns a Color3 value containing a green color
  8774. * @returns a new Color3 object
  8775. */
  8776. static Green(): Color3;
  8777. /**
  8778. * Returns a Color3 value containing a blue color
  8779. * @returns a new Color3 object
  8780. */
  8781. static Blue(): Color3;
  8782. /**
  8783. * Returns a Color3 value containing a black color
  8784. * @returns a new Color3 object
  8785. */
  8786. static Black(): Color3;
  8787. /**
  8788. * Returns a Color3 value containing a white color
  8789. * @returns a new Color3 object
  8790. */
  8791. static White(): Color3;
  8792. /**
  8793. * Returns a Color3 value containing a purple color
  8794. * @returns a new Color3 object
  8795. */
  8796. static Purple(): Color3;
  8797. /**
  8798. * Returns a Color3 value containing a magenta color
  8799. * @returns a new Color3 object
  8800. */
  8801. static Magenta(): Color3;
  8802. /**
  8803. * Returns a Color3 value containing a yellow color
  8804. * @returns a new Color3 object
  8805. */
  8806. static Yellow(): Color3;
  8807. /**
  8808. * Returns a Color3 value containing a gray color
  8809. * @returns a new Color3 object
  8810. */
  8811. static Gray(): Color3;
  8812. /**
  8813. * Returns a Color3 value containing a teal color
  8814. * @returns a new Color3 object
  8815. */
  8816. static Teal(): Color3;
  8817. /**
  8818. * Returns a Color3 value containing a random color
  8819. * @returns a new Color3 object
  8820. */
  8821. static Random(): Color3;
  8822. }
  8823. /**
  8824. * Class used to hold a RBGA color
  8825. */
  8826. class Color4 {
  8827. /**
  8828. * Defines the red component (between 0 and 1, default is 0)
  8829. */
  8830. r: number;
  8831. /**
  8832. * Defines the green component (between 0 and 1, default is 0)
  8833. */
  8834. g: number;
  8835. /**
  8836. * Defines the blue component (between 0 and 1, default is 0)
  8837. */
  8838. b: number;
  8839. /**
  8840. * Defines the alpha component (between 0 and 1, default is 1)
  8841. */
  8842. a: number;
  8843. /**
  8844. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  8845. * @param r defines the red component (between 0 and 1, default is 0)
  8846. * @param g defines the green component (between 0 and 1, default is 0)
  8847. * @param b defines the blue component (between 0 and 1, default is 0)
  8848. * @param a defines the alpha component (between 0 and 1, default is 1)
  8849. */
  8850. constructor(
  8851. /**
  8852. * Defines the red component (between 0 and 1, default is 0)
  8853. */
  8854. r?: number,
  8855. /**
  8856. * Defines the green component (between 0 and 1, default is 0)
  8857. */
  8858. g?: number,
  8859. /**
  8860. * Defines the blue component (between 0 and 1, default is 0)
  8861. */
  8862. b?: number,
  8863. /**
  8864. * Defines the alpha component (between 0 and 1, default is 1)
  8865. */
  8866. a?: number);
  8867. /**
  8868. * Adds in place the passed Color4 values to the current Color4 object
  8869. * @param right defines the second operand
  8870. * @returns the current updated Color4 object
  8871. */
  8872. addInPlace(right: Color4): Color4;
  8873. /**
  8874. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  8875. * @returns the new array
  8876. */
  8877. asArray(): number[];
  8878. /**
  8879. * Stores from the starting index in the passed array the Color4 successive values
  8880. * @param array defines the array where to store the r,g,b components
  8881. * @param index defines an optional index in the target array to define where to start storing values
  8882. * @returns the current Color4 object
  8883. */
  8884. toArray(array: number[], index?: number): Color4;
  8885. /**
  8886. * Creates a new Color4 set with the added values of the current Color4 and of the passed one
  8887. * @param right defines the second operand
  8888. * @returns a new Color4 object
  8889. */
  8890. add(right: Color4): Color4;
  8891. /**
  8892. * Creates a new Color4 set with the subtracted values of the passed one from the current Color4
  8893. * @param right defines the second operand
  8894. * @returns a new Color4 object
  8895. */
  8896. subtract(right: Color4): Color4;
  8897. /**
  8898. * Subtracts the passed ones from the current Color4 values and stores the results in "result"
  8899. * @param right defines the second operand
  8900. * @param result defines the Color4 object where to store the result
  8901. * @returns the current Color4 object
  8902. */
  8903. subtractToRef(right: Color4, result: Color4): Color4;
  8904. /**
  8905. * Creates a new Color4 with the current Color4 values multiplied by scale
  8906. * @param scale defines the scaling factor to apply
  8907. * @returns a new Color4 object
  8908. */
  8909. scale(scale: number): Color4;
  8910. /**
  8911. * Multiplies the current Color4 values by scale and stores the result in "result"
  8912. * @param scale defines the scaling factor to apply
  8913. * @param result defines the Color4 object where to store the result
  8914. * @returns the current unmodified Color4
  8915. */
  8916. scaleToRef(scale: number, result: Color4): Color4;
  8917. /**
  8918. * Scale the current Color4 values by a factor and add the result to a given Color4
  8919. * @param scale defines the scale factor
  8920. * @param result defines the Color4 object where to store the result
  8921. * @returns the unmodified current Color4
  8922. */
  8923. scaleAndAddToRef(scale: number, result: Color4): Color4;
  8924. /**
  8925. * Clamps the rgb values by the min and max values and stores the result into "result"
  8926. * @param min defines minimum clamping value (default is 0)
  8927. * @param max defines maximum clamping value (default is 1)
  8928. * @param result defines color to store the result into.
  8929. * @returns the cuurent Color4
  8930. */
  8931. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  8932. /**
  8933. * Multipy an Color4 value by another and return a new Color4 object
  8934. * @param color defines the Color4 value to multiply by
  8935. * @returns a new Color4 object
  8936. */
  8937. multiply(color: Color4): Color4;
  8938. /**
  8939. * Multipy a Color4 value by another and push the result in a reference value
  8940. * @param color defines the Color4 value to multiply by
  8941. * @param result defines the Color4 to fill the result in
  8942. * @returns the result Color4
  8943. */
  8944. multiplyToRef(color: Color4, result: Color4): Color4;
  8945. /**
  8946. * Creates a string with the Color4 current values
  8947. * @returns the string representation of the Color4 object
  8948. */
  8949. toString(): string;
  8950. /**
  8951. * Returns the string "Color4"
  8952. * @returns "Color4"
  8953. */
  8954. getClassName(): string;
  8955. /**
  8956. * Compute the Color4 hash code
  8957. * @returns an unique number that can be used to hash Color4 objects
  8958. */
  8959. getHashCode(): number;
  8960. /**
  8961. * Creates a new Color4 copied from the current one
  8962. * @returns a new Color4 object
  8963. */
  8964. clone(): Color4;
  8965. /**
  8966. * Copies the passed Color4 values into the current one
  8967. * @param source defines the source Color4 object
  8968. * @returns the current updated Color4 object
  8969. */
  8970. copyFrom(source: Color4): Color4;
  8971. /**
  8972. * Copies the passed float values into the current one
  8973. * @param r defines the red component to read from
  8974. * @param g defines the green component to read from
  8975. * @param b defines the blue component to read from
  8976. * @param a defines the alpha component to read from
  8977. * @returns the current updated Color4 object
  8978. */
  8979. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  8980. /**
  8981. * Copies the passed float values into the current one
  8982. * @param r defines the red component to read from
  8983. * @param g defines the green component to read from
  8984. * @param b defines the blue component to read from
  8985. * @param a defines the alpha component to read from
  8986. * @returns the current updated Color4 object
  8987. */
  8988. set(r: number, g: number, b: number, a: number): Color4;
  8989. /**
  8990. * Compute the Color4 hexadecimal code as a string
  8991. * @returns a string containing the hexadecimal representation of the Color4 object
  8992. */
  8993. toHexString(): string;
  8994. /**
  8995. * Computes a new Color4 converted from the current one to linear space
  8996. * @returns a new Color4 object
  8997. */
  8998. toLinearSpace(): Color4;
  8999. /**
  9000. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  9001. * @param convertedColor defines the Color4 object where to store the linear space version
  9002. * @returns the unmodified Color4
  9003. */
  9004. toLinearSpaceToRef(convertedColor: Color4): Color4;
  9005. /**
  9006. * Computes a new Color4 converted from the current one to gamma space
  9007. * @returns a new Color4 object
  9008. */
  9009. toGammaSpace(): Color4;
  9010. /**
  9011. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  9012. * @param convertedColor defines the Color4 object where to store the gamma space version
  9013. * @returns the unmodified Color4
  9014. */
  9015. toGammaSpaceToRef(convertedColor: Color4): Color4;
  9016. /**
  9017. * Creates a new Color4 from the string containing valid hexadecimal values
  9018. * @param hex defines a string containing valid hexadecimal values
  9019. * @returns a new Color4 object
  9020. */
  9021. static FromHexString(hex: string): Color4;
  9022. /**
  9023. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  9024. * @param left defines the start value
  9025. * @param right defines the end value
  9026. * @param amount defines the gradient factor
  9027. * @returns a new Color4 object
  9028. */
  9029. static Lerp(left: Color4, right: Color4, amount: number): Color4;
  9030. /**
  9031. * Set the passed "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  9032. * @param left defines the start value
  9033. * @param right defines the end value
  9034. * @param amount defines the gradient factor
  9035. * @param result defines the Color4 object where to store data
  9036. */
  9037. static LerpToRef(left: Color4, right: Color4, amount: number, result: Color4): void;
  9038. /**
  9039. * Creates a new Color4 from the starting index element of the passed array
  9040. * @param array defines the source array to read from
  9041. * @param offset defines the offset in the source array
  9042. * @returns a new Color4 object
  9043. */
  9044. static FromArray(array: ArrayLike<number>, offset?: number): Color4;
  9045. /**
  9046. * Creates a new Color3 from integer values (< 256)
  9047. * @param r defines the red component to read from (value between 0 and 255)
  9048. * @param g defines the green component to read from (value between 0 and 255)
  9049. * @param b defines the blue component to read from (value between 0 and 255)
  9050. * @param a defines the alpha component to read from (value between 0 and 255)
  9051. * @returns a new Color3 object
  9052. */
  9053. static FromInts(r: number, g: number, b: number, a: number): Color4;
  9054. /**
  9055. * Check the content of a given array and convert it to an array containing RGBA data
  9056. * If the original array was already containing count * 4 values then it is returned directly
  9057. * @param colors defines the array to check
  9058. * @param count defines the number of RGBA data to expect
  9059. * @returns an array containing count * 4 values (RGBA)
  9060. */
  9061. static CheckColors4(colors: number[], count: number): number[];
  9062. }
  9063. class Vector2 {
  9064. x: number;
  9065. y: number;
  9066. /**
  9067. * Creates a new Vector2 from the passed x and y coordinates.
  9068. */
  9069. constructor(x: number, y: number);
  9070. /**
  9071. * Returns a string with the Vector2 coordinates.
  9072. */
  9073. toString(): string;
  9074. /**
  9075. * Returns the string "Vector2"
  9076. */
  9077. getClassName(): string;
  9078. /**
  9079. * Returns the Vector2 hash code as a number.
  9080. */
  9081. getHashCode(): number;
  9082. /**
  9083. * Sets the Vector2 coordinates in the passed array or Float32Array from the passed index.
  9084. * Returns the Vector2.
  9085. */
  9086. toArray(array: FloatArray, index?: number): Vector2;
  9087. /**
  9088. * Returns a new array with 2 elements : the Vector2 coordinates.
  9089. */
  9090. asArray(): number[];
  9091. /**
  9092. * Sets the Vector2 coordinates with the passed Vector2 coordinates.
  9093. * Returns the updated Vector2.
  9094. */
  9095. copyFrom(source: Vector2): Vector2;
  9096. /**
  9097. * Sets the Vector2 coordinates with the passed floats.
  9098. * Returns the updated Vector2.
  9099. */
  9100. copyFromFloats(x: number, y: number): Vector2;
  9101. /**
  9102. * Sets the Vector2 coordinates with the passed floats.
  9103. * Returns the updated Vector2.
  9104. */
  9105. set(x: number, y: number): Vector2;
  9106. /**
  9107. * Returns a new Vector2 set with the addition of the current Vector2 and the passed one coordinates.
  9108. */
  9109. add(otherVector: Vector2): Vector2;
  9110. /**
  9111. * Sets the "result" coordinates with the addition of the current Vector2 and the passed one coordinates.
  9112. * Returns the Vector2.
  9113. */
  9114. addToRef(otherVector: Vector2, result: Vector2): Vector2;
  9115. /**
  9116. * Set the Vector2 coordinates by adding the passed Vector2 coordinates.
  9117. * Returns the updated Vector2.
  9118. */
  9119. addInPlace(otherVector: Vector2): Vector2;
  9120. /**
  9121. * Returns a new Vector2 by adding the current Vector2 coordinates to the passed Vector3 x, y coordinates.
  9122. */
  9123. addVector3(otherVector: Vector3): Vector2;
  9124. /**
  9125. * Returns a new Vector2 set with the subtracted coordinates of the passed one from the current Vector2.
  9126. */
  9127. subtract(otherVector: Vector2): Vector2;
  9128. /**
  9129. * Sets the "result" coordinates with the subtraction of the passed one from the current Vector2 coordinates.
  9130. * Returns the Vector2.
  9131. */
  9132. subtractToRef(otherVector: Vector2, result: Vector2): Vector2;
  9133. /**
  9134. * Sets the current Vector2 coordinates by subtracting from it the passed one coordinates.
  9135. * Returns the updated Vector2.
  9136. */
  9137. subtractInPlace(otherVector: Vector2): Vector2;
  9138. /**
  9139. * Multiplies in place the current Vector2 coordinates by the passed ones.
  9140. * Returns the updated Vector2.
  9141. */
  9142. multiplyInPlace(otherVector: Vector2): Vector2;
  9143. /**
  9144. * Returns a new Vector2 set with the multiplication of the current Vector2 and the passed one coordinates.
  9145. */
  9146. multiply(otherVector: Vector2): Vector2;
  9147. /**
  9148. * Sets "result" coordinates with the multiplication of the current Vector2 and the passed one coordinates.
  9149. * Returns the Vector2.
  9150. */
  9151. multiplyToRef(otherVector: Vector2, result: Vector2): Vector2;
  9152. /**
  9153. * Returns a new Vector2 set with the Vector2 coordinates multiplied by the passed floats.
  9154. */
  9155. multiplyByFloats(x: number, y: number): Vector2;
  9156. /**
  9157. * Returns a new Vector2 set with the Vector2 coordinates divided by the passed one coordinates.
  9158. */
  9159. divide(otherVector: Vector2): Vector2;
  9160. /**
  9161. * Sets the "result" coordinates with the Vector2 divided by the passed one coordinates.
  9162. * Returns the Vector2.
  9163. */
  9164. divideToRef(otherVector: Vector2, result: Vector2): Vector2;
  9165. /**
  9166. * Divides the current Vector3 coordinates by the passed ones.
  9167. * Returns the updated Vector3.
  9168. */
  9169. divideInPlace(otherVector: Vector2): Vector2;
  9170. /**
  9171. * Returns a new Vector2 with current Vector2 negated coordinates.
  9172. */
  9173. negate(): Vector2;
  9174. /**
  9175. * Multiply the Vector2 coordinates by scale.
  9176. * Returns the updated Vector2.
  9177. */
  9178. scaleInPlace(scale: number): Vector2;
  9179. /**
  9180. * Returns a new Vector2 scaled by "scale" from the current Vector2.
  9181. */
  9182. scale(scale: number): Vector2;
  9183. /**
  9184. * Scale the current Vector2 values by a factor to a given Vector2
  9185. * @param scale defines the scale factor
  9186. * @param result defines the Vector2 object where to store the result
  9187. * @returns the unmodified current Vector2
  9188. */
  9189. scaleToRef(scale: number, result: Vector2): Vector2;
  9190. /**
  9191. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  9192. * @param scale defines the scale factor
  9193. * @param result defines the Vector2 object where to store the result
  9194. * @returns the unmodified current Vector2
  9195. */
  9196. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  9197. /**
  9198. * Boolean : True if the passed vector coordinates strictly equal the current Vector2 ones.
  9199. */
  9200. equals(otherVector: Vector2): boolean;
  9201. /**
  9202. * Boolean : True if the passed vector coordinates are close to the current ones by a distance of epsilon.
  9203. */
  9204. equalsWithEpsilon(otherVector: Vector2, epsilon?: number): boolean;
  9205. /**
  9206. * Returns the vector length (float).
  9207. */
  9208. length(): number;
  9209. /**
  9210. * Returns the vector squared length (float);
  9211. */
  9212. lengthSquared(): number;
  9213. /**
  9214. * Normalize the vector.
  9215. * Returns the updated Vector2.
  9216. */
  9217. normalize(): Vector2;
  9218. /**
  9219. * Returns a new Vector2 copied from the Vector2.
  9220. */
  9221. clone(): Vector2;
  9222. /**
  9223. * Returns a new Vector2(0, 0)
  9224. */
  9225. static Zero(): Vector2;
  9226. /**
  9227. * Returns a new Vector2(1, 1)
  9228. */
  9229. static One(): Vector2;
  9230. /**
  9231. * Returns a new Vector2 set from the passed index element of the passed array.
  9232. */
  9233. static FromArray(array: ArrayLike<number>, offset?: number): Vector2;
  9234. /**
  9235. * Sets "result" from the passed index element of the passed array.
  9236. */
  9237. static FromArrayToRef(array: ArrayLike<number>, offset: number, result: Vector2): void;
  9238. /**
  9239. * Retuns a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the passed four Vector2.
  9240. */
  9241. static CatmullRom(value1: Vector2, value2: Vector2, value3: Vector2, value4: Vector2, amount: number): Vector2;
  9242. /**
  9243. * 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".
  9244. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  9245. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate.
  9246. */
  9247. static Clamp(value: Vector2, min: Vector2, max: Vector2): Vector2;
  9248. /**
  9249. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2".
  9250. */
  9251. static Hermite(value1: Vector2, tangent1: Vector2, value2: Vector2, tangent2: Vector2, amount: number): Vector2;
  9252. /**
  9253. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  9254. */
  9255. static Lerp(start: Vector2, end: Vector2, amount: number): Vector2;
  9256. /**
  9257. * Returns the dot product (float) of the vector "left" and the vector "right".
  9258. */
  9259. static Dot(left: Vector2, right: Vector2): number;
  9260. /**
  9261. * Returns a new Vector2 equal to the normalized passed vector.
  9262. */
  9263. static Normalize(vector: Vector2): Vector2;
  9264. /**
  9265. * Returns a new Vecto2 set with the minimal coordinate values from the "left" and "right" vectors.
  9266. */
  9267. static Minimize(left: Vector2, right: Vector2): Vector2;
  9268. /**
  9269. * Returns a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors.
  9270. */
  9271. static Maximize(left: Vector2, right: Vector2): Vector2;
  9272. /**
  9273. * Returns a new Vecto2 set with the transformed coordinates of the passed vector by the passed transformation matrix.
  9274. */
  9275. static Transform(vector: Vector2, transformation: Matrix): Vector2;
  9276. /**
  9277. * Transforms the passed vector coordinates by the passed transformation matrix and stores the result in the vector "result" coordinates.
  9278. */
  9279. static TransformToRef(vector: Vector2, transformation: Matrix, result: Vector2): void;
  9280. /**
  9281. * Boolean : True if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  9282. */
  9283. static PointInTriangle(p: Vector2, p0: Vector2, p1: Vector2, p2: Vector2): boolean;
  9284. /**
  9285. * Returns the distance (float) between the vectors "value1" and "value2".
  9286. */
  9287. static Distance(value1: Vector2, value2: Vector2): number;
  9288. /**
  9289. * Returns the squared distance (float) between the vectors "value1" and "value2".
  9290. */
  9291. static DistanceSquared(value1: Vector2, value2: Vector2): number;
  9292. /**
  9293. * Returns a new Vecto2 located at the center of the vectors "value1" and "value2".
  9294. */
  9295. static Center(value1: Vector2, value2: Vector2): Vector2;
  9296. /**
  9297. * Returns the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  9298. */
  9299. static DistanceOfPointFromSegment(p: Vector2, segA: Vector2, segB: Vector2): number;
  9300. }
  9301. /**
  9302. * Classed used to store (x,y,z) vector representation
  9303. * A Vector3 is the main object used in 3D geometry
  9304. * It can represent etiher the coordinates of a point the space, either a direction
  9305. * Reminder: Babylon.js uses a left handed forward facing system
  9306. */
  9307. class Vector3 {
  9308. /**
  9309. * Defines the first coordinates (on X axis)
  9310. */
  9311. x: number;
  9312. /**
  9313. * Defines the second coordinates (on Y axis)
  9314. */
  9315. y: number;
  9316. /**
  9317. * Defines the third coordinates (on Z axis)
  9318. */
  9319. z: number;
  9320. /**
  9321. * Creates a new Vector3 object from the passed x, y, z (floats) coordinates.
  9322. * @param x defines the first coordinates (on X axis)
  9323. * @param y defines the second coordinates (on Y axis)
  9324. * @param z defines the third coordinates (on Z axis)
  9325. */
  9326. constructor(
  9327. /**
  9328. * Defines the first coordinates (on X axis)
  9329. */
  9330. x: number,
  9331. /**
  9332. * Defines the second coordinates (on Y axis)
  9333. */
  9334. y: number,
  9335. /**
  9336. * Defines the third coordinates (on Z axis)
  9337. */
  9338. z: number);
  9339. /**
  9340. * Creates a string representation of the Vector3
  9341. * @returns a string with the Vector3 coordinates.
  9342. */
  9343. toString(): string;
  9344. /**
  9345. * Gets the class name
  9346. * @returns the string "Vector3"
  9347. */
  9348. getClassName(): string;
  9349. /**
  9350. * Creates the Vector3 hash code
  9351. * @returns a number which tends to be unique between Vector3 instances
  9352. */
  9353. getHashCode(): number;
  9354. /**
  9355. * Creates an array containing three elements : the coordinates of the Vector3
  9356. * @returns a new array of numbers
  9357. */
  9358. asArray(): number[];
  9359. /**
  9360. * Populates the passed array or Float32Array from the passed index with the successive coordinates of the Vector3
  9361. * @param array defines the destination array
  9362. * @param index defines the offset in the destination array
  9363. * @returns the current Vector3
  9364. */
  9365. toArray(array: FloatArray, index?: number): Vector3;
  9366. /**
  9367. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  9368. * @returns a new Quaternion object, computed from the Vector3 coordinates
  9369. */
  9370. toQuaternion(): Quaternion;
  9371. /**
  9372. * Adds the passed vector to the current Vector3
  9373. * @param otherVector defines the second operand
  9374. * @returns the current updated Vector3
  9375. */
  9376. addInPlace(otherVector: Vector3): Vector3;
  9377. /**
  9378. * Gets a new Vector3, result of the addition the current Vector3 and the passed vector
  9379. * @param otherVector defines the second operand
  9380. * @returns the resulting Vector3
  9381. */
  9382. add(otherVector: Vector3): Vector3;
  9383. /**
  9384. * Adds the current Vector3 to the passed one and stores the result in the vector "result"
  9385. * @param otherVector defines the second operand
  9386. * @param result defines the Vector3 object where to store the result
  9387. * @returns the current Vector3
  9388. */
  9389. addToRef(otherVector: Vector3, result: Vector3): Vector3;
  9390. /**
  9391. * Subtract the passed vector from the current Vector3
  9392. * @param otherVector defines the second operand
  9393. * @returns the current updated Vector3
  9394. */
  9395. subtractInPlace(otherVector: Vector3): Vector3;
  9396. /**
  9397. * Returns a new Vector3, result of the subtraction of the passed vector from the current Vector3
  9398. * @param otherVector defines the second operand
  9399. * @returns the resulting Vector3
  9400. */
  9401. subtract(otherVector: Vector3): Vector3;
  9402. /**
  9403. * Subtracts the passed vector from the current Vector3 and stores the result in the vector "result".
  9404. * @param otherVector defines the second operand
  9405. * @param result defines the Vector3 object where to store the result
  9406. * @returns the current Vector3
  9407. */
  9408. subtractToRef(otherVector: Vector3, result: Vector3): Vector3;
  9409. /**
  9410. * Returns a new Vector3 set with the subtraction of the passed floats from the current Vector3 coordinates
  9411. * @param x defines the x coordinate of the operand
  9412. * @param y defines the y coordinate of the operand
  9413. * @param z defines the z coordinate of the operand
  9414. * @returns the resulting Vector3
  9415. */
  9416. subtractFromFloats(x: number, y: number, z: number): Vector3;
  9417. /**
  9418. * Subtracts the passed floats from the current Vector3 coordinates and set the passed vector "result" with this result
  9419. * @param x defines the x coordinate of the operand
  9420. * @param y defines the y coordinate of the operand
  9421. * @param z defines the z coordinate of the operand
  9422. * @param result defines the Vector3 object where to store the result
  9423. * @returns the current Vector3
  9424. */
  9425. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  9426. /**
  9427. * Gets a new Vector3 set with the current Vector3 negated coordinates
  9428. * @returns a new Vector3
  9429. */
  9430. negate(): Vector3;
  9431. /**
  9432. * Multiplies the Vector3 coordinates by the float "scale"
  9433. * @param scale defines the multiplier factor
  9434. * @returns the current updated Vector3
  9435. */
  9436. scaleInPlace(scale: number): Vector3;
  9437. /**
  9438. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  9439. * @param scale defines the multiplier factor
  9440. * @returns a new Vector3
  9441. */
  9442. scale(scale: number): Vector3;
  9443. /**
  9444. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the passed vector "result" coordinates
  9445. * @param scale defines the multiplier factor
  9446. * @param result defines the Vector3 object where to store the result
  9447. * @returns the current Vector3
  9448. */
  9449. scaleToRef(scale: number, result: Vector3): Vector3;
  9450. /**
  9451. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  9452. * @param scale defines the scale factor
  9453. * @param result defines the Vector3 object where to store the result
  9454. * @returns the unmodified current Vector3
  9455. */
  9456. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  9457. /**
  9458. * Returns true if the current Vector3 and the passed vector coordinates are strictly equal
  9459. * @param otherVector defines the second operand
  9460. * @returns true if both vectors are equals
  9461. */
  9462. equals(otherVector: Vector3): boolean;
  9463. /**
  9464. * Returns true if the current Vector3 and the passed vector coordinates are distant less than epsilon
  9465. * @param otherVector defines the second operand
  9466. * @param epsilon defines the minimal distance to define values as equals
  9467. * @returns true if both vectors are distant less than epsilon
  9468. */
  9469. equalsWithEpsilon(otherVector: Vector3, epsilon?: number): boolean;
  9470. /**
  9471. * Returns true if the current Vector3 coordinates equals the passed floats
  9472. * @param x defines the x coordinate of the operand
  9473. * @param y defines the y coordinate of the operand
  9474. * @param z defines the z coordinate of the operand
  9475. * @returns true if both vectors are equals
  9476. */
  9477. equalsToFloats(x: number, y: number, z: number): boolean;
  9478. /**
  9479. * Multiplies the current Vector3 coordinates by the passed ones
  9480. * @param otherVector defines the second operand
  9481. * @returns the current updated Vector3
  9482. */
  9483. multiplyInPlace(otherVector: Vector3): Vector3;
  9484. /**
  9485. * Returns a new Vector3, result of the multiplication of the current Vector3 by the passed vector
  9486. * @param otherVector defines the second operand
  9487. * @returns the new Vector3
  9488. */
  9489. multiply(otherVector: Vector3): Vector3;
  9490. /**
  9491. * Multiplies the current Vector3 by the passed one and stores the result in the passed vector "result"
  9492. * @param otherVector defines the second operand
  9493. * @param result defines the Vector3 object where to store the result
  9494. * @returns the current Vector3
  9495. */
  9496. multiplyToRef(otherVector: Vector3, result: Vector3): Vector3;
  9497. /**
  9498. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the passed floats
  9499. * @param x defines the x coordinate of the operand
  9500. * @param y defines the y coordinate of the operand
  9501. * @param z defines the z coordinate of the operand
  9502. * @returns the new Vector3
  9503. */
  9504. multiplyByFloats(x: number, y: number, z: number): Vector3;
  9505. /**
  9506. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the passed ones
  9507. * @param otherVector defines the second operand
  9508. * @returns the new Vector3
  9509. */
  9510. divide(otherVector: Vector3): Vector3;
  9511. /**
  9512. * Divides the current Vector3 coordinates by the passed ones and stores the result in the passed vector "result"
  9513. * @param otherVector defines the second operand
  9514. * @param result defines the Vector3 object where to store the result
  9515. * @returns the current Vector3
  9516. */
  9517. divideToRef(otherVector: Vector3, result: Vector3): Vector3;
  9518. /**
  9519. * Divides the current Vector3 coordinates by the passed ones.
  9520. * @param otherVector defines the second operand
  9521. * @returns the current updated Vector3
  9522. */
  9523. divideInPlace(otherVector: Vector3): Vector3;
  9524. /**
  9525. * Updates the current Vector3 with the minimal coordinate values between its and the passed vector ones
  9526. * @param other defines the second operand
  9527. * @returns the current updated Vector3
  9528. */
  9529. minimizeInPlace(other: Vector3): Vector3;
  9530. /**
  9531. * Updates the current Vector3 with the maximal coordinate values between its and the passed vector ones.
  9532. * @param other defines the second operand
  9533. * @returns the current updated Vector3
  9534. */
  9535. maximizeInPlace(other: Vector3): Vector3;
  9536. /**
  9537. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  9538. */
  9539. readonly isNonUniform: boolean;
  9540. /**
  9541. * Gets the length of the Vector3
  9542. * @returns the length of the Vecto3
  9543. */
  9544. length(): number;
  9545. /**
  9546. * Gets the squared length of the Vector3
  9547. * @returns squared length of the Vector3
  9548. */
  9549. lengthSquared(): number;
  9550. /**
  9551. * Normalize the current Vector3.
  9552. * Please note that this is an in place operation.
  9553. * @returns the current updated Vector3
  9554. */
  9555. normalize(): Vector3;
  9556. /**
  9557. * Normalize the current Vector3 to a new vector
  9558. * @returns the new Vector3
  9559. */
  9560. normalizeToNew(): Vector3;
  9561. /**
  9562. * Normalize the current Vector3 to the reference
  9563. * @param reference define the Vector3 to update
  9564. * @returns the updated Vector3
  9565. */
  9566. normalizeToRef(reference: Vector3): Vector3;
  9567. /**
  9568. * Creates a new Vector3 copied from the current Vector3
  9569. * @returns the new Vector3
  9570. */
  9571. clone(): Vector3;
  9572. /**
  9573. * Copies the passed vector coordinates to the current Vector3 ones
  9574. * @param source defines the source Vector3
  9575. * @returns the current updated Vector3
  9576. */
  9577. copyFrom(source: Vector3): Vector3;
  9578. /**
  9579. * Copies the passed floats to the current Vector3 coordinates
  9580. * @param x defines the x coordinate of the operand
  9581. * @param y defines the y coordinate of the operand
  9582. * @param z defines the z coordinate of the operand
  9583. * @returns the current updated Vector3
  9584. */
  9585. copyFromFloats(x: number, y: number, z: number): Vector3;
  9586. /**
  9587. * Copies the passed floats to the current Vector3 coordinates
  9588. * @param x defines the x coordinate of the operand
  9589. * @param y defines the y coordinate of the operand
  9590. * @param z defines the z coordinate of the operand
  9591. * @returns the current updated Vector3
  9592. */
  9593. set(x: number, y: number, z: number): Vector3;
  9594. /**
  9595. * Get the clip factor between two vectors
  9596. * @param vector0 defines the first operand
  9597. * @param vector1 defines the second operand
  9598. * @param axis defines the axis to use
  9599. * @param size defines the size along the axis
  9600. * @returns the clip factor
  9601. */
  9602. static GetClipFactor(vector0: Vector3, vector1: Vector3, axis: Vector3, size: number): number;
  9603. /**
  9604. * Get angle between two vectors
  9605. * @param vector0 angle between vector0 and vector1
  9606. * @param vector1 angle between vector0 and vector1
  9607. * @param normal direction of the normal
  9608. * @return the angle between vector0 and vector1
  9609. */
  9610. static GetAngleBetweenVectors(vector0: Vector3, vector1: Vector3, normal: Vector3): number;
  9611. /**
  9612. * Returns a new Vector3 set from the index "offset" of the passed array
  9613. * @param array defines the source array
  9614. * @param offset defines the offset in the source array
  9615. * @returns the new Vector3
  9616. */
  9617. static FromArray(array: ArrayLike<number>, offset?: number): Vector3;
  9618. /**
  9619. * Returns a new Vector3 set from the index "offset" of the passed Float32Array
  9620. * This function is deprecated. Use FromArray instead
  9621. * @param array defines the source array
  9622. * @param offset defines the offset in the source array
  9623. * @returns the new Vector3
  9624. */
  9625. static FromFloatArray(array: Float32Array, offset?: number): Vector3;
  9626. /**
  9627. * Sets the passed vector "result" with the element values from the index "offset" of the passed array
  9628. * @param array defines the source array
  9629. * @param offset defines the offset in the source array
  9630. * @param result defines the Vector3 where to store the result
  9631. */
  9632. static FromArrayToRef(array: ArrayLike<number>, offset: number, result: Vector3): void;
  9633. /**
  9634. * Sets the passed vector "result" with the element values from the index "offset" of the passed Float32Array
  9635. * This function is deprecated. Use FromArrayToRef instead.
  9636. * @param array defines the source array
  9637. * @param offset defines the offset in the source array
  9638. * @param result defines the Vector3 where to store the result
  9639. */
  9640. static FromFloatArrayToRef(array: Float32Array, offset: number, result: Vector3): void;
  9641. /**
  9642. * Sets the passed vector "result" with the passed floats.
  9643. * @param x defines the x coordinate of the source
  9644. * @param y defines the y coordinate of the source
  9645. * @param z defines the z coordinate of the source
  9646. * @param result defines the Vector3 where to store the result
  9647. */
  9648. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  9649. /**
  9650. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  9651. * @returns a new empty Vector3
  9652. */
  9653. static Zero(): Vector3;
  9654. /**
  9655. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  9656. * @returns a new unit Vector3
  9657. */
  9658. static One(): Vector3;
  9659. /**
  9660. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  9661. * @returns a new up Vector3
  9662. */
  9663. static Up(): Vector3;
  9664. /**
  9665. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  9666. * @returns a new forward Vector3
  9667. */
  9668. static Forward(): Vector3;
  9669. /**
  9670. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  9671. * @returns a new right Vector3
  9672. */
  9673. static Right(): Vector3;
  9674. /**
  9675. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  9676. * @returns a new left Vector3
  9677. */
  9678. static Left(): Vector3;
  9679. /**
  9680. * Returns a new Vector3 set with the result of the transformation by the passed matrix of the passed vector.
  9681. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  9682. * @param vector defines the Vector3 to transform
  9683. * @param transformation defines the transformation matrix
  9684. * @returns the transformed Vector3
  9685. */
  9686. static TransformCoordinates(vector: Vector3, transformation: Matrix): Vector3;
  9687. /**
  9688. * Sets the passed vector "result" coordinates with the result of the transformation by the passed matrix of the passed vector
  9689. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  9690. * @param vector defines the Vector3 to transform
  9691. * @param transformation defines the transformation matrix
  9692. * @param result defines the Vector3 where to store the result
  9693. */
  9694. static TransformCoordinatesToRef(vector: Vector3, transformation: Matrix, result: Vector3): void;
  9695. /**
  9696. * Sets the passed vector "result" coordinates with the result of the transformation by the passed matrix of the passed floats (x, y, z)
  9697. * This method computes tranformed coordinates only, not transformed direction vectors
  9698. * @param x define the x coordinate of the source vector
  9699. * @param y define the y coordinate of the source vector
  9700. * @param z define the z coordinate of the source vector
  9701. * @param transformation defines the transformation matrix
  9702. * @param result defines the Vector3 where to store the result
  9703. */
  9704. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: Matrix, result: Vector3): void;
  9705. /**
  9706. * Returns a new Vector3 set with the result of the normal transformation by the passed matrix of the passed vector
  9707. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  9708. * @param vector defines the Vector3 to transform
  9709. * @param transformation defines the transformation matrix
  9710. * @returns the new Vector3
  9711. */
  9712. static TransformNormal(vector: Vector3, transformation: Matrix): Vector3;
  9713. /**
  9714. * Sets the passed vector "result" with the result of the normal transformation by the passed matrix of the passed vector
  9715. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  9716. * @param vector defines the Vector3 to transform
  9717. * @param transformation defines the transformation matrix
  9718. * @param result defines the Vector3 where to store the result
  9719. */
  9720. static TransformNormalToRef(vector: Vector3, transformation: Matrix, result: Vector3): void;
  9721. /**
  9722. * Sets the passed vector "result" with the result of the normal transformation by the passed matrix of the passed floats (x, y, z)
  9723. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  9724. * @param x define the x coordinate of the source vector
  9725. * @param y define the y coordinate of the source vector
  9726. * @param z define the z coordinate of the source vector
  9727. * @param transformation defines the transformation matrix
  9728. * @param result defines the Vector3 where to store the result
  9729. */
  9730. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: Matrix, result: Vector3): void;
  9731. /**
  9732. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  9733. * @param value1 defines the first control point
  9734. * @param value2 defines the second control point
  9735. * @param value3 defines the third control point
  9736. * @param value4 defines the fourth control point
  9737. * @param amount defines the amount on the spline to use
  9738. * @returns the new Vector3
  9739. */
  9740. static CatmullRom(value1: Vector3, value2: Vector3, value3: Vector3, value4: Vector3, amount: number): Vector3;
  9741. /**
  9742. * 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"
  9743. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  9744. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  9745. * @param value defines the current value
  9746. * @param min defines the lower range value
  9747. * @param max defines the upper range value
  9748. * @returns the new Vector3
  9749. */
  9750. static Clamp(value: Vector3, min: Vector3, max: Vector3): Vector3;
  9751. /**
  9752. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  9753. * @param value1 defines the first control point
  9754. * @param tangent1 defines the first tangent vector
  9755. * @param value2 defines the second control point
  9756. * @param tangent2 defines the second tangent vector
  9757. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  9758. * @returns the new Vector3
  9759. */
  9760. static Hermite(value1: Vector3, tangent1: Vector3, value2: Vector3, tangent2: Vector3, amount: number): Vector3;
  9761. /**
  9762. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  9763. * @param start defines the start value
  9764. * @param end defines the end value
  9765. * @param amount max defines amount between both (between 0 and 1)
  9766. * @returns the new Vector3
  9767. */
  9768. static Lerp(start: Vector3, end: Vector3, amount: number): Vector3;
  9769. /**
  9770. * Sets the passed vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  9771. * @param start defines the start value
  9772. * @param end defines the end value
  9773. * @param amount max defines amount between both (between 0 and 1)
  9774. * @param result defines the Vector3 where to store the result
  9775. */
  9776. static LerpToRef(start: Vector3, end: Vector3, amount: number, result: Vector3): void;
  9777. /**
  9778. * Returns the dot product (float) between the vectors "left" and "right"
  9779. * @param left defines the left operand
  9780. * @param right defines the right operand
  9781. * @returns the dot product
  9782. */
  9783. static Dot(left: Vector3, right: Vector3): number;
  9784. /**
  9785. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  9786. * The cross product is then orthogonal to both "left" and "right"
  9787. * @param left defines the left operand
  9788. * @param right defines the right operand
  9789. * @returns the cross product
  9790. */
  9791. static Cross(left: Vector3, right: Vector3): Vector3;
  9792. /**
  9793. * Sets the passed vector "result" with the cross product of "left" and "right"
  9794. * The cross product is then orthogonal to both "left" and "right"
  9795. * @param left defines the left operand
  9796. * @param right defines the right operand
  9797. * @param result defines the Vector3 where to store the result
  9798. */
  9799. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  9800. /**
  9801. * Returns a new Vector3 as the normalization of the passed vector
  9802. * @param vector defines the Vector3 to normalize
  9803. * @returns the new Vector3
  9804. */
  9805. static Normalize(vector: Vector3): Vector3;
  9806. /**
  9807. * Sets the passed vector "result" with the normalization of the passed first vector
  9808. * @param vector defines the Vector3 to normalize
  9809. * @param result defines the Vector3 where to store the result
  9810. */
  9811. static NormalizeToRef(vector: Vector3, result: Vector3): void;
  9812. private static _viewportMatrixCache;
  9813. /**
  9814. * Project a Vector3 onto screen space
  9815. * @param vector defines the Vector3 to project
  9816. * @param world defines the world matrix to use
  9817. * @param transform defines the transform (view x projection) matrix to use
  9818. * @param viewport defines the screen viewport to use
  9819. * @returns the new Vector3
  9820. */
  9821. static Project(vector: Vector3, world: Matrix, transform: Matrix, viewport: Viewport): Vector3;
  9822. /**
  9823. * Unproject from screen space to object space
  9824. * @param source defines the screen space Vector3 to use
  9825. * @param viewportWidth defines the current width of the viewport
  9826. * @param viewportHeight defines the current height of the viewport
  9827. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  9828. * @param transform defines the transform (view x projection) matrix to use
  9829. * @returns the new Vector3
  9830. */
  9831. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: Matrix, transform: Matrix): Vector3;
  9832. /**
  9833. * Unproject from screen space to object space
  9834. * @param source defines the screen space Vector3 to use
  9835. * @param viewportWidth defines the current width of the viewport
  9836. * @param viewportHeight defines the current height of the viewport
  9837. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  9838. * @param view defines the view matrix to use
  9839. * @param projection defines the projection matrix to use
  9840. * @returns the new Vector3
  9841. */
  9842. static Unproject(source: Vector3, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix): Vector3;
  9843. /**
  9844. * Unproject from screen space to object space
  9845. * @param source defines the screen space Vector3 to use
  9846. * @param viewportWidth defines the current width of the viewport
  9847. * @param viewportHeight defines the current height of the viewport
  9848. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  9849. * @param view defines the view matrix to use
  9850. * @param projection defines the projection matrix to use
  9851. * @param result defines the Vector3 where to store the result
  9852. */
  9853. static UnprojectToRef(source: Vector3, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix, result: Vector3): void;
  9854. /**
  9855. * Unproject from screen space to object space
  9856. * @param sourceX defines the screen space x coordinate to use
  9857. * @param sourceY defines the screen space y coordinate to use
  9858. * @param sourceZ defines the screen space z coordinate to use
  9859. * @param viewportWidth defines the current width of the viewport
  9860. * @param viewportHeight defines the current height of the viewport
  9861. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  9862. * @param view defines the view matrix to use
  9863. * @param projection defines the projection matrix to use
  9864. * @param result defines the Vector3 where to store the result
  9865. */
  9866. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix, result: Vector3): void;
  9867. /**
  9868. * Gets the minimal coordinate values between two Vector3
  9869. * @param left defines the first operand
  9870. * @param right defines the second operand
  9871. * @returns the new Vector3
  9872. */
  9873. static Minimize(left: Vector3, right: Vector3): Vector3;
  9874. /**
  9875. * Gets the maximal coordinate values between two Vector3
  9876. * @param left defines the first operand
  9877. * @param right defines the second operand
  9878. * @returns the new Vector3
  9879. */
  9880. static Maximize(left: Vector3, right: Vector3): Vector3;
  9881. /**
  9882. * Returns the distance between the vectors "value1" and "value2"
  9883. * @param value1 defines the first operand
  9884. * @param value2 defines the second operand
  9885. * @returns the distance
  9886. */
  9887. static Distance(value1: Vector3, value2: Vector3): number;
  9888. /**
  9889. * Returns the squared distance between the vectors "value1" and "value2"
  9890. * @param value1 defines the first operand
  9891. * @param value2 defines the second operand
  9892. * @returns the squared distance
  9893. */
  9894. static DistanceSquared(value1: Vector3, value2: Vector3): number;
  9895. /**
  9896. * Returns a new Vector3 located at the center between "value1" and "value2"
  9897. * @param value1 defines the first operand
  9898. * @param value2 defines the second operand
  9899. * @returns the new Vector3
  9900. */
  9901. static Center(value1: Vector3, value2: Vector3): Vector3;
  9902. /**
  9903. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  9904. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  9905. * to something in order to rotate it from its local system to the given target system
  9906. * Note: axis1, axis2 and axis3 are normalized during this operation
  9907. * @param axis1 defines the first axis
  9908. * @param axis2 defines the second axis
  9909. * @param axis3 defines the third axis
  9910. * @returns a new Vector3
  9911. */
  9912. static RotationFromAxis(axis1: Vector3, axis2: Vector3, axis3: Vector3): Vector3;
  9913. /**
  9914. * The same than RotationFromAxis but updates the passed ref Vector3 parameter instead of returning a new Vector3
  9915. * @param axis1 defines the first axis
  9916. * @param axis2 defines the second axis
  9917. * @param axis3 defines the third axis
  9918. * @param ref defines the Vector3 where to store the result
  9919. */
  9920. static RotationFromAxisToRef(axis1: Vector3, axis2: Vector3, axis3: Vector3, ref: Vector3): void;
  9921. }
  9922. class Vector4 {
  9923. x: number;
  9924. y: number;
  9925. z: number;
  9926. w: number;
  9927. /**
  9928. * Creates a Vector4 object from the passed floats.
  9929. */
  9930. constructor(x: number, y: number, z: number, w: number);
  9931. /**
  9932. * Returns the string with the Vector4 coordinates.
  9933. */
  9934. toString(): string;
  9935. /**
  9936. * Returns the string "Vector4".
  9937. */
  9938. getClassName(): string;
  9939. /**
  9940. * Returns the Vector4 hash code.
  9941. */
  9942. getHashCode(): number;
  9943. /**
  9944. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  9945. */
  9946. asArray(): number[];
  9947. /**
  9948. * Populates the passed array from the passed index with the Vector4 coordinates.
  9949. * Returns the Vector4.
  9950. */
  9951. toArray(array: FloatArray, index?: number): Vector4;
  9952. /**
  9953. * Adds the passed vector to the current Vector4.
  9954. * Returns the updated Vector4.
  9955. */
  9956. addInPlace(otherVector: Vector4): Vector4;
  9957. /**
  9958. * Returns a new Vector4 as the result of the addition of the current Vector4 and the passed one.
  9959. */
  9960. add(otherVector: Vector4): Vector4;
  9961. /**
  9962. * Updates the passed vector "result" with the result of the addition of the current Vector4 and the passed one.
  9963. * Returns the current Vector4.
  9964. */
  9965. addToRef(otherVector: Vector4, result: Vector4): Vector4;
  9966. /**
  9967. * Subtract in place the passed vector from the current Vector4.
  9968. * Returns the updated Vector4.
  9969. */
  9970. subtractInPlace(otherVector: Vector4): Vector4;
  9971. /**
  9972. * Returns a new Vector4 with the result of the subtraction of the passed vector from the current Vector4.
  9973. */
  9974. subtract(otherVector: Vector4): Vector4;
  9975. /**
  9976. * Sets the passed vector "result" with the result of the subtraction of the passed vector from the current Vector4.
  9977. * Returns the current Vector4.
  9978. */
  9979. subtractToRef(otherVector: Vector4, result: Vector4): Vector4;
  9980. /**
  9981. * Returns a new Vector4 set with the result of the subtraction of the passed floats from the current Vector4 coordinates.
  9982. */
  9983. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  9984. /**
  9985. * Sets the passed vector "result" set with the result of the subtraction of the passed floats from the current Vector4 coordinates.
  9986. * Returns the current Vector4.
  9987. */
  9988. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  9989. /**
  9990. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  9991. */
  9992. negate(): Vector4;
  9993. /**
  9994. * Multiplies the current Vector4 coordinates by scale (float).
  9995. * Returns the updated Vector4.
  9996. */
  9997. scaleInPlace(scale: number): Vector4;
  9998. /**
  9999. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  10000. */
  10001. scale(scale: number): Vector4;
  10002. /**
  10003. * Sets the passed vector "result" with the current Vector4 coordinates multiplied by scale (float).
  10004. * Returns the current Vector4.
  10005. */
  10006. scaleToRef(scale: number, result: Vector4): Vector4;
  10007. /**
  10008. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  10009. * @param scale defines the scale factor
  10010. * @param result defines the Vector4 object where to store the result
  10011. * @returns the unmodified current Vector4
  10012. */
  10013. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  10014. /**
  10015. * Boolean : True if the current Vector4 coordinates are stricly equal to the passed ones.
  10016. */
  10017. equals(otherVector: Vector4): boolean;
  10018. /**
  10019. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the passed vector ones.
  10020. */
  10021. equalsWithEpsilon(otherVector: Vector4, epsilon?: number): boolean;
  10022. /**
  10023. * Boolean : True if the passed floats are strictly equal to the current Vector4 coordinates.
  10024. */
  10025. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  10026. /**
  10027. * Multiplies in place the current Vector4 by the passed one.
  10028. * Returns the updated Vector4.
  10029. */
  10030. multiplyInPlace(otherVector: Vector4): Vector4;
  10031. /**
  10032. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the passed one.
  10033. */
  10034. multiply(otherVector: Vector4): Vector4;
  10035. /**
  10036. * Updates the passed vector "result" with the multiplication result of the current Vector4 and the passed one.
  10037. * Returns the current Vector4.
  10038. */
  10039. multiplyToRef(otherVector: Vector4, result: Vector4): Vector4;
  10040. /**
  10041. * Returns a new Vector4 set with the multiplication result of the passed floats and the current Vector4 coordinates.
  10042. */
  10043. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  10044. /**
  10045. * Returns a new Vector4 set with the division result of the current Vector4 by the passed one.
  10046. */
  10047. divide(otherVector: Vector4): Vector4;
  10048. /**
  10049. * Updates the passed vector "result" with the division result of the current Vector4 by the passed one.
  10050. * Returns the current Vector4.
  10051. */
  10052. divideToRef(otherVector: Vector4, result: Vector4): Vector4;
  10053. /**
  10054. * Divides the current Vector3 coordinates by the passed ones.
  10055. * @returns the updated Vector3.
  10056. */
  10057. divideInPlace(otherVector: Vector4): Vector4;
  10058. /**
  10059. * Updates the Vector4 coordinates with the minimum values between its own and the passed vector ones
  10060. * @param other defines the second operand
  10061. * @returns the current updated Vector4
  10062. */
  10063. minimizeInPlace(other: Vector4): Vector4;
  10064. /**
  10065. * Updates the Vector4 coordinates with the maximum values between its own and the passed vector ones
  10066. * @param other defines the second operand
  10067. * @returns the current updated Vector4
  10068. */
  10069. maximizeInPlace(other: Vector4): Vector4;
  10070. /**
  10071. * Returns the Vector4 length (float).
  10072. */
  10073. length(): number;
  10074. /**
  10075. * Returns the Vector4 squared length (float).
  10076. */
  10077. lengthSquared(): number;
  10078. /**
  10079. * Normalizes in place the Vector4.
  10080. * Returns the updated Vector4.
  10081. */
  10082. normalize(): Vector4;
  10083. /**
  10084. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  10085. */
  10086. toVector3(): Vector3;
  10087. /**
  10088. * Returns a new Vector4 copied from the current one.
  10089. */
  10090. clone(): Vector4;
  10091. /**
  10092. * Updates the current Vector4 with the passed one coordinates.
  10093. * Returns the updated Vector4.
  10094. */
  10095. copyFrom(source: Vector4): Vector4;
  10096. /**
  10097. * Updates the current Vector4 coordinates with the passed floats.
  10098. * Returns the updated Vector4.
  10099. */
  10100. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  10101. /**
  10102. * Updates the current Vector4 coordinates with the passed floats.
  10103. * Returns the updated Vector4.
  10104. */
  10105. set(x: number, y: number, z: number, w: number): Vector4;
  10106. /**
  10107. * Returns a new Vector4 set from the starting index of the passed array.
  10108. */
  10109. static FromArray(array: ArrayLike<number>, offset?: number): Vector4;
  10110. /**
  10111. * Updates the passed vector "result" from the starting index of the passed array.
  10112. */
  10113. static FromArrayToRef(array: ArrayLike<number>, offset: number, result: Vector4): void;
  10114. /**
  10115. * Updates the passed vector "result" from the starting index of the passed Float32Array.
  10116. */
  10117. static FromFloatArrayToRef(array: Float32Array, offset: number, result: Vector4): void;
  10118. /**
  10119. * Updates the passed vector "result" coordinates from the passed floats.
  10120. */
  10121. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  10122. /**
  10123. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  10124. */
  10125. static Zero(): Vector4;
  10126. /**
  10127. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  10128. */
  10129. static One(): Vector4;
  10130. /**
  10131. * Returns a new normalized Vector4 from the passed one.
  10132. */
  10133. static Normalize(vector: Vector4): Vector4;
  10134. /**
  10135. * Updates the passed vector "result" from the normalization of the passed one.
  10136. */
  10137. static NormalizeToRef(vector: Vector4, result: Vector4): void;
  10138. static Minimize(left: Vector4, right: Vector4): Vector4;
  10139. static Maximize(left: Vector4, right: Vector4): Vector4;
  10140. /**
  10141. * Returns the distance (float) between the vectors "value1" and "value2".
  10142. */
  10143. static Distance(value1: Vector4, value2: Vector4): number;
  10144. /**
  10145. * Returns the squared distance (float) between the vectors "value1" and "value2".
  10146. */
  10147. static DistanceSquared(value1: Vector4, value2: Vector4): number;
  10148. /**
  10149. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  10150. */
  10151. static Center(value1: Vector4, value2: Vector4): Vector4;
  10152. /**
  10153. * Returns a new Vector4 set with the result of the normal transformation by the passed matrix of the passed vector.
  10154. * This methods computes transformed normalized direction vectors only.
  10155. */
  10156. static TransformNormal(vector: Vector4, transformation: Matrix): Vector4;
  10157. /**
  10158. * Sets the passed vector "result" with the result of the normal transformation by the passed matrix of the passed vector.
  10159. * This methods computes transformed normalized direction vectors only.
  10160. */
  10161. static TransformNormalToRef(vector: Vector4, transformation: Matrix, result: Vector4): void;
  10162. /**
  10163. * Sets the passed vector "result" with the result of the normal transformation by the passed matrix of the passed floats (x, y, z, w).
  10164. * This methods computes transformed normalized direction vectors only.
  10165. */
  10166. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: Matrix, result: Vector4): void;
  10167. }
  10168. interface ISize {
  10169. width: number;
  10170. height: number;
  10171. }
  10172. class Size implements ISize {
  10173. width: number;
  10174. height: number;
  10175. /**
  10176. * Creates a Size object from the passed width and height (floats).
  10177. */
  10178. constructor(width: number, height: number);
  10179. toString(): string;
  10180. /**
  10181. * Returns the string "Size"
  10182. */
  10183. getClassName(): string;
  10184. /**
  10185. * Returns the Size hash code.
  10186. */
  10187. getHashCode(): number;
  10188. /**
  10189. * Updates the current size from the passed one.
  10190. * Returns the updated Size.
  10191. */
  10192. copyFrom(src: Size): void;
  10193. /**
  10194. * Updates in place the current Size from the passed floats.
  10195. * Returns the updated Size.
  10196. */
  10197. copyFromFloats(width: number, height: number): Size;
  10198. /**
  10199. * Updates in place the current Size from the passed floats.
  10200. * Returns the updated Size.
  10201. */
  10202. set(width: number, height: number): Size;
  10203. /**
  10204. * Returns a new Size set with the multiplication result of the current Size and the passed floats.
  10205. */
  10206. multiplyByFloats(w: number, h: number): Size;
  10207. /**
  10208. * Returns a new Size copied from the passed one.
  10209. */
  10210. clone(): Size;
  10211. /**
  10212. * Boolean : True if the current Size and the passed one width and height are strictly equal.
  10213. */
  10214. equals(other: Size): boolean;
  10215. /**
  10216. * Returns the surface of the Size : width * height (float).
  10217. */
  10218. readonly surface: number;
  10219. /**
  10220. * Returns a new Size set to (0.0, 0.0)
  10221. */
  10222. static Zero(): Size;
  10223. /**
  10224. * Returns a new Size set as the addition result of the current Size and the passed one.
  10225. */
  10226. add(otherSize: Size): Size;
  10227. /**
  10228. * Returns a new Size set as the subtraction result of the passed one from the current Size.
  10229. */
  10230. subtract(otherSize: Size): Size;
  10231. /**
  10232. * Returns a new Size set at the linear interpolation "amount" between "start" and "end".
  10233. */
  10234. static Lerp(start: Size, end: Size, amount: number): Size;
  10235. }
  10236. class Quaternion {
  10237. x: number;
  10238. y: number;
  10239. z: number;
  10240. w: number;
  10241. /**
  10242. * Creates a new Quaternion from the passed floats.
  10243. */
  10244. constructor(x?: number, y?: number, z?: number, w?: number);
  10245. /**
  10246. * Returns a string with the Quaternion coordinates.
  10247. */
  10248. toString(): string;
  10249. /**
  10250. * Returns the string "Quaternion".
  10251. */
  10252. getClassName(): string;
  10253. /**
  10254. * Returns the Quaternion hash code.
  10255. */
  10256. getHashCode(): number;
  10257. /**
  10258. * Returns a new array populated with 4 elements : the Quaternion coordinates.
  10259. */
  10260. asArray(): number[];
  10261. /**
  10262. * Boolean : True if the current Quaterion and the passed one coordinates are strictly equal.
  10263. */
  10264. equals(otherQuaternion: Quaternion): boolean;
  10265. /**
  10266. * Returns a new Quaternion copied from the current one.
  10267. */
  10268. clone(): Quaternion;
  10269. /**
  10270. * Updates the current Quaternion from the passed one coordinates.
  10271. * Returns the updated Quaterion.
  10272. */
  10273. copyFrom(other: Quaternion): Quaternion;
  10274. /**
  10275. * Updates the current Quaternion from the passed float coordinates.
  10276. * Returns the updated Quaterion.
  10277. */
  10278. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  10279. /**
  10280. * Updates the current Quaternion from the passed float coordinates.
  10281. * Returns the updated Quaterion.
  10282. */
  10283. set(x: number, y: number, z: number, w: number): Quaternion;
  10284. /**
  10285. * Returns a new Quaternion as the addition result of the passed one and the current Quaternion.
  10286. */
  10287. add(other: Quaternion): Quaternion;
  10288. /**
  10289. * Returns a new Quaternion as the subtraction result of the passed one from the current Quaternion.
  10290. */
  10291. subtract(other: Quaternion): Quaternion;
  10292. /**
  10293. * Returns a new Quaternion set by multiplying the current Quaterion coordinates by the float "scale".
  10294. */
  10295. scale(value: number): Quaternion;
  10296. /**
  10297. * Scale the current Quaternion values by a factor to a given Quaternion
  10298. * @param scale defines the scale factor
  10299. * @param result defines the Quaternion object where to store the result
  10300. * @returns the unmodified current Quaternion
  10301. */
  10302. scaleToRef(scale: number, result: Quaternion): Quaternion;
  10303. /**
  10304. * Scale the current Quaternion values by a factor and add the result to a given Quaternion
  10305. * @param scale defines the scale factor
  10306. * @param result defines the Quaternion object where to store the result
  10307. * @returns the unmodified current Quaternion
  10308. */
  10309. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  10310. /**
  10311. * Returns a new Quaternion set as the quaternion mulplication result of the current one with the passed one "q1".
  10312. */
  10313. multiply(q1: Quaternion): Quaternion;
  10314. /**
  10315. * Sets the passed "result" as the quaternion mulplication result of the current one with the passed one "q1".
  10316. * Returns the current Quaternion.
  10317. */
  10318. multiplyToRef(q1: Quaternion, result: Quaternion): Quaternion;
  10319. /**
  10320. * Updates the current Quaternion with the quaternion mulplication result of itself with the passed one "q1".
  10321. * Returns the updated Quaternion.
  10322. */
  10323. multiplyInPlace(q1: Quaternion): Quaternion;
  10324. /**
  10325. * Sets the passed "ref" with the conjugation of the current Quaternion.
  10326. * Returns the current Quaternion.
  10327. */
  10328. conjugateToRef(ref: Quaternion): Quaternion;
  10329. /**
  10330. * Conjugates in place the current Quaternion.
  10331. * Returns the updated Quaternion.
  10332. */
  10333. conjugateInPlace(): Quaternion;
  10334. /**
  10335. * Returns a new Quaternion as the conjugate of the current Quaternion.
  10336. */
  10337. conjugate(): Quaternion;
  10338. /**
  10339. * Returns the Quaternion length (float).
  10340. */
  10341. length(): number;
  10342. /**
  10343. * Normalize in place the current Quaternion.
  10344. * Returns the updated Quaternion.
  10345. */
  10346. normalize(): Quaternion;
  10347. /**
  10348. * Returns a new Vector3 set with the Euler angles translated from the current Quaternion
  10349. * @param order is a reserved parameter and is ignore for now
  10350. * @returns the new Vector3
  10351. */
  10352. toEulerAngles(order?: string): Vector3;
  10353. /**
  10354. * Sets the passed vector3 "result" with the Euler angles translated from the current Quaternion
  10355. * @param result defines the vector which will be filled with the Euler angles
  10356. * @param order is a reserved parameter and is ignore for now
  10357. * @returns the current Quaternion
  10358. */
  10359. toEulerAnglesToRef(result: Vector3, order?: string): Quaternion;
  10360. /**
  10361. * Updates the passed rotation matrix with the current Quaternion values.
  10362. * Returns the current Quaternion.
  10363. */
  10364. toRotationMatrix(result: Matrix): Quaternion;
  10365. /**
  10366. * Updates the current Quaternion from the passed rotation matrix values.
  10367. * Returns the updated Quaternion.
  10368. */
  10369. fromRotationMatrix(matrix: Matrix): Quaternion;
  10370. /**
  10371. * Returns a new Quaternion set from the passed rotation matrix values.
  10372. */
  10373. static FromRotationMatrix(matrix: Matrix): Quaternion;
  10374. /**
  10375. * Updates the passed quaternion "result" with the passed rotation matrix values.
  10376. */
  10377. static FromRotationMatrixToRef(matrix: Matrix, result: Quaternion): void;
  10378. /**
  10379. * Returns a new Quaternion set to (0.0, 0.0, 0.0).
  10380. */
  10381. static Zero(): Quaternion;
  10382. /**
  10383. * Returns a new Quaternion as the inverted current Quaternion.
  10384. */
  10385. static Inverse(q: Quaternion): Quaternion;
  10386. /**
  10387. * Returns the identity Quaternion.
  10388. */
  10389. static Identity(): Quaternion;
  10390. static IsIdentity(quaternion: Quaternion): boolean;
  10391. /**
  10392. * Returns a new Quaternion set from the passed axis (Vector3) and angle in radians (float).
  10393. */
  10394. static RotationAxis(axis: Vector3, angle: number): Quaternion;
  10395. /**
  10396. * Sets the passed quaternion "result" from the passed axis (Vector3) and angle in radians (float).
  10397. */
  10398. static RotationAxisToRef(axis: Vector3, angle: number, result: Quaternion): Quaternion;
  10399. /**
  10400. * Retuns a new Quaternion set from the starting index of the passed array.
  10401. */
  10402. static FromArray(array: ArrayLike<number>, offset?: number): Quaternion;
  10403. /**
  10404. * Returns a new Quaternion set from the passed Euler float angles (y, x, z).
  10405. */
  10406. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  10407. /**
  10408. * Sets the passed quaternion "result" from the passed float Euler angles (y, x, z).
  10409. */
  10410. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  10411. /**
  10412. * Returns a new Quaternion from the passed float Euler angles expressed in z-x-z orientation
  10413. */
  10414. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  10415. /**
  10416. * Sets the passed quaternion "result" from the passed float Euler angles expressed in z-x-z orientation
  10417. */
  10418. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  10419. /**
  10420. * Returns a new Quaternion as the quaternion rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system.
  10421. * cf to Vector3.RotationFromAxis() documentation.
  10422. * Note : axis1, axis2 and axis3 are normalized during this operation.
  10423. */
  10424. static RotationQuaternionFromAxis(axis1: Vector3, axis2: Vector3, axis3: Vector3, ref: Quaternion): Quaternion;
  10425. /**
  10426. * Sets the passed quaternion "ref" with the quaternion rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system.
  10427. * cf to Vector3.RotationFromAxis() documentation.
  10428. * Note : axis1, axis2 and axis3 are normalized during this operation.
  10429. */
  10430. static RotationQuaternionFromAxisToRef(axis1: Vector3, axis2: Vector3, axis3: Vector3, ref: Quaternion): void;
  10431. static Slerp(left: Quaternion, right: Quaternion, amount: number): Quaternion;
  10432. static SlerpToRef(left: Quaternion, right: Quaternion, amount: number, result: Quaternion): void;
  10433. /**
  10434. * Returns a new Quaternion located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2".
  10435. */
  10436. static Hermite(value1: Quaternion, tangent1: Quaternion, value2: Quaternion, tangent2: Quaternion, amount: number): Quaternion;
  10437. }
  10438. class Matrix {
  10439. private static _tempQuaternion;
  10440. private static _xAxis;
  10441. private static _yAxis;
  10442. private static _zAxis;
  10443. private static _updateFlagSeed;
  10444. private static _identityReadOnly;
  10445. private _isIdentity;
  10446. private _isIdentityDirty;
  10447. updateFlag: number;
  10448. m: Float32Array;
  10449. _markAsUpdated(): void;
  10450. constructor();
  10451. /**
  10452. * Boolean : True is the matrix is the identity matrix
  10453. */
  10454. isIdentity(considerAsTextureMatrix?: boolean): boolean;
  10455. /**
  10456. * Returns the matrix determinant (float).
  10457. */
  10458. determinant(): number;
  10459. /**
  10460. * Returns the matrix underlying array.
  10461. */
  10462. toArray(): Float32Array;
  10463. /**
  10464. * Returns the matrix underlying array.
  10465. */
  10466. asArray(): Float32Array;
  10467. /**
  10468. * Inverts in place the Matrix.
  10469. * Returns the Matrix inverted.
  10470. */
  10471. invert(): Matrix;
  10472. /**
  10473. * Sets all the matrix elements to zero.
  10474. * Returns the Matrix.
  10475. */
  10476. reset(): Matrix;
  10477. /**
  10478. * Returns a new Matrix as the addition result of the current Matrix and the passed one.
  10479. */
  10480. add(other: Matrix): Matrix;
  10481. /**
  10482. * Sets the passed matrix "result" with the ddition result of the current Matrix and the passed one.
  10483. * Returns the Matrix.
  10484. */
  10485. addToRef(other: Matrix, result: Matrix): Matrix;
  10486. /**
  10487. * Adds in place the passed matrix to the current Matrix.
  10488. * Returns the updated Matrix.
  10489. */
  10490. addToSelf(other: Matrix): Matrix;
  10491. /**
  10492. * Sets the passed matrix with the current inverted Matrix.
  10493. * Returns the unmodified current Matrix.
  10494. */
  10495. invertToRef(other: Matrix): Matrix;
  10496. /**
  10497. * Inserts the translation vector (using 3 x floats) in the current Matrix.
  10498. * Returns the updated Matrix.
  10499. */
  10500. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  10501. /**
  10502. * Inserts the translation vector in the current Matrix.
  10503. * Returns the updated Matrix.
  10504. */
  10505. setTranslation(vector3: Vector3): Matrix;
  10506. /**
  10507. * Returns a new Vector3 as the extracted translation from the Matrix.
  10508. */
  10509. getTranslation(): Vector3;
  10510. /**
  10511. * Fill a Vector3 with the extracted translation from the Matrix.
  10512. */
  10513. getTranslationToRef(result: Vector3): Matrix;
  10514. /**
  10515. * Remove rotation and scaling part from the Matrix.
  10516. * Returns the updated Matrix.
  10517. */
  10518. removeRotationAndScaling(): Matrix;
  10519. /**
  10520. * Returns a new Matrix set with the multiplication result of the current Matrix and the passed one.
  10521. */
  10522. multiply(other: Matrix): Matrix;
  10523. /**
  10524. * Updates the current Matrix from the passed one values.
  10525. * Returns the updated Matrix.
  10526. */
  10527. copyFrom(other: Matrix): Matrix;
  10528. /**
  10529. * Populates the passed array from the starting index with the Matrix values.
  10530. * Returns the Matrix.
  10531. */
  10532. copyToArray(array: Float32Array, offset?: number): Matrix;
  10533. /**
  10534. * Sets the passed matrix "result" with the multiplication result of the current Matrix and the passed one.
  10535. */
  10536. multiplyToRef(other: Matrix, result: Matrix): Matrix;
  10537. /**
  10538. * Sets the Float32Array "result" from the passed index "offset" with the multiplication result of the current Matrix and the passed one.
  10539. */
  10540. multiplyToArray(other: Matrix, result: Float32Array, offset: number): Matrix;
  10541. /**
  10542. * Boolean : True is the current Matrix and the passed one values are strictly equal.
  10543. */
  10544. equals(value: Matrix): boolean;
  10545. /**
  10546. * Returns a new Matrix from the current Matrix.
  10547. */
  10548. clone(): Matrix;
  10549. /**
  10550. * Returns the string "Matrix"
  10551. */
  10552. getClassName(): string;
  10553. /**
  10554. * Returns the Matrix hash code.
  10555. */
  10556. getHashCode(): number;
  10557. /**
  10558. * Decomposes the current Matrix into :
  10559. * - a scale vector3 passed as a reference to update,
  10560. * - a rotation quaternion passed as a reference to update,
  10561. * - a translation vector3 passed as a reference to update.
  10562. * Returns the true if operation was successful.
  10563. */
  10564. decompose(scale: Vector3, rotation: Quaternion, translation: Vector3): boolean;
  10565. /**
  10566. * Returns the index-th row of the current matrix as a new Vector4.
  10567. */
  10568. getRow(index: number): Nullable<Vector4>;
  10569. /**
  10570. * Sets the index-th row of the current matrix with the passed Vector4 values.
  10571. * Returns the updated Matrix.
  10572. */
  10573. setRow(index: number, row: Vector4): Matrix;
  10574. /**
  10575. * Compute the transpose of the matrix.
  10576. * Returns a new Matrix.
  10577. */
  10578. transpose(): Matrix;
  10579. /**
  10580. * Compute the transpose of the matrix.
  10581. * Returns the current matrix.
  10582. */
  10583. transposeToRef(result: Matrix): Matrix;
  10584. /**
  10585. * Sets the index-th row of the current matrix with the passed 4 x float values.
  10586. * Returns the updated Matrix.
  10587. */
  10588. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  10589. /**
  10590. * Compute a new Matrix set with the current Matrix values multiplied by scale (float)
  10591. * @param scale defines the scale factor
  10592. * @returns a new Matrix
  10593. */
  10594. scale(scale: number): Matrix;
  10595. /**
  10596. * Scale the current Matrix values by a factor to a given result Matrix
  10597. * @param scale defines the scale factor
  10598. * @param result defines the Matrix to store the result
  10599. * @returns the current Matrix
  10600. */
  10601. scaleToRef(scale: number, result: Matrix): Matrix;
  10602. /**
  10603. * Scale the current Matrix values by a factor and add the result to a given Matrix
  10604. * @param scale defines the scale factor
  10605. * @param result defines the Matrix to store the result
  10606. * @returns the current Matrix
  10607. */
  10608. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  10609. /**
  10610. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  10611. * @param ref matrix to store the result
  10612. */
  10613. toNormalMatrix(ref: Matrix): void;
  10614. /**
  10615. * Returns a new Matrix as the extracted rotation matrix from the current one.
  10616. */
  10617. getRotationMatrix(): Matrix;
  10618. /**
  10619. * Extracts the rotation matrix from the current one and sets it as the passed "result".
  10620. * Returns the current Matrix.
  10621. */
  10622. getRotationMatrixToRef(result: Matrix): Matrix;
  10623. /**
  10624. * Returns a new Matrix set from the starting index of the passed array.
  10625. */
  10626. static FromArray(array: ArrayLike<number>, offset?: number): Matrix;
  10627. /**
  10628. * Sets the passed "result" matrix from the starting index of the passed array.
  10629. */
  10630. static FromArrayToRef(array: ArrayLike<number>, offset: number, result: Matrix): void;
  10631. /**
  10632. * Sets the passed "result" matrix from the starting index of the passed Float32Array by multiplying each element by the float "scale".
  10633. */
  10634. static FromFloat32ArrayToRefScaled(array: Float32Array, offset: number, scale: number, result: Matrix): void;
  10635. /**
  10636. * Sets the passed matrix "result" with the 16 passed floats.
  10637. */
  10638. 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;
  10639. /**
  10640. * Static identity matrix to be used as readonly matrix
  10641. * Must not be updated.
  10642. */
  10643. static readonly IdentityReadOnly: Matrix;
  10644. /**
  10645. * Returns a new Matrix set from the 16 passed floats.
  10646. */
  10647. 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;
  10648. /**
  10649. * Returns a new Matrix composed by the passed scale (vector3), rotation (quaternion) and translation (vector3).
  10650. */
  10651. static Compose(scale: Vector3, rotation: Quaternion, translation: Vector3): Matrix;
  10652. /**
  10653. * Update a Matrix with values composed by the passed scale (vector3), rotation (quaternion) and translation (vector3).
  10654. */
  10655. static ComposeToRef(scale: Vector3, rotation: Quaternion, translation: Vector3, result: Matrix): void;
  10656. /**
  10657. * Returns a new indentity Matrix.
  10658. */
  10659. static Identity(): Matrix;
  10660. /**
  10661. * Sets the passed "result" as an identity matrix.
  10662. */
  10663. static IdentityToRef(result: Matrix): void;
  10664. /**
  10665. * Returns a new zero Matrix.
  10666. */
  10667. static Zero(): Matrix;
  10668. /**
  10669. * Returns a new rotation matrix for "angle" radians around the X axis.
  10670. */
  10671. static RotationX(angle: number): Matrix;
  10672. /**
  10673. * Returns a new Matrix as the passed inverted one.
  10674. */
  10675. static Invert(source: Matrix): Matrix;
  10676. /**
  10677. * Sets the passed matrix "result" as a rotation matrix for "angle" radians around the X axis.
  10678. */
  10679. static RotationXToRef(angle: number, result: Matrix): void;
  10680. /**
  10681. * Returns a new rotation matrix for "angle" radians around the Y axis.
  10682. */
  10683. static RotationY(angle: number): Matrix;
  10684. /**
  10685. * Sets the passed matrix "result" as a rotation matrix for "angle" radians around the Y axis.
  10686. */
  10687. static RotationYToRef(angle: number, result: Matrix): void;
  10688. /**
  10689. * Returns a new rotation matrix for "angle" radians around the Z axis.
  10690. */
  10691. static RotationZ(angle: number): Matrix;
  10692. /**
  10693. * Sets the passed matrix "result" as a rotation matrix for "angle" radians around the Z axis.
  10694. */
  10695. static RotationZToRef(angle: number, result: Matrix): void;
  10696. /**
  10697. * Returns a new rotation matrix for "angle" radians around the passed axis.
  10698. */
  10699. static RotationAxis(axis: Vector3, angle: number): Matrix;
  10700. /**
  10701. * Sets the passed matrix "result" as a rotation matrix for "angle" radians around the passed axis.
  10702. */
  10703. static RotationAxisToRef(axis: Vector3, angle: number, result: Matrix): void;
  10704. /**
  10705. * Returns a new Matrix as a rotation matrix from the Euler angles (y, x, z).
  10706. */
  10707. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  10708. /**
  10709. * Sets the passed matrix "result" as a rotation matrix from the Euler angles (y, x, z).
  10710. */
  10711. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  10712. /**
  10713. * Returns a new Matrix as a scaling matrix from the passed floats (x, y, z).
  10714. */
  10715. static Scaling(x: number, y: number, z: number): Matrix;
  10716. /**
  10717. * Sets the passed matrix "result" as a scaling matrix from the passed floats (x, y, z).
  10718. */
  10719. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  10720. /**
  10721. * Returns a new Matrix as a translation matrix from the passed floats (x, y, z).
  10722. */
  10723. static Translation(x: number, y: number, z: number): Matrix;
  10724. /**
  10725. * Sets the passed matrix "result" as a translation matrix from the passed floats (x, y, z).
  10726. */
  10727. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  10728. /**
  10729. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  10730. * @param startValue defines the start value
  10731. * @param endValue defines the end value
  10732. * @param gradient defines the gradient factor
  10733. * @returns the new matrix
  10734. */
  10735. static Lerp(startValue: Matrix, endValue: Matrix, gradient: number): Matrix;
  10736. /**
  10737. * Set the passed matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  10738. * @param startValue defines the start value
  10739. * @param endValue defines the end value
  10740. * @param gradient defines the gradient factor
  10741. * @param result defines the Matrix object where to store data
  10742. */
  10743. static LerpToRef(startValue: Matrix, endValue: Matrix, gradient: number, result: Matrix): void;
  10744. /**
  10745. * Returns a new Matrix whose values are computed by :
  10746. * - decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices,
  10747. * - interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end,
  10748. * - recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices.
  10749. */
  10750. static DecomposeLerp(startValue: Matrix, endValue: Matrix, gradient: number): Matrix;
  10751. /**
  10752. * 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".
  10753. * This methods works for a Left-Handed system.
  10754. */
  10755. static LookAtLH(eye: Vector3, target: Vector3, up: Vector3): Matrix;
  10756. /**
  10757. * 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".
  10758. * This methods works for a Left-Handed system.
  10759. */
  10760. static LookAtLHToRef(eye: Vector3, target: Vector3, up: Vector3, result: Matrix): void;
  10761. /**
  10762. * 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".
  10763. * This methods works for a Right-Handed system.
  10764. */
  10765. static LookAtRH(eye: Vector3, target: Vector3, up: Vector3): Matrix;
  10766. /**
  10767. * 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".
  10768. * This methods works for a Left-Handed system.
  10769. */
  10770. static LookAtRHToRef(eye: Vector3, target: Vector3, up: Vector3, result: Matrix): void;
  10771. /**
  10772. * 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.
  10773. */
  10774. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  10775. /**
  10776. * 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.
  10777. */
  10778. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  10779. /**
  10780. * 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.
  10781. */
  10782. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  10783. /**
  10784. * 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.
  10785. */
  10786. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  10787. /**
  10788. * 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.
  10789. */
  10790. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  10791. /**
  10792. * 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.
  10793. */
  10794. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  10795. /**
  10796. * 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.
  10797. */
  10798. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  10799. /**
  10800. * 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.
  10801. */
  10802. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  10803. /**
  10804. * 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.
  10805. */
  10806. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  10807. /**
  10808. * 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.
  10809. */
  10810. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  10811. /**
  10812. * 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.
  10813. */
  10814. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  10815. /**
  10816. * 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.
  10817. */
  10818. static PerspectiveFovWebVRToRef(fov: {
  10819. upDegrees: number;
  10820. downDegrees: number;
  10821. leftDegrees: number;
  10822. rightDegrees: number;
  10823. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  10824. /**
  10825. * Returns the final transformation matrix : world * view * projection * viewport
  10826. */
  10827. static GetFinalMatrix(viewport: Viewport, world: Matrix, view: Matrix, projection: Matrix, zmin: number, zmax: number): Matrix;
  10828. /**
  10829. * Returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the passed Matrix.
  10830. */
  10831. static GetAsMatrix2x2(matrix: Matrix): Float32Array;
  10832. /**
  10833. * Returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the passed Matrix.
  10834. */
  10835. static GetAsMatrix3x3(matrix: Matrix): Float32Array;
  10836. /**
  10837. * Compute the transpose of the passed Matrix.
  10838. * Returns a new Matrix.
  10839. */
  10840. static Transpose(matrix: Matrix): Matrix;
  10841. /**
  10842. * Compute the transpose of the passed Matrix and store it in the result matrix.
  10843. */
  10844. static TransposeToRef(matrix: Matrix, result: Matrix): void;
  10845. /**
  10846. * Returns a new Matrix as the reflection matrix across the passed plane.
  10847. */
  10848. static Reflection(plane: Plane): Matrix;
  10849. /**
  10850. * Sets the passed matrix "result" as the reflection matrix across the passed plane.
  10851. */
  10852. static ReflectionToRef(plane: Plane, result: Matrix): void;
  10853. /**
  10854. * Sets the passed matrix "mat" as a rotation matrix composed from the 3 passed left handed axis.
  10855. */
  10856. static FromXYZAxesToRef(xaxis: Vector3, yaxis: Vector3, zaxis: Vector3, result: Matrix): void;
  10857. /**
  10858. * Sets the passed matrix "result" as a rotation matrix according to the passed quaternion.
  10859. */
  10860. static FromQuaternionToRef(quat: Quaternion, result: Matrix): void;
  10861. }
  10862. class Plane {
  10863. normal: Vector3;
  10864. d: number;
  10865. /**
  10866. * Creates a Plane object according to the passed floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  10867. */
  10868. constructor(a: number, b: number, c: number, d: number);
  10869. /**
  10870. * Returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  10871. */
  10872. asArray(): number[];
  10873. /**
  10874. * Returns a new plane copied from the current Plane.
  10875. */
  10876. clone(): Plane;
  10877. /**
  10878. * Returns the string "Plane".
  10879. */
  10880. getClassName(): string;
  10881. /**
  10882. * Returns the Plane hash code.
  10883. */
  10884. getHashCode(): number;
  10885. /**
  10886. * Normalize the current Plane in place.
  10887. * Returns the updated Plane.
  10888. */
  10889. normalize(): Plane;
  10890. /**
  10891. * Returns a new Plane as the result of the transformation of the current Plane by the passed matrix.
  10892. */
  10893. transform(transformation: Matrix): Plane;
  10894. /**
  10895. * Returns the dot product (float) of the point coordinates and the plane normal.
  10896. */
  10897. dotCoordinate(point: Vector3): number;
  10898. /**
  10899. * Updates the current Plane from the plane defined by the three passed points.
  10900. * Returns the updated Plane.
  10901. */
  10902. copyFromPoints(point1: Vector3, point2: Vector3, point3: Vector3): Plane;
  10903. /**
  10904. * Boolean : True is the vector "direction" is the same side than the plane normal.
  10905. */
  10906. isFrontFacingTo(direction: Vector3, epsilon: number): boolean;
  10907. /**
  10908. * Returns the signed distance (float) from the passed point to the Plane.
  10909. */
  10910. signedDistanceTo(point: Vector3): number;
  10911. /**
  10912. * Returns a new Plane from the passed array.
  10913. */
  10914. static FromArray(array: ArrayLike<number>): Plane;
  10915. /**
  10916. * Returns a new Plane defined by the three passed points.
  10917. */
  10918. static FromPoints(point1: Vector3, point2: Vector3, point3: Vector3): Plane;
  10919. /**
  10920. * Returns a new Plane the normal vector to this plane at the passed origin point.
  10921. * Note : the vector "normal" is updated because normalized.
  10922. */
  10923. static FromPositionAndNormal(origin: Vector3, normal: Vector3): Plane;
  10924. /**
  10925. * Returns the signed distance between the plane defined by the normal vector at the "origin"" point and the passed other point.
  10926. */
  10927. static SignedDistanceToPlaneFromPositionAndNormal(origin: Vector3, normal: Vector3, point: Vector3): number;
  10928. }
  10929. class Viewport {
  10930. x: number;
  10931. y: number;
  10932. width: number;
  10933. height: number;
  10934. /**
  10935. * Creates a Viewport object located at (x, y) and sized (width, height).
  10936. */
  10937. constructor(x: number, y: number, width: number, height: number);
  10938. toGlobal(renderWidthOrEngine: number | Engine, renderHeight: number): Viewport;
  10939. /**
  10940. * Returns a new Viewport copied from the current one.
  10941. */
  10942. clone(): Viewport;
  10943. }
  10944. class Frustum {
  10945. /**
  10946. * Returns a new array of 6 Frustum planes computed by the passed transformation matrix.
  10947. */
  10948. static GetPlanes(transform: Matrix): Plane[];
  10949. static GetNearPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  10950. static GetFarPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  10951. static GetLeftPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  10952. static GetRightPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  10953. static GetTopPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  10954. static GetBottomPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  10955. /**
  10956. * Sets the passed array "frustumPlanes" with the 6 Frustum planes computed by the passed transformation matrix.
  10957. */
  10958. static GetPlanesToRef(transform: Matrix, frustumPlanes: Plane[]): void;
  10959. }
  10960. enum Space {
  10961. LOCAL = 0,
  10962. WORLD = 1,
  10963. BONE = 2,
  10964. }
  10965. class Axis {
  10966. static X: Vector3;
  10967. static Y: Vector3;
  10968. static Z: Vector3;
  10969. }
  10970. class BezierCurve {
  10971. /**
  10972. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the passed x1, y1, x2, y2 floats.
  10973. */
  10974. static interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  10975. }
  10976. enum Orientation {
  10977. CW = 0,
  10978. CCW = 1,
  10979. }
  10980. class Angle {
  10981. private _radians;
  10982. /**
  10983. * Creates an Angle object of "radians" radians (float).
  10984. */
  10985. constructor(radians: number);
  10986. /**
  10987. * Returns the Angle value in degrees (float).
  10988. */
  10989. degrees: () => number;
  10990. /**
  10991. * Returns the Angle value in radians (float).
  10992. */
  10993. radians: () => number;
  10994. /**
  10995. * Returns a new Angle object valued with the angle value in radians between the two passed vectors.
  10996. */
  10997. static BetweenTwoPoints(a: Vector2, b: Vector2): Angle;
  10998. /**
  10999. * Returns a new Angle object from the passed float in radians.
  11000. */
  11001. static FromRadians(radians: number): Angle;
  11002. /**
  11003. * Returns a new Angle object from the passed float in degrees.
  11004. */
  11005. static FromDegrees(degrees: number): Angle;
  11006. }
  11007. class Arc2 {
  11008. startPoint: Vector2;
  11009. midPoint: Vector2;
  11010. endPoint: Vector2;
  11011. centerPoint: Vector2;
  11012. radius: number;
  11013. angle: Angle;
  11014. startAngle: Angle;
  11015. orientation: Orientation;
  11016. /**
  11017. * Creates an Arc object from the three passed points : start, middle and end.
  11018. */
  11019. constructor(startPoint: Vector2, midPoint: Vector2, endPoint: Vector2);
  11020. }
  11021. class Path2 {
  11022. private _points;
  11023. private _length;
  11024. closed: boolean;
  11025. /**
  11026. * Creates a Path2 object from the starting 2D coordinates x and y.
  11027. */
  11028. constructor(x: number, y: number);
  11029. /**
  11030. * Adds a new segment until the passed coordinates (x, y) to the current Path2.
  11031. * Returns the updated Path2.
  11032. */
  11033. addLineTo(x: number, y: number): Path2;
  11034. /**
  11035. * 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.
  11036. * Returns the updated Path2.
  11037. */
  11038. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  11039. /**
  11040. * Closes the Path2.
  11041. * Returns the Path2.
  11042. */
  11043. close(): Path2;
  11044. /**
  11045. * Returns the Path2 total length (float).
  11046. */
  11047. length(): number;
  11048. /**
  11049. * Returns the Path2 internal array of points.
  11050. */
  11051. getPoints(): Vector2[];
  11052. /**
  11053. * Returns a new Vector2 located at a percentage of the Path2 total length on this path.
  11054. */
  11055. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  11056. /**
  11057. * Returns a new Path2 starting at the coordinates (x, y).
  11058. */
  11059. static StartingAt(x: number, y: number): Path2;
  11060. }
  11061. class Path3D {
  11062. path: Vector3[];
  11063. private _curve;
  11064. private _distances;
  11065. private _tangents;
  11066. private _normals;
  11067. private _binormals;
  11068. private _raw;
  11069. /**
  11070. * new Path3D(path, normal, raw)
  11071. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  11072. * please read the description in the tutorial : http://doc.babylonjs.com/tutorials/How_to_use_Path3D
  11073. * path : an array of Vector3, the curve axis of the Path3D
  11074. * normal (optional) : Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  11075. * raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  11076. */
  11077. constructor(path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  11078. /**
  11079. * Returns the Path3D array of successive Vector3 designing its curve.
  11080. */
  11081. getCurve(): Vector3[];
  11082. /**
  11083. * Returns an array populated with tangent vectors on each Path3D curve point.
  11084. */
  11085. getTangents(): Vector3[];
  11086. /**
  11087. * Returns an array populated with normal vectors on each Path3D curve point.
  11088. */
  11089. getNormals(): Vector3[];
  11090. /**
  11091. * Returns an array populated with binormal vectors on each Path3D curve point.
  11092. */
  11093. getBinormals(): Vector3[];
  11094. /**
  11095. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  11096. */
  11097. getDistances(): number[];
  11098. /**
  11099. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  11100. * Returns the same object updated.
  11101. */
  11102. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  11103. private _compute(firstNormal);
  11104. private _getFirstNonNullVector(index);
  11105. private _getLastNonNullVector(index);
  11106. private _normalVector(v0, vt, va);
  11107. }
  11108. class Curve3 {
  11109. private _points;
  11110. private _length;
  11111. /**
  11112. * Returns a Curve3 object along a Quadratic Bezier curve : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#quadratic-bezier-curve
  11113. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  11114. * @param v1 (Vector3) the control point
  11115. * @param v2 (Vector3) the end point of the Quadratic Bezier
  11116. * @param nbPoints (integer) the wanted number of points in the curve
  11117. */
  11118. static CreateQuadraticBezier(v0: Vector3, v1: Vector3, v2: Vector3, nbPoints: number): Curve3;
  11119. /**
  11120. * Returns a Curve3 object along a Cubic Bezier curve : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#cubic-bezier-curve
  11121. * @param v0 (Vector3) the origin point of the Cubic Bezier
  11122. * @param v1 (Vector3) the first control point
  11123. * @param v2 (Vector3) the second control point
  11124. * @param v3 (Vector3) the end point of the Cubic Bezier
  11125. * @param nbPoints (integer) the wanted number of points in the curve
  11126. */
  11127. static CreateCubicBezier(v0: Vector3, v1: Vector3, v2: Vector3, v3: Vector3, nbPoints: number): Curve3;
  11128. /**
  11129. * Returns a Curve3 object along a Hermite Spline curve : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#hermite-spline
  11130. * @param p1 (Vector3) the origin point of the Hermite Spline
  11131. * @param t1 (Vector3) the tangent vector at the origin point
  11132. * @param p2 (Vector3) the end point of the Hermite Spline
  11133. * @param t2 (Vector3) the tangent vector at the end point
  11134. * @param nbPoints (integer) the wanted number of points in the curve
  11135. */
  11136. static CreateHermiteSpline(p1: Vector3, t1: Vector3, p2: Vector3, t2: Vector3, nbPoints: number): Curve3;
  11137. /**
  11138. * Returns a Curve3 object along a CatmullRom Spline curve :
  11139. * @param points (array of Vector3) the points the spline must pass through. At least, four points required.
  11140. * @param nbPoints (integer) the wanted number of points between each curve control points.
  11141. */
  11142. static CreateCatmullRomSpline(points: Vector3[], nbPoints: number): Curve3;
  11143. /**
  11144. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  11145. * A Curve3 is designed from a series of successive Vector3.
  11146. * Tuto : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#curve3-object
  11147. */
  11148. constructor(points: Vector3[]);
  11149. /**
  11150. * Returns the Curve3 stored array of successive Vector3
  11151. */
  11152. getPoints(): Vector3[];
  11153. /**
  11154. * Returns the computed length (float) of the curve.
  11155. */
  11156. length(): number;
  11157. /**
  11158. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  11159. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  11160. * curveA and curveB keep unchanged.
  11161. */
  11162. continue(curve: Curve3): Curve3;
  11163. private _computeLength(path);
  11164. }
  11165. class PositionNormalVertex {
  11166. position: Vector3;
  11167. normal: Vector3;
  11168. constructor(position?: Vector3, normal?: Vector3);
  11169. clone(): PositionNormalVertex;
  11170. }
  11171. class PositionNormalTextureVertex {
  11172. position: Vector3;
  11173. normal: Vector3;
  11174. uv: Vector2;
  11175. constructor(position?: Vector3, normal?: Vector3, uv?: Vector2);
  11176. clone(): PositionNormalTextureVertex;
  11177. }
  11178. class Tmp {
  11179. static Color3: Color3[];
  11180. static Vector2: Vector2[];
  11181. static Vector3: Vector3[];
  11182. static Vector4: Vector4[];
  11183. static Quaternion: Quaternion[];
  11184. static Matrix: Matrix[];
  11185. }
  11186. }
  11187. declare module BABYLON {
  11188. class SphericalPolynomial {
  11189. x: Vector3;
  11190. y: Vector3;
  11191. z: Vector3;
  11192. xx: Vector3;
  11193. yy: Vector3;
  11194. zz: Vector3;
  11195. xy: Vector3;
  11196. yz: Vector3;
  11197. zx: Vector3;
  11198. addAmbient(color: Color3): void;
  11199. static getSphericalPolynomialFromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  11200. scale(scale: number): void;
  11201. }
  11202. class SphericalHarmonics {
  11203. L00: Vector3;
  11204. L1_1: Vector3;
  11205. L10: Vector3;
  11206. L11: Vector3;
  11207. L2_2: Vector3;
  11208. L2_1: Vector3;
  11209. L20: Vector3;
  11210. L21: Vector3;
  11211. L22: Vector3;
  11212. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  11213. scale(scale: number): void;
  11214. convertIncidentRadianceToIrradiance(): void;
  11215. convertIrradianceToLambertianRadiance(): void;
  11216. static getsphericalHarmonicsFromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  11217. }
  11218. }
  11219. declare module BABYLON {
  11220. /**
  11221. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  11222. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  11223. * 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;
  11224. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  11225. */
  11226. class ColorCurves {
  11227. private _dirty;
  11228. private _tempColor;
  11229. private _globalCurve;
  11230. private _highlightsCurve;
  11231. private _midtonesCurve;
  11232. private _shadowsCurve;
  11233. private _positiveCurve;
  11234. private _negativeCurve;
  11235. private _globalHue;
  11236. private _globalDensity;
  11237. private _globalSaturation;
  11238. private _globalExposure;
  11239. /**
  11240. * Gets the global Hue value.
  11241. * 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).
  11242. */
  11243. /**
  11244. * Sets the global Hue value.
  11245. * 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).
  11246. */
  11247. globalHue: number;
  11248. /**
  11249. * Gets the global Density value.
  11250. * 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.
  11251. * Values less than zero provide a filter of opposite hue.
  11252. */
  11253. /**
  11254. * Sets the global Density value.
  11255. * 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.
  11256. * Values less than zero provide a filter of opposite hue.
  11257. */
  11258. globalDensity: number;
  11259. /**
  11260. * Gets the global Saturation value.
  11261. * 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.
  11262. */
  11263. /**
  11264. * Sets the global Saturation value.
  11265. * 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.
  11266. */
  11267. globalSaturation: number;
  11268. private _highlightsHue;
  11269. private _highlightsDensity;
  11270. private _highlightsSaturation;
  11271. private _highlightsExposure;
  11272. /**
  11273. * Gets the highlights Hue value.
  11274. * 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).
  11275. */
  11276. /**
  11277. * Sets the highlights Hue value.
  11278. * 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).
  11279. */
  11280. highlightsHue: number;
  11281. /**
  11282. * Gets the highlights Density value.
  11283. * 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.
  11284. * Values less than zero provide a filter of opposite hue.
  11285. */
  11286. /**
  11287. * Sets the highlights Density value.
  11288. * 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.
  11289. * Values less than zero provide a filter of opposite hue.
  11290. */
  11291. highlightsDensity: number;
  11292. /**
  11293. * Gets the highlights Saturation value.
  11294. * 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.
  11295. */
  11296. /**
  11297. * Sets the highlights Saturation value.
  11298. * 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.
  11299. */
  11300. highlightsSaturation: number;
  11301. /**
  11302. * Gets the highlights Exposure value.
  11303. * 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.
  11304. */
  11305. /**
  11306. * Sets the highlights Exposure value.
  11307. * 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.
  11308. */
  11309. highlightsExposure: number;
  11310. private _midtonesHue;
  11311. private _midtonesDensity;
  11312. private _midtonesSaturation;
  11313. private _midtonesExposure;
  11314. /**
  11315. * Gets the midtones Hue value.
  11316. * 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).
  11317. */
  11318. /**
  11319. * Sets the midtones Hue value.
  11320. * 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).
  11321. */
  11322. midtonesHue: number;
  11323. /**
  11324. * Gets the midtones Density value.
  11325. * 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.
  11326. * Values less than zero provide a filter of opposite hue.
  11327. */
  11328. /**
  11329. * Sets the midtones Density value.
  11330. * 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.
  11331. * Values less than zero provide a filter of opposite hue.
  11332. */
  11333. midtonesDensity: number;
  11334. /**
  11335. * Gets the midtones Saturation value.
  11336. * 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.
  11337. */
  11338. /**
  11339. * Sets the midtones Saturation value.
  11340. * 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.
  11341. */
  11342. midtonesSaturation: number;
  11343. /**
  11344. * Gets the midtones Exposure value.
  11345. * 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.
  11346. */
  11347. /**
  11348. * Sets the midtones Exposure value.
  11349. * 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.
  11350. */
  11351. midtonesExposure: number;
  11352. private _shadowsHue;
  11353. private _shadowsDensity;
  11354. private _shadowsSaturation;
  11355. private _shadowsExposure;
  11356. /**
  11357. * Gets the shadows Hue value.
  11358. * 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).
  11359. */
  11360. /**
  11361. * Sets the shadows Hue value.
  11362. * 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).
  11363. */
  11364. shadowsHue: number;
  11365. /**
  11366. * Gets the shadows Density value.
  11367. * 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.
  11368. * Values less than zero provide a filter of opposite hue.
  11369. */
  11370. /**
  11371. * Sets the shadows Density value.
  11372. * 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.
  11373. * Values less than zero provide a filter of opposite hue.
  11374. */
  11375. shadowsDensity: number;
  11376. /**
  11377. * Gets the shadows Saturation value.
  11378. * 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.
  11379. */
  11380. /**
  11381. * Sets the shadows Saturation value.
  11382. * 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.
  11383. */
  11384. shadowsSaturation: number;
  11385. /**
  11386. * Gets the shadows Exposure value.
  11387. * 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.
  11388. */
  11389. /**
  11390. * Sets the shadows Exposure value.
  11391. * 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.
  11392. */
  11393. shadowsExposure: number;
  11394. getClassName(): string;
  11395. /**
  11396. * Binds the color curves to the shader.
  11397. * @param colorCurves The color curve to bind
  11398. * @param effect The effect to bind to
  11399. */
  11400. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  11401. /**
  11402. * Prepare the list of uniforms associated with the ColorCurves effects.
  11403. * @param uniformsList The list of uniforms used in the effect
  11404. */
  11405. static PrepareUniforms(uniformsList: string[]): void;
  11406. /**
  11407. * Returns color grading data based on a hue, density, saturation and exposure value.
  11408. * @param filterHue The hue of the color filter.
  11409. * @param filterDensity The density of the color filter.
  11410. * @param saturation The saturation.
  11411. * @param exposure The exposure.
  11412. * @param result The result data container.
  11413. */
  11414. private getColorGradingDataToRef(hue, density, saturation, exposure, result);
  11415. /**
  11416. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  11417. * @param value The input slider value in range [-100,100].
  11418. * @returns Adjusted value.
  11419. */
  11420. private static applyColorGradingSliderNonlinear(value);
  11421. /**
  11422. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  11423. * @param hue The hue (H) input.
  11424. * @param saturation The saturation (S) input.
  11425. * @param brightness The brightness (B) input.
  11426. * @result An RGBA color represented as Vector4.
  11427. */
  11428. private static fromHSBToRef(hue, saturation, brightness, result);
  11429. /**
  11430. * Returns a value clamped between min and max
  11431. * @param value The value to clamp
  11432. * @param min The minimum of value
  11433. * @param max The maximum of value
  11434. * @returns The clamped value.
  11435. */
  11436. private static clamp(value, min, max);
  11437. /**
  11438. * Clones the current color curve instance.
  11439. * @return The cloned curves
  11440. */
  11441. clone(): ColorCurves;
  11442. /**
  11443. * Serializes the current color curve instance to a json representation.
  11444. * @return a JSON representation
  11445. */
  11446. serialize(): any;
  11447. /**
  11448. * Parses the color curve from a json representation.
  11449. * @param source the JSON source to parse
  11450. * @return The parsed curves
  11451. */
  11452. static Parse(source: any): ColorCurves;
  11453. }
  11454. }
  11455. declare module BABYLON {
  11456. /**
  11457. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  11458. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  11459. */
  11460. class EffectFallbacks {
  11461. private _defines;
  11462. private _currentRank;
  11463. private _maxRank;
  11464. private _mesh;
  11465. /**
  11466. * Removes the fallback from the bound mesh.
  11467. */
  11468. unBindMesh(): void;
  11469. /**
  11470. * Adds a fallback on the specified property.
  11471. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  11472. * @param define The name of the define in the shader
  11473. */
  11474. addFallback(rank: number, define: string): void;
  11475. /**
  11476. * Sets the mesh to use CPU skinning when needing to fallback.
  11477. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  11478. * @param mesh The mesh to use the fallbacks.
  11479. */
  11480. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  11481. /**
  11482. * Checks to see if more fallbacks are still availible.
  11483. */
  11484. readonly isMoreFallbacks: boolean;
  11485. /**
  11486. * Removes the defines that shoould be removed when falling back.
  11487. * @param currentDefines defines the current define statements for the shader.
  11488. * @param effect defines the current effect we try to compile
  11489. * @returns The resulting defines with defines of the current rank removed.
  11490. */
  11491. reduce(currentDefines: string, effect: Effect): string;
  11492. }
  11493. /**
  11494. * Options to be used when creating an effect.
  11495. */
  11496. class EffectCreationOptions {
  11497. /**
  11498. * Atrributes that will be used in the shader.
  11499. */
  11500. attributes: string[];
  11501. /**
  11502. * Uniform varible names that will be set in the shader.
  11503. */
  11504. uniformsNames: string[];
  11505. /**
  11506. * Uniform buffer varible names that will be set in the shader.
  11507. */
  11508. uniformBuffersNames: string[];
  11509. /**
  11510. * Sampler texture variable names that will be set in the shader.
  11511. */
  11512. samplers: string[];
  11513. /**
  11514. * Define statements that will be set in the shader.
  11515. */
  11516. defines: any;
  11517. /**
  11518. * Possible fallbacks for this effect to improve performance when needed.
  11519. */
  11520. fallbacks: Nullable<EffectFallbacks>;
  11521. /**
  11522. * Callback that will be called when the shader is compiled.
  11523. */
  11524. onCompiled: Nullable<(effect: Effect) => void>;
  11525. /**
  11526. * Callback that will be called if an error occurs during shader compilation.
  11527. */
  11528. onError: Nullable<(effect: Effect, errors: string) => void>;
  11529. /**
  11530. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  11531. */
  11532. indexParameters: any;
  11533. /**
  11534. * Max number of lights that can be used in the shader.
  11535. */
  11536. maxSimultaneousLights: number;
  11537. /**
  11538. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  11539. */
  11540. transformFeedbackVaryings: Nullable<string[]>;
  11541. }
  11542. /**
  11543. * Effect containing vertex and fragment shader that can be executed on an object.
  11544. */
  11545. class Effect {
  11546. /**
  11547. * Name of the effect.
  11548. */
  11549. name: any;
  11550. /**
  11551. * String container all the define statements that should be set on the shader.
  11552. */
  11553. defines: string;
  11554. /**
  11555. * Callback that will be called when the shader is compiled.
  11556. */
  11557. onCompiled: Nullable<(effect: Effect) => void>;
  11558. /**
  11559. * Callback that will be called if an error occurs during shader compilation.
  11560. */
  11561. onError: Nullable<(effect: Effect, errors: string) => void>;
  11562. /**
  11563. * Callback that will be called when effect is bound.
  11564. */
  11565. onBind: Nullable<(effect: Effect) => void>;
  11566. /**
  11567. * Unique ID of the effect.
  11568. */
  11569. uniqueId: number;
  11570. /**
  11571. * Observable that will be called when the shader is compiled.
  11572. */
  11573. onCompileObservable: Observable<Effect>;
  11574. /**
  11575. * Observable that will be called if an error occurs during shader compilation.
  11576. */
  11577. onErrorObservable: Observable<Effect>;
  11578. /**
  11579. * Observable that will be called when effect is bound.
  11580. */
  11581. onBindObservable: Observable<Effect>;
  11582. private static _uniqueIdSeed;
  11583. private _engine;
  11584. private _uniformBuffersNames;
  11585. private _uniformsNames;
  11586. private _samplers;
  11587. private _isReady;
  11588. private _compilationError;
  11589. private _attributesNames;
  11590. private _attributes;
  11591. private _uniforms;
  11592. /**
  11593. * Key for the effect.
  11594. */
  11595. _key: string;
  11596. private _indexParameters;
  11597. private _fallbacks;
  11598. private _vertexSourceCode;
  11599. private _fragmentSourceCode;
  11600. private _vertexSourceCodeOverride;
  11601. private _fragmentSourceCodeOverride;
  11602. private _transformFeedbackVaryings;
  11603. /**
  11604. * Compiled shader to webGL program.
  11605. */
  11606. _program: WebGLProgram;
  11607. private _valueCache;
  11608. private static _baseCache;
  11609. /**
  11610. * Instantiates an effect.
  11611. * An effect can be used to create/manage/execute vertex and fragment shaders.
  11612. * @param baseName Name of the effect.
  11613. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  11614. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  11615. * @param samplers List of sampler variables that will be passed to the shader.
  11616. * @param engine Engine to be used to render the effect
  11617. * @param defines Define statements to be added to the shader.
  11618. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  11619. * @param onCompiled Callback that will be called when the shader is compiled.
  11620. * @param onError Callback that will be called if an error occurs during shader compilation.
  11621. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  11622. */
  11623. 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);
  11624. /**
  11625. * Unique key for this effect
  11626. */
  11627. readonly key: string;
  11628. /**
  11629. * If the effect has been compiled and prepared.
  11630. * @returns if the effect is compiled and prepared.
  11631. */
  11632. isReady(): boolean;
  11633. /**
  11634. * The engine the effect was initialized with.
  11635. * @returns the engine.
  11636. */
  11637. getEngine(): Engine;
  11638. /**
  11639. * The compiled webGL program for the effect
  11640. * @returns the webGL program.
  11641. */
  11642. getProgram(): WebGLProgram;
  11643. /**
  11644. * The set of names of attribute variables for the shader.
  11645. * @returns An array of attribute names.
  11646. */
  11647. getAttributesNames(): string[];
  11648. /**
  11649. * Returns the attribute at the given index.
  11650. * @param index The index of the attribute.
  11651. * @returns The location of the attribute.
  11652. */
  11653. getAttributeLocation(index: number): number;
  11654. /**
  11655. * Returns the attribute based on the name of the variable.
  11656. * @param name of the attribute to look up.
  11657. * @returns the attribute location.
  11658. */
  11659. getAttributeLocationByName(name: string): number;
  11660. /**
  11661. * The number of attributes.
  11662. * @returns the numnber of attributes.
  11663. */
  11664. getAttributesCount(): number;
  11665. /**
  11666. * Gets the index of a uniform variable.
  11667. * @param uniformName of the uniform to look up.
  11668. * @returns the index.
  11669. */
  11670. getUniformIndex(uniformName: string): number;
  11671. /**
  11672. * Returns the attribute based on the name of the variable.
  11673. * @param uniformName of the uniform to look up.
  11674. * @returns the location of the uniform.
  11675. */
  11676. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  11677. /**
  11678. * Returns an array of sampler variable names
  11679. * @returns The array of sampler variable neames.
  11680. */
  11681. getSamplers(): string[];
  11682. /**
  11683. * The error from the last compilation.
  11684. * @returns the error string.
  11685. */
  11686. getCompilationError(): string;
  11687. /**
  11688. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  11689. * @param func The callback to be used.
  11690. */
  11691. executeWhenCompiled(func: (effect: Effect) => void): void;
  11692. /** @ignore */
  11693. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  11694. /** @ignore */
  11695. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  11696. private _dumpShadersSource(vertexCode, fragmentCode, defines);
  11697. private _processShaderConversion(sourceCode, isFragment, callback);
  11698. private _processIncludes(sourceCode, callback);
  11699. private _processPrecision(source);
  11700. /**
  11701. * Recompiles the webGL program
  11702. * @param vertexSourceCode The source code for the vertex shader.
  11703. * @param fragmentSourceCode The source code for the fragment shader.
  11704. * @param onCompiled Callback called when completed.
  11705. * @param onError Callback called on error.
  11706. */
  11707. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void): void;
  11708. /**
  11709. * Gets the uniform locations of the the specified variable names
  11710. * @param names THe names of the variables to lookup.
  11711. * @returns Array of locations in the same order as variable names.
  11712. */
  11713. getSpecificUniformLocations(names: string[]): Nullable<WebGLUniformLocation>[];
  11714. /**
  11715. * Prepares the effect
  11716. */
  11717. _prepareEffect(): void;
  11718. /**
  11719. * Checks if the effect is supported. (Must be called after compilation)
  11720. */
  11721. readonly isSupported: boolean;
  11722. /**
  11723. * Binds a texture to the engine to be used as output of the shader.
  11724. * @param channel Name of the output variable.
  11725. * @param texture Texture to bind.
  11726. */
  11727. _bindTexture(channel: string, texture: InternalTexture): void;
  11728. /**
  11729. * Sets a texture on the engine to be used in the shader.
  11730. * @param channel Name of the sampler variable.
  11731. * @param texture Texture to set.
  11732. */
  11733. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  11734. /**
  11735. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  11736. * @param channel Name of the sampler variable.
  11737. * @param texture Texture to set.
  11738. */
  11739. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  11740. /**
  11741. * Sets an array of textures on the engine to be used in the shader.
  11742. * @param channel Name of the variable.
  11743. * @param textures Textures to set.
  11744. */
  11745. setTextureArray(channel: string, textures: BaseTexture[]): void;
  11746. /**
  11747. * 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)
  11748. * @param channel Name of the sampler variable.
  11749. * @param postProcess Post process to get the input texture from.
  11750. */
  11751. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  11752. /**
  11753. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  11754. * Sets the input texture of the passed in post process to be input of this effect. (To use the output of the passed in post process use setTextureFromPostProcessOutput)
  11755. * @param channel Name of the sampler variable.
  11756. * @param postProcess Post process to get the output texture from.
  11757. */
  11758. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  11759. /** @ignore */
  11760. _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  11761. /** @ignore */
  11762. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  11763. /** @ignore */
  11764. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  11765. /** @ignore */
  11766. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  11767. /**
  11768. * Binds a buffer to a uniform.
  11769. * @param buffer Buffer to bind.
  11770. * @param name Name of the uniform variable to bind to.
  11771. */
  11772. bindUniformBuffer(buffer: WebGLBuffer, name: string): void;
  11773. /**
  11774. * Binds block to a uniform.
  11775. * @param blockName Name of the block to bind.
  11776. * @param index Index to bind.
  11777. */
  11778. bindUniformBlock(blockName: string, index: number): void;
  11779. /**
  11780. * Sets an interger value on a uniform variable.
  11781. * @param uniformName Name of the variable.
  11782. * @param value Value to be set.
  11783. * @returns this effect.
  11784. */
  11785. setInt(uniformName: string, value: number): Effect;
  11786. /**
  11787. * Sets an int array on a uniform variable.
  11788. * @param uniformName Name of the variable.
  11789. * @param array array to be set.
  11790. * @returns this effect.
  11791. */
  11792. setIntArray(uniformName: string, array: Int32Array): Effect;
  11793. /**
  11794. * 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)
  11795. * @param uniformName Name of the variable.
  11796. * @param array array to be set.
  11797. * @returns this effect.
  11798. */
  11799. setIntArray2(uniformName: string, array: Int32Array): Effect;
  11800. /**
  11801. * 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)
  11802. * @param uniformName Name of the variable.
  11803. * @param array array to be set.
  11804. * @returns this effect.
  11805. */
  11806. setIntArray3(uniformName: string, array: Int32Array): Effect;
  11807. /**
  11808. * 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)
  11809. * @param uniformName Name of the variable.
  11810. * @param array array to be set.
  11811. * @returns this effect.
  11812. */
  11813. setIntArray4(uniformName: string, array: Int32Array): Effect;
  11814. /**
  11815. * Sets an float array on a uniform variable.
  11816. * @param uniformName Name of the variable.
  11817. * @param array array to be set.
  11818. * @returns this effect.
  11819. */
  11820. setFloatArray(uniformName: string, array: Float32Array): Effect;
  11821. /**
  11822. * 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)
  11823. * @param uniformName Name of the variable.
  11824. * @param array array to be set.
  11825. * @returns this effect.
  11826. */
  11827. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  11828. /**
  11829. * 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)
  11830. * @param uniformName Name of the variable.
  11831. * @param array array to be set.
  11832. * @returns this effect.
  11833. */
  11834. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  11835. /**
  11836. * 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)
  11837. * @param uniformName Name of the variable.
  11838. * @param array array to be set.
  11839. * @returns this effect.
  11840. */
  11841. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  11842. /**
  11843. * Sets an array on a uniform variable.
  11844. * @param uniformName Name of the variable.
  11845. * @param array array to be set.
  11846. * @returns this effect.
  11847. */
  11848. setArray(uniformName: string, array: number[]): Effect;
  11849. /**
  11850. * 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)
  11851. * @param uniformName Name of the variable.
  11852. * @param array array to be set.
  11853. * @returns this effect.
  11854. */
  11855. setArray2(uniformName: string, array: number[]): Effect;
  11856. /**
  11857. * 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)
  11858. * @param uniformName Name of the variable.
  11859. * @param array array to be set.
  11860. * @returns this effect.
  11861. */
  11862. setArray3(uniformName: string, array: number[]): Effect;
  11863. /**
  11864. * 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)
  11865. * @param uniformName Name of the variable.
  11866. * @param array array to be set.
  11867. * @returns this effect.
  11868. */
  11869. setArray4(uniformName: string, array: number[]): Effect;
  11870. /**
  11871. * Sets matrices on a uniform variable.
  11872. * @param uniformName Name of the variable.
  11873. * @param matrices matrices to be set.
  11874. * @returns this effect.
  11875. */
  11876. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  11877. /**
  11878. * Sets matrix on a uniform variable.
  11879. * @param uniformName Name of the variable.
  11880. * @param matrix matrix to be set.
  11881. * @returns this effect.
  11882. */
  11883. setMatrix(uniformName: string, matrix: Matrix): Effect;
  11884. /**
  11885. * 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)
  11886. * @param uniformName Name of the variable.
  11887. * @param matrix matrix to be set.
  11888. * @returns this effect.
  11889. */
  11890. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  11891. /**
  11892. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  11893. * @param uniformName Name of the variable.
  11894. * @param matrix matrix to be set.
  11895. * @returns this effect.
  11896. */
  11897. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  11898. /**
  11899. * Sets a float on a uniform variable.
  11900. * @param uniformName Name of the variable.
  11901. * @param value value to be set.
  11902. * @returns this effect.
  11903. */
  11904. setFloat(uniformName: string, value: number): Effect;
  11905. /**
  11906. * Sets a boolean on a uniform variable.
  11907. * @param uniformName Name of the variable.
  11908. * @param bool value to be set.
  11909. * @returns this effect.
  11910. */
  11911. setBool(uniformName: string, bool: boolean): Effect;
  11912. /**
  11913. * Sets a Vector2 on a uniform variable.
  11914. * @param uniformName Name of the variable.
  11915. * @param vector2 vector2 to be set.
  11916. * @returns this effect.
  11917. */
  11918. setVector2(uniformName: string, vector2: Vector2): Effect;
  11919. /**
  11920. * Sets a float2 on a uniform variable.
  11921. * @param uniformName Name of the variable.
  11922. * @param x First float in float2.
  11923. * @param y Second float in float2.
  11924. * @returns this effect.
  11925. */
  11926. setFloat2(uniformName: string, x: number, y: number): Effect;
  11927. /**
  11928. * Sets a Vector3 on a uniform variable.
  11929. * @param uniformName Name of the variable.
  11930. * @param vector3 Value to be set.
  11931. * @returns this effect.
  11932. */
  11933. setVector3(uniformName: string, vector3: Vector3): Effect;
  11934. /**
  11935. * Sets a float3 on a uniform variable.
  11936. * @param uniformName Name of the variable.
  11937. * @param x First float in float3.
  11938. * @param y Second float in float3.
  11939. * @param z Third float in float3.
  11940. * @returns this effect.
  11941. */
  11942. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  11943. /**
  11944. * Sets a Vector4 on a uniform variable.
  11945. * @param uniformName Name of the variable.
  11946. * @param vector4 Value to be set.
  11947. * @returns this effect.
  11948. */
  11949. setVector4(uniformName: string, vector4: Vector4): Effect;
  11950. /**
  11951. * Sets a float4 on a uniform variable.
  11952. * @param uniformName Name of the variable.
  11953. * @param x First float in float4.
  11954. * @param y Second float in float4.
  11955. * @param z Third float in float4.
  11956. * @param w Fourth float in float4.
  11957. * @returns this effect.
  11958. */
  11959. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  11960. /**
  11961. * Sets a Color3 on a uniform variable.
  11962. * @param uniformName Name of the variable.
  11963. * @param color3 Value to be set.
  11964. * @returns this effect.
  11965. */
  11966. setColor3(uniformName: string, color3: Color3): Effect;
  11967. /**
  11968. * Sets a Color4 on a uniform variable.
  11969. * @param uniformName Name of the variable.
  11970. * @param color3 Value to be set.
  11971. * @param alpha Alpha value to be set.
  11972. * @returns this effect.
  11973. */
  11974. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  11975. /**
  11976. * Sets a Color4 on a uniform variable
  11977. * @param uniformName defines the name of the variable
  11978. * @param color4 defines the value to be set
  11979. * @returns this effect.
  11980. */
  11981. setDirectColor4(uniformName: string, color4: Color4): Effect;
  11982. /**
  11983. * Store of each shader (The can be looked up using effect.key)
  11984. */
  11985. static ShadersStore: {
  11986. [key: string]: string;
  11987. };
  11988. /**
  11989. * Store of each included file for a shader (The can be looked up using effect.key)
  11990. */
  11991. static IncludesShadersStore: {
  11992. [key: string]: string;
  11993. };
  11994. /**
  11995. * Resets the cache of effects.
  11996. */
  11997. static ResetCache(): void;
  11998. }
  11999. }
  12000. declare module BABYLON {
  12001. class FresnelParameters {
  12002. private _isEnabled;
  12003. isEnabled: boolean;
  12004. leftColor: Color3;
  12005. rightColor: Color3;
  12006. bias: number;
  12007. power: number;
  12008. clone(): FresnelParameters;
  12009. serialize(): any;
  12010. static Parse(parsedFresnelParameters: any): FresnelParameters;
  12011. }
  12012. }
  12013. declare module BABYLON {
  12014. /**
  12015. * Interface to follow in your material defines to integrate easily the
  12016. * Image proccessing functions.
  12017. * @ignore
  12018. */
  12019. interface IImageProcessingConfigurationDefines {
  12020. IMAGEPROCESSING: boolean;
  12021. VIGNETTE: boolean;
  12022. VIGNETTEBLENDMODEMULTIPLY: boolean;
  12023. VIGNETTEBLENDMODEOPAQUE: boolean;
  12024. TONEMAPPING: boolean;
  12025. CONTRAST: boolean;
  12026. EXPOSURE: boolean;
  12027. COLORCURVES: boolean;
  12028. COLORGRADING: boolean;
  12029. COLORGRADING3D: boolean;
  12030. SAMPLER3DGREENDEPTH: boolean;
  12031. SAMPLER3DBGRMAP: boolean;
  12032. IMAGEPROCESSINGPOSTPROCESS: boolean;
  12033. }
  12034. /**
  12035. * This groups together the common properties used for image processing either in direct forward pass
  12036. * or through post processing effect depending on the use of the image processing pipeline in your scene
  12037. * or not.
  12038. */
  12039. class ImageProcessingConfiguration {
  12040. /**
  12041. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  12042. */
  12043. colorCurves: Nullable<ColorCurves>;
  12044. private _colorCurvesEnabled;
  12045. /**
  12046. * Gets wether the color curves effect is enabled.
  12047. */
  12048. /**
  12049. * Sets wether the color curves effect is enabled.
  12050. */
  12051. colorCurvesEnabled: boolean;
  12052. /**
  12053. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  12054. */
  12055. colorGradingTexture: Nullable<BaseTexture>;
  12056. private _colorGradingEnabled;
  12057. /**
  12058. * Gets wether the color grading effect is enabled.
  12059. */
  12060. /**
  12061. * Sets wether the color grading effect is enabled.
  12062. */
  12063. colorGradingEnabled: boolean;
  12064. private _colorGradingWithGreenDepth;
  12065. /**
  12066. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  12067. */
  12068. /**
  12069. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  12070. */
  12071. colorGradingWithGreenDepth: boolean;
  12072. private _colorGradingBGR;
  12073. /**
  12074. * Gets wether the color grading texture contains BGR values.
  12075. */
  12076. /**
  12077. * Sets wether the color grading texture contains BGR values.
  12078. */
  12079. colorGradingBGR: boolean;
  12080. _exposure: number;
  12081. /**
  12082. * Gets the Exposure used in the effect.
  12083. */
  12084. /**
  12085. * Sets the Exposure used in the effect.
  12086. */
  12087. exposure: number;
  12088. private _toneMappingEnabled;
  12089. /**
  12090. * Gets wether the tone mapping effect is enabled.
  12091. */
  12092. /**
  12093. * Sets wether the tone mapping effect is enabled.
  12094. */
  12095. toneMappingEnabled: boolean;
  12096. protected _contrast: number;
  12097. /**
  12098. * Gets the contrast used in the effect.
  12099. */
  12100. /**
  12101. * Sets the contrast used in the effect.
  12102. */
  12103. contrast: number;
  12104. /**
  12105. * Vignette stretch size.
  12106. */
  12107. vignetteStretch: number;
  12108. /**
  12109. * Vignette centre X Offset.
  12110. */
  12111. vignetteCentreX: number;
  12112. /**
  12113. * Vignette centre Y Offset.
  12114. */
  12115. vignetteCentreY: number;
  12116. /**
  12117. * Vignette weight or intensity of the vignette effect.
  12118. */
  12119. vignetteWeight: number;
  12120. /**
  12121. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  12122. * if vignetteEnabled is set to true.
  12123. */
  12124. vignetteColor: Color4;
  12125. /**
  12126. * Camera field of view used by the Vignette effect.
  12127. */
  12128. vignetteCameraFov: number;
  12129. private _vignetteBlendMode;
  12130. /**
  12131. * Gets the vignette blend mode allowing different kind of effect.
  12132. */
  12133. /**
  12134. * Sets the vignette blend mode allowing different kind of effect.
  12135. */
  12136. vignetteBlendMode: number;
  12137. private _vignetteEnabled;
  12138. /**
  12139. * Gets wether the vignette effect is enabled.
  12140. */
  12141. /**
  12142. * Sets wether the vignette effect is enabled.
  12143. */
  12144. vignetteEnabled: boolean;
  12145. private _applyByPostProcess;
  12146. /**
  12147. * Gets wether the image processing is applied through a post process or not.
  12148. */
  12149. /**
  12150. * Sets wether the image processing is applied through a post process or not.
  12151. */
  12152. applyByPostProcess: boolean;
  12153. private _isEnabled;
  12154. /**
  12155. * Gets wether the image processing is enabled or not.
  12156. */
  12157. /**
  12158. * Sets wether the image processing is enabled or not.
  12159. */
  12160. isEnabled: boolean;
  12161. /**
  12162. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  12163. */
  12164. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  12165. /**
  12166. * Method called each time the image processing information changes requires to recompile the effect.
  12167. */
  12168. protected _updateParameters(): void;
  12169. getClassName(): string;
  12170. /**
  12171. * Prepare the list of uniforms associated with the Image Processing effects.
  12172. * @param uniformsList The list of uniforms used in the effect
  12173. * @param defines the list of defines currently in use
  12174. */
  12175. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  12176. /**
  12177. * Prepare the list of samplers associated with the Image Processing effects.
  12178. * @param uniformsList The list of uniforms used in the effect
  12179. * @param defines the list of defines currently in use
  12180. */
  12181. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  12182. /**
  12183. * Prepare the list of defines associated to the shader.
  12184. * @param defines the list of defines to complete
  12185. */
  12186. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  12187. /**
  12188. * Returns true if all the image processing information are ready.
  12189. */
  12190. isReady(): boolean;
  12191. /**
  12192. * Binds the image processing to the shader.
  12193. * @param effect The effect to bind to
  12194. */
  12195. bind(effect: Effect, aspectRatio?: number): void;
  12196. /**
  12197. * Clones the current image processing instance.
  12198. * @return The cloned image processing
  12199. */
  12200. clone(): ImageProcessingConfiguration;
  12201. /**
  12202. * Serializes the current image processing instance to a json representation.
  12203. * @return a JSON representation
  12204. */
  12205. serialize(): any;
  12206. /**
  12207. * Parses the image processing from a json representation.
  12208. * @param source the JSON source to parse
  12209. * @return The parsed image processing
  12210. */
  12211. static Parse(source: any): ImageProcessingConfiguration;
  12212. private static _VIGNETTEMODE_MULTIPLY;
  12213. private static _VIGNETTEMODE_OPAQUE;
  12214. /**
  12215. * Used to apply the vignette as a mix with the pixel color.
  12216. */
  12217. static readonly VIGNETTEMODE_MULTIPLY: number;
  12218. /**
  12219. * Used to apply the vignette as a replacement of the pixel color.
  12220. */
  12221. static readonly VIGNETTEMODE_OPAQUE: number;
  12222. }
  12223. }
  12224. declare module BABYLON {
  12225. /**
  12226. * Manages the defines for the Material.
  12227. */
  12228. class MaterialDefines {
  12229. private _keys;
  12230. private _isDirty;
  12231. _renderId: number;
  12232. _areLightsDirty: boolean;
  12233. _areAttributesDirty: boolean;
  12234. _areTexturesDirty: boolean;
  12235. _areFresnelDirty: boolean;
  12236. _areMiscDirty: boolean;
  12237. _areImageProcessingDirty: boolean;
  12238. _normals: boolean;
  12239. _uvs: boolean;
  12240. _needNormals: boolean;
  12241. _needUVs: boolean;
  12242. /**
  12243. * Specifies if the material needs to be re-calculated.
  12244. */
  12245. readonly isDirty: boolean;
  12246. /**
  12247. * Marks the material to indicate that it has been re-calculated.
  12248. */
  12249. markAsProcessed(): void;
  12250. /**
  12251. * Marks the material to indicate that it needs to be re-calculated.
  12252. */
  12253. markAsUnprocessed(): void;
  12254. /**
  12255. * Marks the material to indicate all of its defines need to be re-calculated.
  12256. */
  12257. markAllAsDirty(): void;
  12258. /**
  12259. * Marks the material to indicate that image processing needs to be re-calculated.
  12260. */
  12261. markAsImageProcessingDirty(): void;
  12262. /**
  12263. * Marks the material to indicate the lights need to be re-calculated.
  12264. */
  12265. markAsLightDirty(): void;
  12266. /**
  12267. * Marks the attribute state as changed.
  12268. */
  12269. markAsAttributesDirty(): void;
  12270. /**
  12271. * Marks the texture state as changed.
  12272. */
  12273. markAsTexturesDirty(): void;
  12274. /**
  12275. * Marks the fresnel state as changed.
  12276. */
  12277. markAsFresnelDirty(): void;
  12278. /**
  12279. * Marks the misc state as changed.
  12280. */
  12281. markAsMiscDirty(): void;
  12282. /**
  12283. * Rebuilds the material defines.
  12284. */
  12285. rebuild(): void;
  12286. /**
  12287. * Specifies if two material defines are equal.
  12288. * @param other - A material define instance to compare to.
  12289. * @returns - Boolean indicating if the material defines are equal (true) or not (false).
  12290. */
  12291. isEqual(other: MaterialDefines): boolean;
  12292. /**
  12293. * Clones this instance's defines to another instance.
  12294. * @param other - material defines to clone values to.
  12295. */
  12296. cloneTo(other: MaterialDefines): void;
  12297. /**
  12298. * Resets the material define values.
  12299. */
  12300. reset(): void;
  12301. /**
  12302. * Converts the material define values to a string.
  12303. * @returns - String of material define information.
  12304. */
  12305. toString(): string;
  12306. }
  12307. /**
  12308. * This offers the main features of a material in BJS.
  12309. */
  12310. class Material implements IAnimatable {
  12311. private static _TriangleFillMode;
  12312. private static _WireFrameFillMode;
  12313. private static _PointFillMode;
  12314. private static _PointListDrawMode;
  12315. private static _LineListDrawMode;
  12316. private static _LineLoopDrawMode;
  12317. private static _LineStripDrawMode;
  12318. private static _TriangleStripDrawMode;
  12319. private static _TriangleFanDrawMode;
  12320. /**
  12321. * Returns the triangle fill mode.
  12322. */
  12323. static readonly TriangleFillMode: number;
  12324. /**
  12325. * Returns the wireframe mode.
  12326. */
  12327. static readonly WireFrameFillMode: number;
  12328. /**
  12329. * Returns the point fill mode.
  12330. */
  12331. static readonly PointFillMode: number;
  12332. /**
  12333. * Returns the point list draw mode.
  12334. */
  12335. static readonly PointListDrawMode: number;
  12336. /**
  12337. * Returns the line list draw mode.
  12338. */
  12339. static readonly LineListDrawMode: number;
  12340. /**
  12341. * Returns the line loop draw mode.
  12342. */
  12343. static readonly LineLoopDrawMode: number;
  12344. /**
  12345. * Returns the line strip draw mode.
  12346. */
  12347. static readonly LineStripDrawMode: number;
  12348. /**
  12349. * Returns the triangle strip draw mode.
  12350. */
  12351. static readonly TriangleStripDrawMode: number;
  12352. /**
  12353. * Returns the triangle fan draw mode.
  12354. */
  12355. static readonly TriangleFanDrawMode: number;
  12356. /**
  12357. * Stores the clock-wise side orientation.
  12358. */
  12359. private static _ClockWiseSideOrientation;
  12360. /**
  12361. * Stores the counter clock-wise side orientation.
  12362. */
  12363. private static _CounterClockWiseSideOrientation;
  12364. /**
  12365. * Returns the clock-wise side orientation.
  12366. */
  12367. static readonly ClockWiseSideOrientation: number;
  12368. /**
  12369. * Returns the counter clock-wise side orientation.
  12370. */
  12371. static readonly CounterClockWiseSideOrientation: number;
  12372. /**
  12373. * The dirty texture flag value.
  12374. */
  12375. private static _TextureDirtyFlag;
  12376. /**
  12377. * The dirty light flag value.
  12378. */
  12379. private static _LightDirtyFlag;
  12380. /**
  12381. * The dirty fresnel flag value.
  12382. */
  12383. private static _FresnelDirtyFlag;
  12384. /**
  12385. * The dirty attribute flag value.
  12386. */
  12387. private static _AttributesDirtyFlag;
  12388. /**
  12389. * The dirty misc flag value.
  12390. */
  12391. private static _MiscDirtyFlag;
  12392. /**
  12393. * Returns the dirty texture flag value.
  12394. */
  12395. static readonly TextureDirtyFlag: number;
  12396. /**
  12397. * Returns the dirty light flag value.
  12398. */
  12399. static readonly LightDirtyFlag: number;
  12400. /**
  12401. * Returns the dirty fresnel flag value.
  12402. */
  12403. static readonly FresnelDirtyFlag: number;
  12404. /**
  12405. * Returns the dirty attributes flag value.
  12406. */
  12407. static readonly AttributesDirtyFlag: number;
  12408. /**
  12409. * Returns the dirty misc flag value.
  12410. */
  12411. static readonly MiscDirtyFlag: number;
  12412. /**
  12413. * The ID of the material.
  12414. */
  12415. id: string;
  12416. /**
  12417. * The name of the material.
  12418. */
  12419. name: string;
  12420. /**
  12421. * Specifies if the ready state should be checked on each call.
  12422. */
  12423. checkReadyOnEveryCall: boolean;
  12424. /**
  12425. * Specifies if the ready state should be checked once.
  12426. */
  12427. checkReadyOnlyOnce: boolean;
  12428. /**
  12429. * The state of the material.
  12430. */
  12431. state: string;
  12432. /**
  12433. * The alpha value of the material.
  12434. */
  12435. protected _alpha: number;
  12436. /**
  12437. * Gets the alpha value of the material.
  12438. */
  12439. /**
  12440. * Sets the alpha value of the material.
  12441. */
  12442. alpha: number;
  12443. /**
  12444. * Specifies if back face culling is enabled.
  12445. */
  12446. protected _backFaceCulling: boolean;
  12447. /**
  12448. * Gets the back-face culling state.
  12449. */
  12450. /**
  12451. * Sets the back-face culling state.
  12452. */
  12453. backFaceCulling: boolean;
  12454. /**
  12455. * Stores the value for side orientation.
  12456. */
  12457. sideOrientation: number;
  12458. /**
  12459. * Callback triggered when the material is compiled.
  12460. */
  12461. onCompiled: (effect: Effect) => void;
  12462. /**
  12463. * Callback triggered when an error occurs.
  12464. */
  12465. onError: (effect: Effect, errors: string) => void;
  12466. /**
  12467. * Callback triggered to get the render target textures.
  12468. */
  12469. getRenderTargetTextures: () => SmartArray<RenderTargetTexture>;
  12470. /**
  12471. * Specifies if the material should be serialized.
  12472. */
  12473. doNotSerialize: boolean;
  12474. /**
  12475. * Specifies if the effect should be stored on sub meshes.
  12476. */
  12477. storeEffectOnSubMeshes: boolean;
  12478. /**
  12479. * Stores the animations for the material.
  12480. */
  12481. animations: Array<Animation>;
  12482. /**
  12483. * An event triggered when the material is disposed.
  12484. */
  12485. onDisposeObservable: Observable<Material>;
  12486. /**
  12487. * An observer which watches for dispose events.
  12488. */
  12489. private _onDisposeObserver;
  12490. /**
  12491. * Called during a dispose event.
  12492. */
  12493. onDispose: () => void;
  12494. /**
  12495. * An event triggered when the material is bound.
  12496. */
  12497. onBindObservable: Observable<AbstractMesh>;
  12498. /**
  12499. * An observer which watches for bind events.
  12500. */
  12501. private _onBindObserver;
  12502. /**
  12503. * Called during a bind event.
  12504. */
  12505. onBind: (Mesh: AbstractMesh) => void;
  12506. /**
  12507. * An event triggered when the material is unbound.
  12508. */
  12509. onUnBindObservable: Observable<Material>;
  12510. /**
  12511. * Stores the value of the alpha mode.
  12512. */
  12513. private _alphaMode;
  12514. /**
  12515. * Gets the value of the alpha mode.
  12516. */
  12517. /**
  12518. * Sets the value of the alpha mode.
  12519. *
  12520. * | Value | Type | Description |
  12521. * | --- | --- | --- |
  12522. * | 0 | ALPHA_DISABLE | |
  12523. * | 1 | ALPHA_ADD | |
  12524. * | 2 | ALPHA_COMBINE | |
  12525. * | 3 | ALPHA_SUBTRACT | |
  12526. * | 4 | ALPHA_MULTIPLY | |
  12527. * | 5 | ALPHA_MAXIMIZED | |
  12528. * | 6 | ALPHA_ONEONE | |
  12529. * | 7 | ALPHA_PREMULTIPLIED | |
  12530. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  12531. * | 9 | ALPHA_INTERPOLATE | |
  12532. * | 10 | ALPHA_SCREENMODE | |
  12533. *
  12534. */
  12535. alphaMode: number;
  12536. /**
  12537. * Stores the state of the need depth pre-pass value.
  12538. */
  12539. private _needDepthPrePass;
  12540. /**
  12541. * Gets the depth pre-pass value.
  12542. */
  12543. /**
  12544. * Sets the need depth pre-pass value.
  12545. */
  12546. needDepthPrePass: boolean;
  12547. /**
  12548. * Specifies if depth writing should be disabled.
  12549. */
  12550. disableDepthWrite: boolean;
  12551. /**
  12552. * Specifies if depth writing should be forced.
  12553. */
  12554. forceDepthWrite: boolean;
  12555. /**
  12556. * Specifies if there should be a separate pass for culling.
  12557. */
  12558. separateCullingPass: boolean;
  12559. /**
  12560. * Stores the state specifing if fog should be enabled.
  12561. */
  12562. private _fogEnabled;
  12563. /**
  12564. * Gets the value of the fog enabled state.
  12565. */
  12566. /**
  12567. * Sets the state for enabling fog.
  12568. */
  12569. fogEnabled: boolean;
  12570. /**
  12571. * Stores the size of points.
  12572. */
  12573. pointSize: number;
  12574. /**
  12575. * Stores the z offset value.
  12576. */
  12577. zOffset: number;
  12578. /**
  12579. * Gets a value specifying if wireframe mode is enabled.
  12580. */
  12581. /**
  12582. * Sets the state of wireframe mode.
  12583. */
  12584. wireframe: boolean;
  12585. /**
  12586. * Gets the value specifying if point clouds are enabled.
  12587. */
  12588. /**
  12589. * Sets the state of point cloud mode.
  12590. */
  12591. pointsCloud: boolean;
  12592. /**
  12593. * Gets the material fill mode.
  12594. */
  12595. /**
  12596. * Sets the material fill mode.
  12597. */
  12598. fillMode: number;
  12599. /**
  12600. * Stores the effects for the material.
  12601. */
  12602. _effect: Nullable<Effect>;
  12603. /**
  12604. * Specifies if the material was previously ready.
  12605. */
  12606. _wasPreviouslyReady: boolean;
  12607. /**
  12608. * Specifies if uniform buffers should be used.
  12609. */
  12610. private _useUBO;
  12611. /**
  12612. * Stores a reference to the scene.
  12613. */
  12614. private _scene;
  12615. /**
  12616. * Stores the fill mode state.
  12617. */
  12618. private _fillMode;
  12619. /**
  12620. * Specifies if the depth write state should be cached.
  12621. */
  12622. private _cachedDepthWriteState;
  12623. /**
  12624. * Stores the uniform buffer.
  12625. */
  12626. protected _uniformBuffer: UniformBuffer;
  12627. /**
  12628. * Creates a material instance.
  12629. * @param name - The name of the material.
  12630. * @param scene - The BJS scene to reference.
  12631. * @param doNotAdd - Specifies if the material should be added to the scene.
  12632. */
  12633. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  12634. /**
  12635. * @param {boolean} fullDetails - support for multiple levels of logging within scene loading
  12636. * subclasses should override adding information pertainent to themselves.
  12637. * @returns - String with material information.
  12638. */
  12639. toString(fullDetails?: boolean): string;
  12640. /**
  12641. * Gets the class name of the material.
  12642. * @returns - String with the class name of the material.
  12643. */
  12644. getClassName(): string;
  12645. /**
  12646. * Specifies if updates for the material been locked.
  12647. */
  12648. readonly isFrozen: boolean;
  12649. /**
  12650. * Locks updates for the material.
  12651. */
  12652. freeze(): void;
  12653. /**
  12654. * Unlocks updates for the material.
  12655. */
  12656. unfreeze(): void;
  12657. /**
  12658. * Specifies if the material is ready to be used.
  12659. * @param mesh - BJS mesh.
  12660. * @param useInstances - Specifies if instances should be used.
  12661. * @returns - Boolean indicating if the material is ready to be used.
  12662. */
  12663. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  12664. /**
  12665. * Specifies that the submesh is ready to be used.
  12666. * @param mesh - BJS mesh.
  12667. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  12668. * @param useInstances - Specifies that instances should be used.
  12669. * @returns - boolean indicating that the submesh is ready or not.
  12670. */
  12671. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  12672. /**
  12673. * Returns the material effect.
  12674. * @returns - Nullable material effect.
  12675. */
  12676. getEffect(): Nullable<Effect>;
  12677. /**
  12678. * Returns the BJS scene.
  12679. * @returns - BJS Scene.
  12680. */
  12681. getScene(): Scene;
  12682. /**
  12683. * Specifies if the material will require alpha blending
  12684. * @returns - Boolean specifying if alpha blending is needed.
  12685. */
  12686. needAlphaBlending(): boolean;
  12687. /**
  12688. * Specifies if the mesh will require alpha blending.
  12689. * @param mesh - BJS mesh.
  12690. * @returns - Boolean specifying if alpha blending is needed for the mesh.
  12691. */
  12692. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  12693. /**
  12694. * Specifies if this material should be rendered in alpha test mode.
  12695. * @returns - Boolean specifying if an alpha test is needed.
  12696. */
  12697. needAlphaTesting(): boolean;
  12698. /**
  12699. * Gets the texture used for the alpha test.
  12700. * @returns - Nullable alpha test texture.
  12701. */
  12702. getAlphaTestTexture(): Nullable<BaseTexture>;
  12703. /**
  12704. * Marks the material to indicate that it needs to be re-calculated.
  12705. */
  12706. markDirty(): void;
  12707. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  12708. /**
  12709. * Binds the material to the mesh.
  12710. * @param world - World transformation matrix.
  12711. * @param mesh - Mesh to bind the material to.
  12712. */
  12713. bind(world: Matrix, mesh?: Mesh): void;
  12714. /**
  12715. * Binds the submesh to the material.
  12716. * @param world - World transformation matrix.
  12717. * @param mesh - Mesh containing the submesh.
  12718. * @param subMesh - Submesh to bind the material to.
  12719. */
  12720. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  12721. /**
  12722. * Binds the world matrix to the material.
  12723. * @param world - World transformation matrix.
  12724. */
  12725. bindOnlyWorldMatrix(world: Matrix): void;
  12726. /**
  12727. * Binds the scene's uniform buffer to the effect.
  12728. * @param effect - Effect to bind to the scene uniform buffer.
  12729. * @param sceneUbo - Scene uniform buffer.
  12730. */
  12731. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  12732. /**
  12733. * Binds the view matrix to the effect.
  12734. * @param effect - Effect to bind the view matrix to.
  12735. */
  12736. bindView(effect: Effect): void;
  12737. /**
  12738. * Binds the view projection matrix to the effect.
  12739. * @param effect - Effect to bind the view projection matrix to.
  12740. */
  12741. bindViewProjection(effect: Effect): void;
  12742. /**
  12743. * Specifies if material alpha testing should be turned on for the mesh.
  12744. * @param mesh - BJS mesh.
  12745. */
  12746. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  12747. /**
  12748. * Processes to execute after binding the material to a mesh.
  12749. * @param mesh - BJS mesh.
  12750. */
  12751. protected _afterBind(mesh?: Mesh): void;
  12752. /**
  12753. * Unbinds the material from the mesh.
  12754. */
  12755. unbind(): void;
  12756. /**
  12757. * Gets the active textures from the material.
  12758. * @returns - Array of textures.
  12759. */
  12760. getActiveTextures(): BaseTexture[];
  12761. /**
  12762. * Specifies if the material uses a texture.
  12763. * @param texture - Texture to check against the material.
  12764. * @returns - Boolean specifying if the material uses the texture.
  12765. */
  12766. hasTexture(texture: BaseTexture): boolean;
  12767. /**
  12768. * Makes a duplicate of the material, and gives it a new name.
  12769. * @param name - Name to call the duplicated material.
  12770. * @returns - Nullable cloned material
  12771. */
  12772. clone(name: string): Nullable<Material>;
  12773. /**
  12774. * Gets the meshes bound to the material.
  12775. * @returns - Array of meshes bound to the material.
  12776. */
  12777. getBindedMeshes(): AbstractMesh[];
  12778. /**
  12779. * Force shader compilation
  12780. * @param mesh - BJS mesh.
  12781. * @param onCompiled - function to execute once the material is compiled.
  12782. * @param options - options to pass to this function.
  12783. */
  12784. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  12785. clipPlane: boolean;
  12786. }>): void;
  12787. /**
  12788. * Force shader compilation.
  12789. * @param mesh The mesh that will use this material
  12790. * @param options Additional options for compiling the shaders
  12791. * @returns A promise that resolves when the compilation completes
  12792. */
  12793. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  12794. clipPlane: boolean;
  12795. }>): Promise<void>;
  12796. /**
  12797. * Marks a define in the material to indicate that it needs to be re-computed.
  12798. * @param flag - Material define flag.
  12799. */
  12800. markAsDirty(flag: number): void;
  12801. /**
  12802. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated.
  12803. * @param func - function which checks material defines against the submeshes.
  12804. */
  12805. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  12806. /**
  12807. * Indicates that image processing needs to be re-calculated for all submeshes.
  12808. */
  12809. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  12810. /**
  12811. * Indicates that textures need to be re-calculated for all submeshes.
  12812. */
  12813. protected _markAllSubMeshesAsTexturesDirty(): void;
  12814. /**
  12815. * Indicates that fresnel needs to be re-calculated for all submeshes.
  12816. */
  12817. protected _markAllSubMeshesAsFresnelDirty(): void;
  12818. /**
  12819. * Indicates that fresnel and misc need to be re-calculated for all submeshes.
  12820. */
  12821. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  12822. /**
  12823. * Indicates that lights need to be re-calculated for all submeshes.
  12824. */
  12825. protected _markAllSubMeshesAsLightsDirty(): void;
  12826. /**
  12827. * Indicates that attributes need to be re-calculated for all submeshes.
  12828. */
  12829. protected _markAllSubMeshesAsAttributesDirty(): void;
  12830. /**
  12831. * Indicates that misc needs to be re-calculated for all submeshes.
  12832. */
  12833. protected _markAllSubMeshesAsMiscDirty(): void;
  12834. /**
  12835. * Indicates that textures and misc need to be re-calculated for all submeshes.
  12836. */
  12837. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  12838. /**
  12839. * Disposes the material.
  12840. * @param forceDisposeEffect - Specifies if effects should be force disposed.
  12841. * @param forceDisposeTextures - Specifies if textures should be force disposed.
  12842. */
  12843. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  12844. /**
  12845. * Serializes this material.
  12846. * @returns - serialized material object.
  12847. */
  12848. serialize(): any;
  12849. /**
  12850. * Creates a MultiMaterial from parse MultiMaterial data.
  12851. * @param parsedMultiMaterial - Parsed MultiMaterial data.
  12852. * @param scene - BJS scene.
  12853. * @returns - MultiMaterial.
  12854. */
  12855. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  12856. /**
  12857. * Creates a material from parsed material data.
  12858. * @param parsedMaterial - Parsed material data.
  12859. * @param scene - BJS scene.
  12860. * @param rootUrl - Root URL containing the material information.
  12861. * @returns - Parsed material.
  12862. */
  12863. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): any;
  12864. }
  12865. }
  12866. declare module BABYLON {
  12867. /**
  12868. * "Static Class" containing the most commonly used helper while dealing with material for
  12869. * rendering purpose.
  12870. *
  12871. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  12872. *
  12873. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  12874. */
  12875. class MaterialHelper {
  12876. /**
  12877. * Bind the current view position to an effect.
  12878. * @param effect The effect to be bound
  12879. * @param scene The scene the eyes position is used from
  12880. */
  12881. static BindEyePosition(effect: Effect, scene: Scene): void;
  12882. /**
  12883. * Helps preparing the defines values about the UVs in used in the effect.
  12884. * UVs are shared as much as we can accross chanels in the shaders.
  12885. * @param texture The texture we are preparing the UVs for
  12886. * @param defines The defines to update
  12887. * @param key The chanel key "diffuse", "specular"... used in the shader
  12888. */
  12889. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  12890. /**
  12891. * Binds a texture matrix value to its corrsponding uniform
  12892. * @param texture The texture to bind the matrix for
  12893. * @param uniformBuffer The uniform buffer receivin the data
  12894. * @param key The chanel key "diffuse", "specular"... used in the shader
  12895. */
  12896. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  12897. /**
  12898. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  12899. * @param mesh defines the current mesh
  12900. * @param scene defines the current scene
  12901. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  12902. * @param pointsCloud defines if point cloud rendering has to be turned on
  12903. * @param fogEnabled defines if fog has to be turned on
  12904. * @param alphaTest defines if alpha testing has to be turned on
  12905. * @param defines defines the current list of defines
  12906. */
  12907. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  12908. /**
  12909. * Helper used to prepare the list of defines associated with frame values for shader compilation
  12910. * @param scene defines the current scene
  12911. * @param engine defines the current engine
  12912. * @param defines specifies the list of active defines
  12913. * @param useInstances defines if instances have to be turned on
  12914. * @param useClipPlane defines if clip plane have to be turned on
  12915. */
  12916. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  12917. /**
  12918. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  12919. * @param mesh The mesh containing the geometry data we will draw
  12920. * @param defines The defines to update
  12921. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  12922. * @param useBones Precise whether bones should be used or not (override mesh info)
  12923. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  12924. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  12925. * @returns false if defines are considered not dirty and have not been checked
  12926. */
  12927. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  12928. /**
  12929. * Prepares the defines related to the light information passed in parameter
  12930. * @param scene The scene we are intending to draw
  12931. * @param mesh The mesh the effect is compiling for
  12932. * @param defines The defines to update
  12933. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  12934. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  12935. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  12936. * @returns true if normals will be required for the rest of the effect
  12937. */
  12938. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  12939. /**
  12940. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  12941. * that won t be acctive due to defines being turned off.
  12942. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  12943. * @param samplersList The samplers list
  12944. * @param defines The defines helping in the list generation
  12945. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  12946. */
  12947. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  12948. /**
  12949. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  12950. * @param defines The defines to update while falling back
  12951. * @param fallbacks The authorized effect fallbacks
  12952. * @param maxSimultaneousLights The maximum number of lights allowed
  12953. * @param rank the current rank of the Effect
  12954. * @returns The newly affected rank
  12955. */
  12956. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  12957. /**
  12958. * Prepares the list of attributes required for morph targets according to the effect defines.
  12959. * @param attribs The current list of supported attribs
  12960. * @param mesh The mesh to prepare the morph targets attributes for
  12961. * @param defines The current Defines of the effect
  12962. */
  12963. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  12964. /**
  12965. * Prepares the list of attributes required for bones according to the effect defines.
  12966. * @param attribs The current list of supported attribs
  12967. * @param mesh The mesh to prepare the bones attributes for
  12968. * @param defines The current Defines of the effect
  12969. * @param fallbacks The current efffect fallback strategy
  12970. */
  12971. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  12972. /**
  12973. * Prepares the list of attributes required for instances according to the effect defines.
  12974. * @param attribs The current list of supported attribs
  12975. * @param defines The current Defines of the effect
  12976. */
  12977. static PrepareAttributesForInstances(attribs: string[], defines: any): void;
  12978. /**
  12979. * Binds the light shadow information to the effect for the given mesh.
  12980. * @param light The light containing the generator
  12981. * @param scene The scene the lights belongs to
  12982. * @param mesh The mesh we are binding the information to render
  12983. * @param lightIndex The light index in the effect used to render the mesh
  12984. * @param effect The effect we are binding the data to
  12985. */
  12986. static BindLightShadow(light: Light, scene: Scene, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  12987. /**
  12988. * Binds the light information to the effect.
  12989. * @param light The light containing the generator
  12990. * @param effect The effect we are binding the data to
  12991. * @param lightIndex The light index in the effect used to render
  12992. */
  12993. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  12994. /**
  12995. * Binds the lights information from the scene to the effect for the given mesh.
  12996. * @param scene The scene the lights belongs to
  12997. * @param mesh The mesh we are binding the information to render
  12998. * @param effect The effect we are binding the data to
  12999. * @param defines The generated defines for the effect
  13000. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  13001. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  13002. */
  13003. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  13004. /**
  13005. * Binds the fog information from the scene to the effect for the given mesh.
  13006. * @param scene The scene the lights belongs to
  13007. * @param mesh The mesh we are binding the information to render
  13008. * @param effect The effect we are binding the data to
  13009. */
  13010. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect): void;
  13011. /**
  13012. * Binds the bones information from the mesh to the effect.
  13013. * @param mesh The mesh we are binding the information to render
  13014. * @param effect The effect we are binding the data to
  13015. */
  13016. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  13017. /**
  13018. * Binds the morph targets information from the mesh to the effect.
  13019. * @param abstractMesh The mesh we are binding the information to render
  13020. * @param effect The effect we are binding the data to
  13021. */
  13022. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  13023. /**
  13024. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  13025. * @param defines The generated defines used in the effect
  13026. * @param effect The effect we are binding the data to
  13027. * @param scene The scene we are willing to render with logarithmic scale for
  13028. */
  13029. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  13030. /**
  13031. * Binds the clip plane information from the scene to the effect.
  13032. * @param scene The scene the clip plane information are extracted from
  13033. * @param effect The effect we are binding the data to
  13034. */
  13035. static BindClipPlane(effect: Effect, scene: Scene): void;
  13036. }
  13037. }
  13038. declare module BABYLON {
  13039. class MultiMaterial extends Material {
  13040. private _subMaterials;
  13041. subMaterials: Nullable<Material>[];
  13042. constructor(name: string, scene: Scene);
  13043. private _hookArray(array);
  13044. getSubMaterial(index: number): Nullable<Material>;
  13045. getActiveTextures(): BaseTexture[];
  13046. getClassName(): string;
  13047. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  13048. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  13049. serialize(): any;
  13050. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  13051. }
  13052. }
  13053. declare module BABYLON {
  13054. class PushMaterial extends Material {
  13055. protected _activeEffect: Effect;
  13056. protected _normalMatrix: Matrix;
  13057. constructor(name: string, scene: Scene);
  13058. getEffect(): Effect;
  13059. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  13060. /**
  13061. * Binds the given world matrix to the active effect
  13062. *
  13063. * @param world the matrix to bind
  13064. */
  13065. bindOnlyWorldMatrix(world: Matrix): void;
  13066. /**
  13067. * Binds the given normal matrix to the active effect
  13068. *
  13069. * @param normalMatrix the matrix to bind
  13070. */
  13071. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  13072. bind(world: Matrix, mesh?: Mesh): void;
  13073. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  13074. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  13075. }
  13076. }
  13077. declare module BABYLON {
  13078. class ShaderMaterial extends Material {
  13079. private _shaderPath;
  13080. private _options;
  13081. private _textures;
  13082. private _textureArrays;
  13083. private _floats;
  13084. private _ints;
  13085. private _floatsArrays;
  13086. private _colors3;
  13087. private _colors3Arrays;
  13088. private _colors4;
  13089. private _vectors2;
  13090. private _vectors3;
  13091. private _vectors4;
  13092. private _matrices;
  13093. private _matrices3x3;
  13094. private _matrices2x2;
  13095. private _vectors2Arrays;
  13096. private _vectors3Arrays;
  13097. private _cachedWorldViewMatrix;
  13098. private _renderId;
  13099. constructor(name: string, scene: Scene, shaderPath: any, options: any);
  13100. getClassName(): string;
  13101. needAlphaBlending(): boolean;
  13102. needAlphaTesting(): boolean;
  13103. private _checkUniform(uniformName);
  13104. setTexture(name: string, texture: Texture): ShaderMaterial;
  13105. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  13106. setFloat(name: string, value: number): ShaderMaterial;
  13107. setInt(name: string, value: number): ShaderMaterial;
  13108. setFloats(name: string, value: number[]): ShaderMaterial;
  13109. setColor3(name: string, value: Color3): ShaderMaterial;
  13110. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  13111. setColor4(name: string, value: Color4): ShaderMaterial;
  13112. setVector2(name: string, value: Vector2): ShaderMaterial;
  13113. setVector3(name: string, value: Vector3): ShaderMaterial;
  13114. setVector4(name: string, value: Vector4): ShaderMaterial;
  13115. setMatrix(name: string, value: Matrix): ShaderMaterial;
  13116. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  13117. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  13118. setArray2(name: string, value: number[]): ShaderMaterial;
  13119. setArray3(name: string, value: number[]): ShaderMaterial;
  13120. private _checkCache(scene, mesh?, useInstances?);
  13121. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  13122. bindOnlyWorldMatrix(world: Matrix): void;
  13123. bind(world: Matrix, mesh?: Mesh): void;
  13124. getActiveTextures(): BaseTexture[];
  13125. hasTexture(texture: BaseTexture): boolean;
  13126. clone(name: string): ShaderMaterial;
  13127. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  13128. serialize(): any;
  13129. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  13130. }
  13131. }
  13132. declare module BABYLON {
  13133. /** @ignore */
  13134. class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  13135. MAINUV1: boolean;
  13136. MAINUV2: boolean;
  13137. DIFFUSE: boolean;
  13138. DIFFUSEDIRECTUV: number;
  13139. AMBIENT: boolean;
  13140. AMBIENTDIRECTUV: number;
  13141. OPACITY: boolean;
  13142. OPACITYDIRECTUV: number;
  13143. OPACITYRGB: boolean;
  13144. REFLECTION: boolean;
  13145. EMISSIVE: boolean;
  13146. EMISSIVEDIRECTUV: number;
  13147. SPECULAR: boolean;
  13148. SPECULARDIRECTUV: number;
  13149. BUMP: boolean;
  13150. BUMPDIRECTUV: number;
  13151. PARALLAX: boolean;
  13152. PARALLAXOCCLUSION: boolean;
  13153. SPECULAROVERALPHA: boolean;
  13154. CLIPPLANE: boolean;
  13155. ALPHATEST: boolean;
  13156. DEPTHPREPASS: boolean;
  13157. ALPHAFROMDIFFUSE: boolean;
  13158. POINTSIZE: boolean;
  13159. FOG: boolean;
  13160. SPECULARTERM: boolean;
  13161. DIFFUSEFRESNEL: boolean;
  13162. OPACITYFRESNEL: boolean;
  13163. REFLECTIONFRESNEL: boolean;
  13164. REFRACTIONFRESNEL: boolean;
  13165. EMISSIVEFRESNEL: boolean;
  13166. FRESNEL: boolean;
  13167. NORMAL: boolean;
  13168. UV1: boolean;
  13169. UV2: boolean;
  13170. VERTEXCOLOR: boolean;
  13171. VERTEXALPHA: boolean;
  13172. NUM_BONE_INFLUENCERS: number;
  13173. BonesPerMesh: number;
  13174. INSTANCES: boolean;
  13175. GLOSSINESS: boolean;
  13176. ROUGHNESS: boolean;
  13177. EMISSIVEASILLUMINATION: boolean;
  13178. LINKEMISSIVEWITHDIFFUSE: boolean;
  13179. REFLECTIONFRESNELFROMSPECULAR: boolean;
  13180. LIGHTMAP: boolean;
  13181. LIGHTMAPDIRECTUV: number;
  13182. OBJECTSPACE_NORMALMAP: boolean;
  13183. USELIGHTMAPASSHADOWMAP: boolean;
  13184. REFLECTIONMAP_3D: boolean;
  13185. REFLECTIONMAP_SPHERICAL: boolean;
  13186. REFLECTIONMAP_PLANAR: boolean;
  13187. REFLECTIONMAP_CUBIC: boolean;
  13188. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  13189. REFLECTIONMAP_PROJECTION: boolean;
  13190. REFLECTIONMAP_SKYBOX: boolean;
  13191. REFLECTIONMAP_EXPLICIT: boolean;
  13192. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  13193. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  13194. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  13195. INVERTCUBICMAP: boolean;
  13196. LOGARITHMICDEPTH: boolean;
  13197. REFRACTION: boolean;
  13198. REFRACTIONMAP_3D: boolean;
  13199. REFLECTIONOVERALPHA: boolean;
  13200. TWOSIDEDLIGHTING: boolean;
  13201. SHADOWFLOAT: boolean;
  13202. MORPHTARGETS: boolean;
  13203. MORPHTARGETS_NORMAL: boolean;
  13204. MORPHTARGETS_TANGENT: boolean;
  13205. NUM_MORPH_INFLUENCERS: number;
  13206. NONUNIFORMSCALING: boolean;
  13207. PREMULTIPLYALPHA: boolean;
  13208. IMAGEPROCESSING: boolean;
  13209. VIGNETTE: boolean;
  13210. VIGNETTEBLENDMODEMULTIPLY: boolean;
  13211. VIGNETTEBLENDMODEOPAQUE: boolean;
  13212. TONEMAPPING: boolean;
  13213. CONTRAST: boolean;
  13214. COLORCURVES: boolean;
  13215. COLORGRADING: boolean;
  13216. COLORGRADING3D: boolean;
  13217. SAMPLER3DGREENDEPTH: boolean;
  13218. SAMPLER3DBGRMAP: boolean;
  13219. IMAGEPROCESSINGPOSTPROCESS: boolean;
  13220. EXPOSURE: boolean;
  13221. constructor();
  13222. setReflectionMode(modeToEnable: string): void;
  13223. }
  13224. class StandardMaterial extends PushMaterial {
  13225. private _diffuseTexture;
  13226. diffuseTexture: Nullable<BaseTexture>;
  13227. private _ambientTexture;
  13228. ambientTexture: Nullable<BaseTexture>;
  13229. private _opacityTexture;
  13230. opacityTexture: Nullable<BaseTexture>;
  13231. private _reflectionTexture;
  13232. reflectionTexture: Nullable<BaseTexture>;
  13233. private _emissiveTexture;
  13234. emissiveTexture: Nullable<BaseTexture>;
  13235. private _specularTexture;
  13236. specularTexture: Nullable<BaseTexture>;
  13237. private _bumpTexture;
  13238. bumpTexture: Nullable<BaseTexture>;
  13239. private _lightmapTexture;
  13240. lightmapTexture: Nullable<BaseTexture>;
  13241. private _refractionTexture;
  13242. refractionTexture: Nullable<BaseTexture>;
  13243. ambientColor: Color3;
  13244. diffuseColor: Color3;
  13245. specularColor: Color3;
  13246. emissiveColor: Color3;
  13247. specularPower: number;
  13248. private _useAlphaFromDiffuseTexture;
  13249. useAlphaFromDiffuseTexture: boolean;
  13250. private _useEmissiveAsIllumination;
  13251. useEmissiveAsIllumination: boolean;
  13252. private _linkEmissiveWithDiffuse;
  13253. linkEmissiveWithDiffuse: boolean;
  13254. private _useSpecularOverAlpha;
  13255. useSpecularOverAlpha: boolean;
  13256. private _useReflectionOverAlpha;
  13257. useReflectionOverAlpha: boolean;
  13258. private _disableLighting;
  13259. disableLighting: boolean;
  13260. private _useObjectSpaceNormalMap;
  13261. /**
  13262. * Allows using an object space normal map (instead of tangent space).
  13263. */
  13264. useObjectSpaceNormalMap: boolean;
  13265. private _useParallax;
  13266. useParallax: boolean;
  13267. private _useParallaxOcclusion;
  13268. useParallaxOcclusion: boolean;
  13269. parallaxScaleBias: number;
  13270. private _roughness;
  13271. roughness: number;
  13272. indexOfRefraction: number;
  13273. invertRefractionY: boolean;
  13274. private _useLightmapAsShadowmap;
  13275. useLightmapAsShadowmap: boolean;
  13276. private _diffuseFresnelParameters;
  13277. diffuseFresnelParameters: FresnelParameters;
  13278. private _opacityFresnelParameters;
  13279. opacityFresnelParameters: FresnelParameters;
  13280. private _reflectionFresnelParameters;
  13281. reflectionFresnelParameters: FresnelParameters;
  13282. private _refractionFresnelParameters;
  13283. refractionFresnelParameters: FresnelParameters;
  13284. private _emissiveFresnelParameters;
  13285. emissiveFresnelParameters: FresnelParameters;
  13286. private _useReflectionFresnelFromSpecular;
  13287. useReflectionFresnelFromSpecular: boolean;
  13288. private _useGlossinessFromSpecularMapAlpha;
  13289. useGlossinessFromSpecularMapAlpha: boolean;
  13290. private _maxSimultaneousLights;
  13291. maxSimultaneousLights: number;
  13292. /**
  13293. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  13294. */
  13295. private _invertNormalMapX;
  13296. invertNormalMapX: boolean;
  13297. /**
  13298. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  13299. */
  13300. private _invertNormalMapY;
  13301. invertNormalMapY: boolean;
  13302. /**
  13303. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  13304. */
  13305. private _twoSidedLighting;
  13306. twoSidedLighting: boolean;
  13307. /**
  13308. * Default configuration related to image processing available in the standard Material.
  13309. */
  13310. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  13311. /**
  13312. * Gets the image processing configuration used either in this material.
  13313. */
  13314. /**
  13315. * Sets the Default image processing configuration used either in the this material.
  13316. *
  13317. * If sets to null, the scene one is in use.
  13318. */
  13319. imageProcessingConfiguration: ImageProcessingConfiguration;
  13320. /**
  13321. * Keep track of the image processing observer to allow dispose and replace.
  13322. */
  13323. private _imageProcessingObserver;
  13324. /**
  13325. * Attaches a new image processing configuration to the Standard Material.
  13326. * @param configuration
  13327. */
  13328. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  13329. /**
  13330. * Gets wether the color curves effect is enabled.
  13331. */
  13332. /**
  13333. * Sets wether the color curves effect is enabled.
  13334. */
  13335. cameraColorCurvesEnabled: boolean;
  13336. /**
  13337. * Gets wether the color grading effect is enabled.
  13338. */
  13339. /**
  13340. * Gets wether the color grading effect is enabled.
  13341. */
  13342. cameraColorGradingEnabled: boolean;
  13343. /**
  13344. * Gets wether tonemapping is enabled or not.
  13345. */
  13346. /**
  13347. * Sets wether tonemapping is enabled or not
  13348. */
  13349. cameraToneMappingEnabled: boolean;
  13350. /**
  13351. * The camera exposure used on this material.
  13352. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  13353. * This corresponds to a photographic exposure.
  13354. */
  13355. /**
  13356. * The camera exposure used on this material.
  13357. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  13358. * This corresponds to a photographic exposure.
  13359. */
  13360. cameraExposure: number;
  13361. /**
  13362. * Gets The camera contrast used on this material.
  13363. */
  13364. /**
  13365. * Sets The camera contrast used on this material.
  13366. */
  13367. cameraContrast: number;
  13368. /**
  13369. * Gets the Color Grading 2D Lookup Texture.
  13370. */
  13371. /**
  13372. * Sets the Color Grading 2D Lookup Texture.
  13373. */
  13374. cameraColorGradingTexture: Nullable<BaseTexture>;
  13375. /**
  13376. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  13377. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  13378. * 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;
  13379. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  13380. */
  13381. /**
  13382. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  13383. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  13384. * 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;
  13385. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  13386. */
  13387. cameraColorCurves: Nullable<ColorCurves>;
  13388. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  13389. protected _renderTargets: SmartArray<RenderTargetTexture>;
  13390. protected _worldViewProjectionMatrix: Matrix;
  13391. protected _globalAmbientColor: Color3;
  13392. protected _useLogarithmicDepth: boolean;
  13393. constructor(name: string, scene: Scene);
  13394. getClassName(): string;
  13395. useLogarithmicDepth: boolean;
  13396. needAlphaBlending(): boolean;
  13397. needAlphaTesting(): boolean;
  13398. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  13399. getAlphaTestTexture(): Nullable<BaseTexture>;
  13400. /**
  13401. * Child classes can use it to update shaders
  13402. */
  13403. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  13404. buildUniformLayout(): void;
  13405. unbind(): void;
  13406. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  13407. getAnimatables(): IAnimatable[];
  13408. getActiveTextures(): BaseTexture[];
  13409. hasTexture(texture: BaseTexture): boolean;
  13410. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  13411. clone(name: string): StandardMaterial;
  13412. serialize(): any;
  13413. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  13414. static _DiffuseTextureEnabled: boolean;
  13415. static DiffuseTextureEnabled: boolean;
  13416. static _AmbientTextureEnabled: boolean;
  13417. static AmbientTextureEnabled: boolean;
  13418. static _OpacityTextureEnabled: boolean;
  13419. static OpacityTextureEnabled: boolean;
  13420. static _ReflectionTextureEnabled: boolean;
  13421. static ReflectionTextureEnabled: boolean;
  13422. static _EmissiveTextureEnabled: boolean;
  13423. static EmissiveTextureEnabled: boolean;
  13424. static _SpecularTextureEnabled: boolean;
  13425. static SpecularTextureEnabled: boolean;
  13426. static _BumpTextureEnabled: boolean;
  13427. static BumpTextureEnabled: boolean;
  13428. static _LightmapTextureEnabled: boolean;
  13429. static LightmapTextureEnabled: boolean;
  13430. static _RefractionTextureEnabled: boolean;
  13431. static RefractionTextureEnabled: boolean;
  13432. static _ColorGradingTextureEnabled: boolean;
  13433. static ColorGradingTextureEnabled: boolean;
  13434. static _FresnelEnabled: boolean;
  13435. static FresnelEnabled: boolean;
  13436. }
  13437. }
  13438. declare module BABYLON {
  13439. class UniformBuffer {
  13440. private _engine;
  13441. private _buffer;
  13442. private _data;
  13443. private _bufferData;
  13444. private _dynamic?;
  13445. private _uniformLocations;
  13446. private _uniformSizes;
  13447. private _uniformLocationPointer;
  13448. private _needSync;
  13449. private _noUBO;
  13450. private _currentEffect;
  13451. private static _MAX_UNIFORM_SIZE;
  13452. private static _tempBuffer;
  13453. /**
  13454. * Wrapper for updateUniform.
  13455. * @method updateMatrix3x3
  13456. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  13457. * @param {Float32Array} matrix
  13458. */
  13459. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  13460. /**
  13461. * Wrapper for updateUniform.
  13462. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  13463. * @param {Float32Array} matrix
  13464. */
  13465. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  13466. /**
  13467. * Wrapper for updateUniform.
  13468. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  13469. * @param {number} x
  13470. */
  13471. updateFloat: (name: string, x: number) => void;
  13472. /**
  13473. * Wrapper for updateUniform.
  13474. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  13475. * @param {number} x
  13476. * @param {number} y
  13477. * @param {string} [suffix] Suffix to add to the uniform name.
  13478. */
  13479. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  13480. /**
  13481. * Wrapper for updateUniform.
  13482. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  13483. * @param {number} x
  13484. * @param {number} y
  13485. * @param {number} z
  13486. * @param {string} [suffix] Suffix to add to the uniform name.
  13487. */
  13488. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  13489. /**
  13490. * Wrapper for updateUniform.
  13491. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  13492. * @param {number} x
  13493. * @param {number} y
  13494. * @param {number} z
  13495. * @param {number} w
  13496. * @param {string} [suffix] Suffix to add to the uniform name.
  13497. */
  13498. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  13499. /**
  13500. * Wrapper for updateUniform.
  13501. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  13502. * @param {Matrix} A 4x4 matrix.
  13503. */
  13504. updateMatrix: (name: string, mat: Matrix) => void;
  13505. /**
  13506. * Wrapper for updateUniform.
  13507. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  13508. * @param {Vector3} vector
  13509. */
  13510. updateVector3: (name: string, vector: Vector3) => void;
  13511. /**
  13512. * Wrapper for updateUniform.
  13513. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  13514. * @param {Vector4} vector
  13515. */
  13516. updateVector4: (name: string, vector: Vector4) => void;
  13517. /**
  13518. * Wrapper for updateUniform.
  13519. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  13520. * @param {Color3} color
  13521. * @param {string} [suffix] Suffix to add to the uniform name.
  13522. */
  13523. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  13524. /**
  13525. * Wrapper for updateUniform.
  13526. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  13527. * @param {Color3} color
  13528. * @param {number} alpha
  13529. * @param {string} [suffix] Suffix to add to the uniform name.
  13530. */
  13531. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  13532. /**
  13533. * Uniform buffer objects.
  13534. *
  13535. * Handles blocks of uniform on the GPU.
  13536. *
  13537. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  13538. *
  13539. * For more information, please refer to :
  13540. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  13541. */
  13542. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  13543. /**
  13544. * Indicates if the buffer is using the WebGL2 UBO implementation,
  13545. * or just falling back on setUniformXXX calls.
  13546. */
  13547. readonly useUbo: boolean;
  13548. /**
  13549. * Indicates if the WebGL underlying uniform buffer is in sync
  13550. * with the javascript cache data.
  13551. */
  13552. readonly isSync: boolean;
  13553. /**
  13554. * Indicates if the WebGL underlying uniform buffer is dynamic.
  13555. * Also, a dynamic UniformBuffer will disable cache verification and always
  13556. * update the underlying WebGL uniform buffer to the GPU.
  13557. */
  13558. isDynamic(): boolean;
  13559. /**
  13560. * The data cache on JS side.
  13561. */
  13562. getData(): Float32Array;
  13563. /**
  13564. * The underlying WebGL Uniform buffer.
  13565. */
  13566. getBuffer(): Nullable<WebGLBuffer>;
  13567. /**
  13568. * std140 layout specifies how to align data within an UBO structure.
  13569. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  13570. * for specs.
  13571. */
  13572. private _fillAlignment(size);
  13573. /**
  13574. * Adds an uniform in the buffer.
  13575. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  13576. * for the layout to be correct !
  13577. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  13578. * @param {number|number[]} size Data size, or data directly.
  13579. */
  13580. addUniform(name: string, size: number | number[]): void;
  13581. /**
  13582. * Wrapper for addUniform.
  13583. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  13584. * @param {Matrix} mat A 4x4 matrix.
  13585. */
  13586. addMatrix(name: string, mat: Matrix): void;
  13587. /**
  13588. * Wrapper for addUniform.
  13589. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  13590. * @param {number} x
  13591. * @param {number} y
  13592. */
  13593. addFloat2(name: string, x: number, y: number): void;
  13594. /**
  13595. * Wrapper for addUniform.
  13596. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  13597. * @param {number} x
  13598. * @param {number} y
  13599. * @param {number} z
  13600. */
  13601. addFloat3(name: string, x: number, y: number, z: number): void;
  13602. /**
  13603. * Wrapper for addUniform.
  13604. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  13605. * @param {Color3} color
  13606. */
  13607. addColor3(name: string, color: Color3): void;
  13608. /**
  13609. * Wrapper for addUniform.
  13610. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  13611. * @param {Color3} color
  13612. * @param {number} alpha
  13613. */
  13614. addColor4(name: string, color: Color3, alpha: number): void;
  13615. /**
  13616. * Wrapper for addUniform.
  13617. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  13618. * @param {Vector3} vector
  13619. */
  13620. addVector3(name: string, vector: Vector3): void;
  13621. /**
  13622. * Wrapper for addUniform.
  13623. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  13624. */
  13625. addMatrix3x3(name: string): void;
  13626. /**
  13627. * Wrapper for addUniform.
  13628. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  13629. */
  13630. addMatrix2x2(name: string): void;
  13631. /**
  13632. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  13633. */
  13634. create(): void;
  13635. _rebuild(): void;
  13636. /**
  13637. * Updates the WebGL Uniform Buffer on the GPU.
  13638. * If the `dynamic` flag is set to true, no cache comparison is done.
  13639. * Otherwise, the buffer will be updated only if the cache differs.
  13640. */
  13641. update(): void;
  13642. /**
  13643. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  13644. * @param {string} uniformName Name of the uniform, as used in the uniform block in the shader.
  13645. * @param {number[]|Float32Array} data Flattened data
  13646. * @param {number} size Size of the data.
  13647. */
  13648. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  13649. private _updateMatrix3x3ForUniform(name, matrix);
  13650. private _updateMatrix3x3ForEffect(name, matrix);
  13651. private _updateMatrix2x2ForEffect(name, matrix);
  13652. private _updateMatrix2x2ForUniform(name, matrix);
  13653. private _updateFloatForEffect(name, x);
  13654. private _updateFloatForUniform(name, x);
  13655. private _updateFloat2ForEffect(name, x, y, suffix?);
  13656. private _updateFloat2ForUniform(name, x, y, suffix?);
  13657. private _updateFloat3ForEffect(name, x, y, z, suffix?);
  13658. private _updateFloat3ForUniform(name, x, y, z, suffix?);
  13659. private _updateFloat4ForEffect(name, x, y, z, w, suffix?);
  13660. private _updateFloat4ForUniform(name, x, y, z, w, suffix?);
  13661. private _updateMatrixForEffect(name, mat);
  13662. private _updateMatrixForUniform(name, mat);
  13663. private _updateVector3ForEffect(name, vector);
  13664. private _updateVector3ForUniform(name, vector);
  13665. private _updateVector4ForEffect(name, vector);
  13666. private _updateVector4ForUniform(name, vector);
  13667. private _updateColor3ForEffect(name, color, suffix?);
  13668. private _updateColor3ForUniform(name, color, suffix?);
  13669. private _updateColor4ForEffect(name, color, alpha, suffix?);
  13670. private _updateColor4ForUniform(name, color, alpha, suffix?);
  13671. /**
  13672. * Sets a sampler uniform on the effect.
  13673. * @param {string} name Name of the sampler.
  13674. * @param {Texture} texture
  13675. */
  13676. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  13677. /**
  13678. * Directly updates the value of the uniform in the cache AND on the GPU.
  13679. * @param {string} uniformName Name of the uniform, as used in the uniform block in the shader.
  13680. * @param {number[]|Float32Array} data Flattened data
  13681. */
  13682. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  13683. /**
  13684. * Binds this uniform buffer to an effect.
  13685. * @param {Effect} effect
  13686. * @param {string} name Name of the uniform block in the shader.
  13687. */
  13688. bindToEffect(effect: Effect, name: string): void;
  13689. /**
  13690. * Disposes the uniform buffer.
  13691. */
  13692. dispose(): void;
  13693. }
  13694. }
  13695. declare module BABYLON {
  13696. class MorphTarget {
  13697. name: string;
  13698. animations: Animation[];
  13699. private _positions;
  13700. private _normals;
  13701. private _tangents;
  13702. private _influence;
  13703. onInfluenceChanged: Observable<boolean>;
  13704. influence: number;
  13705. constructor(name: string, influence?: number);
  13706. readonly hasPositions: boolean;
  13707. readonly hasNormals: boolean;
  13708. readonly hasTangents: boolean;
  13709. setPositions(data: Nullable<FloatArray>): void;
  13710. getPositions(): Nullable<FloatArray>;
  13711. setNormals(data: Nullable<FloatArray>): void;
  13712. getNormals(): Nullable<FloatArray>;
  13713. setTangents(data: Nullable<FloatArray>): void;
  13714. getTangents(): Nullable<FloatArray>;
  13715. /**
  13716. * Serializes the current target into a Serialization object.
  13717. * Returns the serialized object.
  13718. */
  13719. serialize(): any;
  13720. static Parse(serializationObject: any): MorphTarget;
  13721. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  13722. }
  13723. }
  13724. declare module BABYLON {
  13725. class MorphTargetManager {
  13726. private _targets;
  13727. private _targetObservable;
  13728. private _activeTargets;
  13729. private _scene;
  13730. private _influences;
  13731. private _supportsNormals;
  13732. private _supportsTangents;
  13733. private _vertexCount;
  13734. private _uniqueId;
  13735. private _tempInfluences;
  13736. constructor(scene?: Nullable<Scene>);
  13737. readonly uniqueId: number;
  13738. readonly vertexCount: number;
  13739. readonly supportsNormals: boolean;
  13740. readonly supportsTangents: boolean;
  13741. readonly numTargets: number;
  13742. readonly numInfluencers: number;
  13743. readonly influences: Float32Array;
  13744. getActiveTarget(index: number): MorphTarget;
  13745. getTarget(index: number): MorphTarget;
  13746. addTarget(target: MorphTarget): void;
  13747. removeTarget(target: MorphTarget): void;
  13748. /**
  13749. * Serializes the current manager into a Serialization object.
  13750. * Returns the serialized object.
  13751. */
  13752. serialize(): any;
  13753. private _syncActiveTargets(needUpdate);
  13754. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  13755. }
  13756. }
  13757. declare module BABYLON {
  13758. /**
  13759. * This represents a GPU particle system in Babylon
  13760. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  13761. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  13762. */
  13763. class GPUParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  13764. /**
  13765. * The id of the Particle system.
  13766. */
  13767. id: string;
  13768. /**
  13769. * The friendly name of the Particle system.
  13770. */
  13771. name: string;
  13772. /**
  13773. * The emitter represents the Mesh or position we are attaching the particle system to.
  13774. */
  13775. emitter: Nullable<AbstractMesh | Vector3>;
  13776. /**
  13777. * The rendering group used by the Particle system to chose when to render.
  13778. */
  13779. renderingGroupId: number;
  13780. /**
  13781. * The layer mask we are rendering the particles through.
  13782. */
  13783. layerMask: number;
  13784. private _capacity;
  13785. private _activeCount;
  13786. private _currentActiveCount;
  13787. private _renderEffect;
  13788. private _updateEffect;
  13789. private _buffer0;
  13790. private _buffer1;
  13791. private _spriteBuffer;
  13792. private _updateVAO;
  13793. private _renderVAO;
  13794. private _targetIndex;
  13795. private _sourceBuffer;
  13796. private _targetBuffer;
  13797. private _scene;
  13798. private _engine;
  13799. private _currentRenderId;
  13800. private _started;
  13801. private _stopped;
  13802. private _timeDelta;
  13803. private _randomTexture;
  13804. private readonly _attributesStrideSize;
  13805. private _updateEffectOptions;
  13806. private _randomTextureSize;
  13807. private _actualFrame;
  13808. /**
  13809. * List of animations used by the particle system.
  13810. */
  13811. animations: Animation[];
  13812. /**
  13813. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  13814. */
  13815. static readonly IsSupported: boolean;
  13816. /**
  13817. * An event triggered when the system is disposed.
  13818. */
  13819. onDisposeObservable: Observable<GPUParticleSystem>;
  13820. /**
  13821. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  13822. */
  13823. updateSpeed: number;
  13824. /**
  13825. * The amount of time the particle system is running (depends of the overall update speed).
  13826. */
  13827. targetStopDuration: number;
  13828. /**
  13829. * The texture used to render each particle. (this can be a spritesheet)
  13830. */
  13831. particleTexture: Nullable<Texture>;
  13832. /**
  13833. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  13834. */
  13835. blendMode: number;
  13836. /**
  13837. * Minimum life time of emitting particles.
  13838. */
  13839. minLifeTime: number;
  13840. /**
  13841. * Maximum life time of emitting particles.
  13842. */
  13843. maxLifeTime: number;
  13844. /**
  13845. * Minimum Size of emitting particles.
  13846. */
  13847. minSize: number;
  13848. /**
  13849. * Maximum Size of emitting particles.
  13850. */
  13851. maxSize: number;
  13852. /**
  13853. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  13854. */
  13855. color1: Color4;
  13856. /**
  13857. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  13858. */
  13859. color2: Color4;
  13860. /**
  13861. * Color the particle will have at the end of its lifetime.
  13862. */
  13863. colorDead: Color4;
  13864. /**
  13865. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  13866. */
  13867. emitRate: number;
  13868. /**
  13869. * You can use gravity if you want to give an orientation to your particles.
  13870. */
  13871. gravity: Vector3;
  13872. /**
  13873. * Minimum power of emitting particles.
  13874. */
  13875. minEmitPower: number;
  13876. /**
  13877. * Maximum power of emitting particles.
  13878. */
  13879. maxEmitPower: number;
  13880. /**
  13881. * The particle emitter type defines the emitter used by the particle system.
  13882. * It can be for example box, sphere, or cone...
  13883. */
  13884. particleEmitterType: Nullable<IParticleEmitterType>;
  13885. /**
  13886. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13887. * This only works when particleEmitterTyps is a BoxParticleEmitter
  13888. */
  13889. direction1: Vector3;
  13890. /**
  13891. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13892. * This only works when particleEmitterTyps is a BoxParticleEmitter
  13893. */
  13894. direction2: Vector3;
  13895. /**
  13896. * 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.
  13897. * This only works when particleEmitterTyps is a BoxParticleEmitter
  13898. */
  13899. minEmitBox: Vector3;
  13900. /**
  13901. * 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.
  13902. * This only works when particleEmitterTyps is a BoxParticleEmitter
  13903. */
  13904. maxEmitBox: Vector3;
  13905. /**
  13906. * Gets the maximum number of particles active at the same time.
  13907. * @returns The max number of active particles.
  13908. */
  13909. getCapacity(): number;
  13910. /**
  13911. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  13912. * to override the particles.
  13913. */
  13914. forceDepthWrite: boolean;
  13915. /**
  13916. * Gets or set the number of active particles
  13917. */
  13918. activeParticleCount: number;
  13919. /**
  13920. * Is this system ready to be used/rendered
  13921. * @return true if the system is ready
  13922. */
  13923. isReady(): boolean;
  13924. /**
  13925. * Gets Wether the system has been started.
  13926. * @returns True if it has been started, otherwise false.
  13927. */
  13928. isStarted(): boolean;
  13929. /**
  13930. * Starts the particle system and begins to emit.
  13931. */
  13932. start(): void;
  13933. /**
  13934. * Stops the particle system.
  13935. */
  13936. stop(): void;
  13937. /**
  13938. * Remove all active particles
  13939. */
  13940. reset(): void;
  13941. /**
  13942. * Returns the string "GPUParticleSystem"
  13943. * @returns a string containing the class name
  13944. */
  13945. getClassName(): string;
  13946. /**
  13947. * Instantiates a GPU particle system.
  13948. * 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.
  13949. * @param name The name of the particle system
  13950. * @param capacity The max number of particles alive at the same time
  13951. * @param scene The scene the particle system belongs to
  13952. */
  13953. constructor(name: string, options: Partial<{
  13954. capacity: number;
  13955. randomTextureSize: number;
  13956. }>, scene: Scene);
  13957. private _createUpdateVAO(source);
  13958. private _createRenderVAO(source, spriteSource);
  13959. private _initialize(force?);
  13960. /** @ignore */
  13961. _recreateUpdateEffect(): void;
  13962. /** @ignore */
  13963. _recreateRenderEffect(): void;
  13964. /**
  13965. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  13966. */
  13967. animate(): void;
  13968. /**
  13969. * Renders the particle system in its current state.
  13970. * @returns the current number of particles
  13971. */
  13972. render(): number;
  13973. /**
  13974. * Rebuilds the particle system
  13975. */
  13976. rebuild(): void;
  13977. private _releaseBuffers();
  13978. private _releaseVAOs();
  13979. /**
  13980. * Disposes the particle system and free the associated resources
  13981. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  13982. */
  13983. dispose(disposeTexture?: boolean): void;
  13984. /**
  13985. * Clones the particle system.
  13986. * @param name The name of the cloned object
  13987. * @param newEmitter The new emitter to use
  13988. * @returns the cloned particle system
  13989. */
  13990. clone(name: string, newEmitter: any): Nullable<GPUParticleSystem>;
  13991. /**
  13992. * Serializes the particle system to a JSON object.
  13993. * @returns the JSON object
  13994. */
  13995. serialize(): any;
  13996. /**
  13997. * Parses a JSON object to create a GPU particle system.
  13998. * @param parsedParticleSystem The JSON object to parse
  13999. * @param scene The scene to create the particle system in
  14000. * @param rootUrl The root url to use to load external dependencies like texture
  14001. * @returns the parsed GPU particle system
  14002. */
  14003. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string): GPUParticleSystem;
  14004. }
  14005. }
  14006. declare module BABYLON {
  14007. /**
  14008. * Interface representing a particle system in Babylon.
  14009. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  14010. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  14011. */
  14012. interface IParticleSystem {
  14013. /**
  14014. * The id of the Particle system.
  14015. */
  14016. id: string;
  14017. /**
  14018. * The name of the Particle system.
  14019. */
  14020. name: string;
  14021. /**
  14022. * The emitter represents the Mesh or position we are attaching the particle system to.
  14023. */
  14024. emitter: Nullable<AbstractMesh | Vector3>;
  14025. /**
  14026. * The rendering group used by the Particle system to chose when to render.
  14027. */
  14028. renderingGroupId: number;
  14029. /**
  14030. * The layer mask we are rendering the particles through.
  14031. */
  14032. layerMask: number;
  14033. /**
  14034. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  14035. */
  14036. updateSpeed: number;
  14037. /**
  14038. * The amount of time the particle system is running (depends of the overall update speed).
  14039. */
  14040. targetStopDuration: number;
  14041. /**
  14042. * The texture used to render each particle. (this can be a spritesheet)
  14043. */
  14044. particleTexture: Nullable<Texture>;
  14045. /**
  14046. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  14047. */
  14048. blendMode: number;
  14049. /**
  14050. * Minimum life time of emitting particles.
  14051. */
  14052. minLifeTime: number;
  14053. /**
  14054. * Maximum life time of emitting particles.
  14055. */
  14056. maxLifeTime: number;
  14057. /**
  14058. * Minimum Size of emitting particles.
  14059. */
  14060. minSize: number;
  14061. /**
  14062. * Maximum Size of emitting particles.
  14063. */
  14064. maxSize: number;
  14065. /**
  14066. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  14067. */
  14068. color1: Color4;
  14069. /**
  14070. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  14071. */
  14072. color2: Color4;
  14073. /**
  14074. * Color the particle will have at the end of its lifetime.
  14075. */
  14076. colorDead: Color4;
  14077. /**
  14078. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  14079. */
  14080. emitRate: number;
  14081. /**
  14082. * You can use gravity if you want to give an orientation to your particles.
  14083. */
  14084. gravity: Vector3;
  14085. /**
  14086. * Minimum power of emitting particles.
  14087. */
  14088. minEmitPower: number;
  14089. /**
  14090. * Maximum power of emitting particles.
  14091. */
  14092. maxEmitPower: number;
  14093. /**
  14094. * The particle emitter type defines the emitter used by the particle system.
  14095. * It can be for example box, sphere, or cone...
  14096. */
  14097. particleEmitterType: Nullable<IParticleEmitterType>;
  14098. /**
  14099. * Gets the maximum number of particles active at the same time.
  14100. * @returns The max number of active particles.
  14101. */
  14102. getCapacity(): number;
  14103. /**
  14104. * Gets Wether the system has been started.
  14105. * @returns True if it has been started, otherwise false.
  14106. */
  14107. isStarted(): boolean;
  14108. /**
  14109. * Gets if the particle system has been started.
  14110. * @return true if the system has been started, otherwise false.
  14111. */
  14112. isStarted(): boolean;
  14113. /**
  14114. * Animates the particle system for this frame.
  14115. */
  14116. animate(): void;
  14117. /**
  14118. * Renders the particle system in its current state.
  14119. * @returns the current number of particles
  14120. */
  14121. render(): number;
  14122. /**
  14123. * Dispose the particle system and frees its associated resources.
  14124. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  14125. */
  14126. dispose(disposeTexture?: boolean): void;
  14127. /**
  14128. * Clones the particle system.
  14129. * @param name The name of the cloned object
  14130. * @param newEmitter The new emitter to use
  14131. * @returns the cloned particle system
  14132. */
  14133. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  14134. /**
  14135. * Serializes the particle system to a JSON object.
  14136. * @returns the JSON object
  14137. */
  14138. serialize(): any;
  14139. /**
  14140. * Rebuild the particle system
  14141. */
  14142. rebuild(): void;
  14143. /**
  14144. * Starts the particle system and begins to emit.
  14145. */
  14146. start(): void;
  14147. /**
  14148. * Stops the particle system.
  14149. */
  14150. stop(): void;
  14151. /**
  14152. * Remove all active particles
  14153. */
  14154. reset(): void;
  14155. /**
  14156. * Is this system ready to be used/rendered
  14157. * @return true if the system is ready
  14158. */
  14159. isReady(): boolean;
  14160. }
  14161. }
  14162. declare module BABYLON {
  14163. /**
  14164. * A particle represents one of the element emitted by a particle system.
  14165. * This is mainly define by its coordinates, direction, velocity and age.
  14166. */
  14167. class Particle {
  14168. /**
  14169. * particleSystem the particle system the particle belongs to.
  14170. */
  14171. particleSystem: ParticleSystem;
  14172. /**
  14173. * The world position of the particle in the scene.
  14174. */
  14175. position: Vector3;
  14176. /**
  14177. * The world direction of the particle in the scene.
  14178. */
  14179. direction: Vector3;
  14180. /**
  14181. * The color of the particle.
  14182. */
  14183. color: Color4;
  14184. /**
  14185. * The color change of the particle per step.
  14186. */
  14187. colorStep: Color4;
  14188. /**
  14189. * Defines how long will the life of the particle be.
  14190. */
  14191. lifeTime: number;
  14192. /**
  14193. * The current age of the particle.
  14194. */
  14195. age: number;
  14196. /**
  14197. * The current size of the particle.
  14198. */
  14199. size: number;
  14200. /**
  14201. * The current angle of the particle.
  14202. */
  14203. angle: number;
  14204. /**
  14205. * Defines how fast is the angle changing.
  14206. */
  14207. angularSpeed: number;
  14208. /**
  14209. * Defines the cell index used by the particle to be rendered from a sprite.
  14210. */
  14211. cellIndex: number;
  14212. private _currentFrameCounter;
  14213. /**
  14214. * Creates a new instance Particle
  14215. * @param particleSystem the particle system the particle belongs to
  14216. */
  14217. constructor(
  14218. /**
  14219. * particleSystem the particle system the particle belongs to.
  14220. */
  14221. particleSystem: ParticleSystem);
  14222. private updateCellInfoFromSystem();
  14223. /**
  14224. * Defines how the sprite cell index is updated for the particle. This is
  14225. * defined as a callback.
  14226. */
  14227. updateCellIndex: (scaledUpdateSpeed: number) => void;
  14228. private _updateCellIndexWithSpeedCalculated(scaledUpdateSpeed);
  14229. private _updateCellIndexWithCustomSpeed();
  14230. /**
  14231. * Copy the properties of particle to another one.
  14232. * @param other the particle to copy the information to.
  14233. */
  14234. copyTo(other: Particle): void;
  14235. }
  14236. }
  14237. declare module BABYLON {
  14238. /**
  14239. * This represents a particle system in Babylon.
  14240. * 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.
  14241. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  14242. * @example https://doc.babylonjs.com/babylon101/particles
  14243. */
  14244. class ParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  14245. /**
  14246. * Source color is added to the destination color without alpha affecting the result.
  14247. */
  14248. static BLENDMODE_ONEONE: number;
  14249. /**
  14250. * Blend current color and particle color using particle’s alpha.
  14251. */
  14252. static BLENDMODE_STANDARD: number;
  14253. /**
  14254. * List of animations used by the particle system.
  14255. */
  14256. animations: Animation[];
  14257. /**
  14258. * The id of the Particle system.
  14259. */
  14260. id: string;
  14261. /**
  14262. * The friendly name of the Particle system.
  14263. */
  14264. name: string;
  14265. /**
  14266. * The rendering group used by the Particle system to chose when to render.
  14267. */
  14268. renderingGroupId: number;
  14269. /**
  14270. * The emitter represents the Mesh or position we are attaching the particle system to.
  14271. */
  14272. emitter: Nullable<AbstractMesh | Vector3>;
  14273. /**
  14274. * The maximum number of particles to emit per frame
  14275. */
  14276. emitRate: number;
  14277. /**
  14278. * If you want to launch only a few particles at once, that can be done, as well.
  14279. */
  14280. manualEmitCount: number;
  14281. /**
  14282. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  14283. */
  14284. updateSpeed: number;
  14285. /**
  14286. * The amount of time the particle system is running (depends of the overall update speed).
  14287. */
  14288. targetStopDuration: number;
  14289. /**
  14290. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  14291. */
  14292. disposeOnStop: boolean;
  14293. /**
  14294. * Minimum power of emitting particles.
  14295. */
  14296. minEmitPower: number;
  14297. /**
  14298. * Maximum power of emitting particles.
  14299. */
  14300. maxEmitPower: number;
  14301. /**
  14302. * Minimum life time of emitting particles.
  14303. */
  14304. minLifeTime: number;
  14305. /**
  14306. * Maximum life time of emitting particles.
  14307. */
  14308. maxLifeTime: number;
  14309. /**
  14310. * Minimum Size of emitting particles.
  14311. */
  14312. minSize: number;
  14313. /**
  14314. * Maximum Size of emitting particles.
  14315. */
  14316. maxSize: number;
  14317. /**
  14318. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  14319. */
  14320. minAngularSpeed: number;
  14321. /**
  14322. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  14323. */
  14324. maxAngularSpeed: number;
  14325. /**
  14326. * The texture used to render each particle. (this can be a spritesheet)
  14327. */
  14328. particleTexture: Nullable<Texture>;
  14329. /**
  14330. * The layer mask we are rendering the particles through.
  14331. */
  14332. layerMask: number;
  14333. /**
  14334. * This can help using your own shader to render the particle system.
  14335. * The according effect will be created
  14336. */
  14337. customShader: any;
  14338. /**
  14339. * By default particle system starts as soon as they are created. This prevents the
  14340. * automatic start to happen and let you decide when to start emitting particles.
  14341. */
  14342. preventAutoStart: boolean;
  14343. /**
  14344. * This function can be defined to provide custom update for active particles.
  14345. * This function will be called instead of regular update (age, position, color, etc.).
  14346. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  14347. */
  14348. updateFunction: (particles: Particle[]) => void;
  14349. /**
  14350. * Callback triggered when the particle animation is ending.
  14351. */
  14352. onAnimationEnd: Nullable<() => void>;
  14353. /**
  14354. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  14355. */
  14356. blendMode: number;
  14357. /**
  14358. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  14359. * to override the particles.
  14360. */
  14361. forceDepthWrite: boolean;
  14362. /**
  14363. * You can use gravity if you want to give an orientation to your particles.
  14364. */
  14365. gravity: Vector3;
  14366. /**
  14367. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14368. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14369. */
  14370. direction1: Vector3;
  14371. /**
  14372. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14373. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14374. */
  14375. direction2: Vector3;
  14376. /**
  14377. * 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.
  14378. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14379. */
  14380. minEmitBox: Vector3;
  14381. /**
  14382. * 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.
  14383. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14384. */
  14385. maxEmitBox: Vector3;
  14386. /**
  14387. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  14388. */
  14389. color1: Color4;
  14390. /**
  14391. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  14392. */
  14393. color2: Color4;
  14394. /**
  14395. * Color the particle will have at the end of its lifetime.
  14396. */
  14397. colorDead: Color4;
  14398. /**
  14399. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel.
  14400. */
  14401. textureMask: Color4;
  14402. /**
  14403. * The particle emitter type defines the emitter used by the particle system.
  14404. * It can be for example box, sphere, or cone...
  14405. */
  14406. particleEmitterType: IParticleEmitterType;
  14407. /**
  14408. * This function can be defined to specify initial direction for every new particle.
  14409. * It by default use the emitterType defined function.
  14410. */
  14411. startDirectionFunction: (emitPower: number, worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  14412. /**
  14413. * This function can be defined to specify initial position for every new particle.
  14414. * It by default use the emitterType defined function.
  14415. */
  14416. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  14417. /**
  14418. * If using a spritesheet (isAnimationSheetEnabled), defines if the sprite animation should loop between startSpriteCellID and endSpriteCellID or not.
  14419. */
  14420. spriteCellLoop: boolean;
  14421. /**
  14422. * If using a spritesheet (isAnimationSheetEnabled) and spriteCellLoop defines the speed of the sprite loop.
  14423. */
  14424. spriteCellChangeSpeed: number;
  14425. /**
  14426. * If using a spritesheet (isAnimationSheetEnabled) and spriteCellLoop defines the first sprite cell to display.
  14427. */
  14428. startSpriteCellID: number;
  14429. /**
  14430. * If using a spritesheet (isAnimationSheetEnabled) and spriteCellLoop defines the last sprite cell to display.
  14431. */
  14432. endSpriteCellID: number;
  14433. /**
  14434. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use.
  14435. */
  14436. spriteCellWidth: number;
  14437. /**
  14438. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use.
  14439. */
  14440. spriteCellHeight: number;
  14441. /**
  14442. * An event triggered when the system is disposed.
  14443. */
  14444. onDisposeObservable: Observable<ParticleSystem>;
  14445. private _onDisposeObserver;
  14446. /**
  14447. * Sets a callback that will be triggered when the system is disposed.
  14448. */
  14449. onDispose: () => void;
  14450. /**
  14451. * Gets wether an animation sprite sheet is enabled or not on the particle system.
  14452. */
  14453. readonly isAnimationSheetEnabled: Boolean;
  14454. private _particles;
  14455. private _epsilon;
  14456. private _capacity;
  14457. private _scene;
  14458. private _stockParticles;
  14459. private _newPartsExcess;
  14460. private _vertexData;
  14461. private _vertexBuffer;
  14462. private _vertexBuffers;
  14463. private _indexBuffer;
  14464. private _effect;
  14465. private _customEffect;
  14466. private _cachedDefines;
  14467. private _scaledColorStep;
  14468. private _colorDiff;
  14469. private _scaledDirection;
  14470. private _scaledGravity;
  14471. private _currentRenderId;
  14472. private _alive;
  14473. private _started;
  14474. private _stopped;
  14475. private _actualFrame;
  14476. private _scaledUpdateSpeed;
  14477. private _vertexBufferSize;
  14478. private _isAnimationSheetEnabled;
  14479. /**
  14480. * this is the Sub-emitters templates that will be used to generate particle system when the particle dies, this property is used by the root particle system only.
  14481. */
  14482. subEmitters: ParticleSystem[];
  14483. /**
  14484. * The current active Sub-systems, this property is used by the root particle system only.
  14485. */
  14486. activeSubSystems: Array<ParticleSystem>;
  14487. private _rootParticleSystem;
  14488. /**
  14489. * Gets the current list of active particles
  14490. */
  14491. readonly particles: Particle[];
  14492. /**
  14493. * Returns the string "ParticleSystem"
  14494. * @returns a string containing the class name
  14495. */
  14496. getClassName(): string;
  14497. /**
  14498. * Instantiates a particle system.
  14499. * 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.
  14500. * @param name The name of the particle system
  14501. * @param capacity The max number of particles alive at the same time
  14502. * @param scene The scene the particle system belongs to
  14503. * @param customEffect a custom effect used to change the way particles are rendered by default
  14504. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  14505. * @param epsilon Offset used to render the particles
  14506. */
  14507. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  14508. private _createIndexBuffer();
  14509. /**
  14510. * Gets the maximum number of particles active at the same time.
  14511. * @returns The max number of active particles.
  14512. */
  14513. getCapacity(): number;
  14514. /**
  14515. * Gets Wether there are still active particles in the system.
  14516. * @returns True if it is alive, otherwise false.
  14517. */
  14518. isAlive(): boolean;
  14519. /**
  14520. * Gets Wether the system has been started.
  14521. * @returns True if it has been started, otherwise false.
  14522. */
  14523. isStarted(): boolean;
  14524. /**
  14525. * Starts the particle system and begins to emit.
  14526. */
  14527. start(): void;
  14528. /**
  14529. * Stops the particle system.
  14530. * @param stopSubEmitters if true it will stop the current system and all created sub-Systems if false it will stop the current root system only, this param is used by the root particle system only. the default value is true.
  14531. */
  14532. stop(stopSubEmitters?: boolean): void;
  14533. /**
  14534. * Remove all active particles
  14535. */
  14536. reset(): void;
  14537. /**
  14538. * @ignore (for internal use only)
  14539. */
  14540. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  14541. /**
  14542. * @ignore (for internal use only)
  14543. */
  14544. _appendParticleVertexWithAnimation(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  14545. /**
  14546. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  14547. * Its lifetime will start back at 0.
  14548. */
  14549. recycleParticle: (particle: Particle) => void;
  14550. private _stopSubEmitters();
  14551. private _createParticle;
  14552. private _removeFromRoot();
  14553. private _emitFromParticle;
  14554. private _update(newParticles);
  14555. private _getEffect();
  14556. /**
  14557. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  14558. */
  14559. animate(): void;
  14560. private _appendParticleVertexes;
  14561. private _appenedParticleVertexesWithSheet(offset, particle);
  14562. private _appenedParticleVertexesNoSheet(offset, particle);
  14563. /**
  14564. * Rebuilds the particle system.
  14565. */
  14566. rebuild(): void;
  14567. /**
  14568. * Is this system ready to be used/rendered
  14569. * @return true if the system is ready
  14570. */
  14571. isReady(): boolean;
  14572. /**
  14573. * Renders the particle system in its current state.
  14574. * @returns the current number of particles
  14575. */
  14576. render(): number;
  14577. /**
  14578. * Disposes the particle system and free the associated resources
  14579. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  14580. */
  14581. dispose(disposeTexture?: boolean): void;
  14582. /**
  14583. * Creates a Sphere Emitter for the particle system. (emits along the sphere radius)
  14584. * @param radius The radius of the sphere to emit from
  14585. * @returns the emitter
  14586. */
  14587. createSphereEmitter(radius?: number): SphereParticleEmitter;
  14588. /**
  14589. * Creates a Directed Sphere Emitter for the particle system. (emits between direction1 and direction2)
  14590. * @param radius The radius of the sphere to emit from
  14591. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  14592. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  14593. * @returns the emitter
  14594. */
  14595. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  14596. /**
  14597. * Creates a Cone Emitter for the particle system. (emits from the cone to the particle position)
  14598. * @param radius The radius of the cone to emit from
  14599. * @param angle The base angle of the cone
  14600. * @returns the emitter
  14601. */
  14602. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  14603. /**
  14604. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  14605. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14606. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14607. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14608. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14609. * @returns the emitter
  14610. */
  14611. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  14612. /**
  14613. * Clones the particle system.
  14614. * @param name The name of the cloned object
  14615. * @param newEmitter The new emitter to use
  14616. * @returns the cloned particle system
  14617. */
  14618. clone(name: string, newEmitter: any): ParticleSystem;
  14619. /**
  14620. * Serializes the particle system to a JSON object.
  14621. * @returns the JSON object
  14622. */
  14623. serialize(): any;
  14624. /**
  14625. * Parses a JSON object to create a particle system.
  14626. * @param parsedParticleSystem The JSON object to parse
  14627. * @param scene The scene to create the particle system in
  14628. * @param rootUrl The root url to use to load external dependencies like texture
  14629. * @returns the Parsed particle system
  14630. */
  14631. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string): ParticleSystem;
  14632. }
  14633. }
  14634. declare module BABYLON {
  14635. /**
  14636. * Represents one particle of a solid particle system.
  14637. */
  14638. class SolidParticle {
  14639. /**
  14640. * particle global index
  14641. */
  14642. idx: number;
  14643. /**
  14644. * The color of the particle
  14645. */
  14646. color: Nullable<Color4>;
  14647. /**
  14648. * The world space position of the particle.
  14649. */
  14650. position: Vector3;
  14651. /**
  14652. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  14653. */
  14654. rotation: Vector3;
  14655. /**
  14656. * The world space rotation quaternion of the particle.
  14657. */
  14658. rotationQuaternion: Nullable<Quaternion>;
  14659. /**
  14660. * The scaling of the particle.
  14661. */
  14662. scaling: Vector3;
  14663. /**
  14664. * The uvs of the particle.
  14665. */
  14666. uvs: Vector4;
  14667. /**
  14668. * The current speed of the particle.
  14669. */
  14670. velocity: Vector3;
  14671. /**
  14672. * The pivot point in the particle local space.
  14673. */
  14674. pivot: Vector3;
  14675. /**
  14676. * Must the particle be translated from its pivot point in its local space ?
  14677. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  14678. * Default : false
  14679. */
  14680. translateFromPivot: boolean;
  14681. /**
  14682. * Is the particle active or not ?
  14683. */
  14684. alive: boolean;
  14685. /**
  14686. * Is the particle visible or not ?
  14687. */
  14688. isVisible: boolean;
  14689. /**
  14690. * Index of this particle in the global "positions" array (Internal use)
  14691. */
  14692. _pos: number;
  14693. /**
  14694. * Index of this particle in the global "indices" array (Internal use)
  14695. */
  14696. _ind: number;
  14697. /**
  14698. * ModelShape of this particle (Internal use)
  14699. */
  14700. _model: ModelShape;
  14701. /**
  14702. * ModelShape id of this particle
  14703. */
  14704. shapeId: number;
  14705. /**
  14706. * Index of the particle in its shape id (Internal use)
  14707. */
  14708. idxInShape: number;
  14709. /**
  14710. * Reference to the shape model BoundingInfo object (Internal use)
  14711. */
  14712. _modelBoundingInfo: BoundingInfo;
  14713. /**
  14714. * Particle BoundingInfo object (Internal use)
  14715. */
  14716. _boundingInfo: BoundingInfo;
  14717. /**
  14718. * Reference to the SPS what the particle belongs to (Internal use)
  14719. */
  14720. _sps: SolidParticleSystem;
  14721. /**
  14722. * Still set as invisible in order to skip useless computations (Internal use)
  14723. */
  14724. _stillInvisible: boolean;
  14725. /**
  14726. * Last computed particle rotation matrix
  14727. */
  14728. _rotationMatrix: number[];
  14729. /**
  14730. * Parent particle Id, if any.
  14731. * Default null.
  14732. */
  14733. parentId: Nullable<number>;
  14734. /**
  14735. * Internal global position in the SPS.
  14736. */
  14737. _globalPosition: Vector3;
  14738. /**
  14739. * Creates a Solid Particle object.
  14740. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  14741. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  14742. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  14743. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  14744. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  14745. * @param shapeId (integer) is the model shape identifier in the SPS.
  14746. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  14747. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  14748. */
  14749. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  14750. /**
  14751. * Legacy support, changed scale to scaling
  14752. */
  14753. /**
  14754. * Legacy support, changed scale to scaling
  14755. */
  14756. scale: Vector3;
  14757. /**
  14758. * Legacy support, changed quaternion to rotationQuaternion
  14759. */
  14760. /**
  14761. * Legacy support, changed quaternion to rotationQuaternion
  14762. */
  14763. quaternion: Nullable<Quaternion>;
  14764. /**
  14765. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  14766. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  14767. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  14768. * @returns true if it intersects
  14769. */
  14770. intersectsMesh(target: Mesh | SolidParticle): boolean;
  14771. }
  14772. /**
  14773. * Represents the shape of the model used by one particle of a solid particle system.
  14774. * SPS internal tool, don't use it manually.
  14775. */
  14776. class ModelShape {
  14777. /**
  14778. * The shape id.
  14779. */
  14780. shapeID: number;
  14781. /**
  14782. * flat array of model positions (internal use)
  14783. */
  14784. _shape: Vector3[];
  14785. /**
  14786. * flat array of model UVs (internal use)
  14787. */
  14788. _shapeUV: number[];
  14789. /**
  14790. * length of the shape in the model indices array (internal use)
  14791. */
  14792. _indicesLength: number;
  14793. /**
  14794. * Custom position function (internal use)
  14795. */
  14796. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  14797. /**
  14798. * Custom vertex function (internal use)
  14799. */
  14800. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  14801. /**
  14802. * 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.
  14803. * SPS internal tool, don't use it manually.
  14804. * @ignore
  14805. */
  14806. 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>);
  14807. }
  14808. /**
  14809. * Represents a Depth Sorted Particle in the solid particle system.
  14810. */
  14811. class DepthSortedParticle {
  14812. /**
  14813. * Index of the particle in the "indices" array
  14814. */
  14815. ind: number;
  14816. /**
  14817. * Length of the particle shape in the "indices" array
  14818. */
  14819. indicesLength: number;
  14820. /**
  14821. * Squared distance from the particle to the camera
  14822. */
  14823. sqDistance: number;
  14824. }
  14825. }
  14826. declare module BABYLON {
  14827. /**
  14828. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  14829. *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.
  14830. * The SPS is also a particle system. It provides some methods to manage the particles.
  14831. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  14832. *
  14833. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  14834. */
  14835. class SolidParticleSystem implements IDisposable {
  14836. /**
  14837. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  14838. * Example : var p = SPS.particles[i];
  14839. */
  14840. particles: SolidParticle[];
  14841. /**
  14842. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  14843. */
  14844. nbParticles: number;
  14845. /**
  14846. * If the particles must ever face the camera (default false). Useful for planar particles.
  14847. */
  14848. billboard: boolean;
  14849. /**
  14850. * Recompute normals when adding a shape
  14851. */
  14852. recomputeNormals: boolean;
  14853. /**
  14854. * This a counter ofr your own usage. It's not set by any SPS functions.
  14855. */
  14856. counter: number;
  14857. /**
  14858. * The SPS name. This name is also given to the underlying mesh.
  14859. */
  14860. name: string;
  14861. /**
  14862. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  14863. */
  14864. mesh: Mesh;
  14865. /**
  14866. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  14867. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  14868. */
  14869. vars: any;
  14870. /**
  14871. * This array is populated when the SPS is set as 'pickable'.
  14872. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  14873. * Each element of this array is an object `{idx: int, faceId: int}`.
  14874. * `idx` is the picked particle index in the `SPS.particles` array
  14875. * `faceId` is the picked face index counted within this particle.
  14876. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  14877. */
  14878. pickedParticles: {
  14879. idx: number;
  14880. faceId: number;
  14881. }[];
  14882. /**
  14883. * This array is populated when `enableDepthSort` is set to true.
  14884. * Each element of this array is an instance of the class DepthSortedParticle.
  14885. */
  14886. depthSortedParticles: DepthSortedParticle[];
  14887. /**
  14888. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  14889. */
  14890. _bSphereOnly: boolean;
  14891. /**
  14892. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  14893. */
  14894. _bSphereRadiusFactor: number;
  14895. private _scene;
  14896. private _positions;
  14897. private _indices;
  14898. private _normals;
  14899. private _colors;
  14900. private _uvs;
  14901. private _indices32;
  14902. private _positions32;
  14903. private _normals32;
  14904. private _fixedNormal32;
  14905. private _colors32;
  14906. private _uvs32;
  14907. private _index;
  14908. private _updatable;
  14909. private _pickable;
  14910. private _isVisibilityBoxLocked;
  14911. private _alwaysVisible;
  14912. private _depthSort;
  14913. private _shapeCounter;
  14914. private _copy;
  14915. private _shape;
  14916. private _shapeUV;
  14917. private _color;
  14918. private _computeParticleColor;
  14919. private _computeParticleTexture;
  14920. private _computeParticleRotation;
  14921. private _computeParticleVertex;
  14922. private _computeBoundingBox;
  14923. private _depthSortParticles;
  14924. private _cam_axisZ;
  14925. private _cam_axisY;
  14926. private _cam_axisX;
  14927. private _axisZ;
  14928. private _camera;
  14929. private _particle;
  14930. private _camDir;
  14931. private _camInvertedPosition;
  14932. private _rotMatrix;
  14933. private _invertMatrix;
  14934. private _rotated;
  14935. private _quaternion;
  14936. private _vertex;
  14937. private _normal;
  14938. private _yaw;
  14939. private _pitch;
  14940. private _roll;
  14941. private _halfroll;
  14942. private _halfpitch;
  14943. private _halfyaw;
  14944. private _sinRoll;
  14945. private _cosRoll;
  14946. private _sinPitch;
  14947. private _cosPitch;
  14948. private _sinYaw;
  14949. private _cosYaw;
  14950. private _mustUnrotateFixedNormals;
  14951. private _minimum;
  14952. private _maximum;
  14953. private _minBbox;
  14954. private _maxBbox;
  14955. private _particlesIntersect;
  14956. private _depthSortFunction;
  14957. private _needs32Bits;
  14958. private _pivotBackTranslation;
  14959. private _scaledPivot;
  14960. private _particleHasParent;
  14961. private _parent;
  14962. /**
  14963. * Creates a SPS (Solid Particle System) object.
  14964. * @param name (String) is the SPS name, this will be the underlying mesh name.
  14965. * @param scene (Scene) is the scene in which the SPS is added.
  14966. * @param updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  14967. * @param isPickable (optional boolean, default false) : if the solid particles must be pickable.
  14968. * @param enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  14969. * @param particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  14970. * @param boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  14971. * @param bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  14972. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  14973. */
  14974. constructor(name: string, scene: Scene, options?: {
  14975. updatable?: boolean;
  14976. isPickable?: boolean;
  14977. enableDepthSort?: boolean;
  14978. particleIntersection?: boolean;
  14979. boundingSphereOnly?: boolean;
  14980. bSphereRadiusFactor?: number;
  14981. });
  14982. /**
  14983. * Builds the SPS underlying mesh. Returns a standard Mesh.
  14984. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  14985. * @returns the created mesh
  14986. */
  14987. buildMesh(): Mesh;
  14988. /**
  14989. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  14990. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  14991. * Thus the particles generated from `digest()` have their property `position` set yet.
  14992. * @param mesh ( Mesh ) is the mesh to be digested
  14993. * @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
  14994. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  14995. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  14996. * @returns the current SPS
  14997. */
  14998. digest(mesh: Mesh, options?: {
  14999. facetNb?: number;
  15000. number?: number;
  15001. delta?: number;
  15002. }): SolidParticleSystem;
  15003. private _unrotateFixedNormals();
  15004. private _resetCopy();
  15005. private _meshBuilder(p, shape, positions, meshInd, indices, meshUV, uvs, meshCol, colors, meshNor, normals, idx, idxInShape, options);
  15006. private _posToShape(positions);
  15007. private _uvsToShapeUV(uvs);
  15008. private _addParticle(idx, idxpos, idxind, model, shapeId, idxInShape, bInfo?);
  15009. /**
  15010. * Adds some particles to the SPS from the model shape. Returns the shape id.
  15011. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  15012. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  15013. * @param nb (positive integer) the number of particles to be created from this model
  15014. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  15015. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  15016. * @returns the number of shapes in the system
  15017. */
  15018. addShape(mesh: Mesh, nb: number, options?: {
  15019. positionFunction?: any;
  15020. vertexFunction?: any;
  15021. }): number;
  15022. private _rebuildParticle(particle);
  15023. /**
  15024. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  15025. * @returns the SPS.
  15026. */
  15027. rebuildMesh(): SolidParticleSystem;
  15028. /**
  15029. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  15030. * This method calls `updateParticle()` for each particle of the SPS.
  15031. * For an animated SPS, it is usually called within the render loop.
  15032. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  15033. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  15034. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  15035. * @returns the SPS.
  15036. */
  15037. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  15038. private _quaternionRotationYPR();
  15039. private _quaternionToRotationMatrix();
  15040. /**
  15041. * Disposes the SPS.
  15042. */
  15043. dispose(): void;
  15044. /**
  15045. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  15046. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  15047. * @returns the SPS.
  15048. */
  15049. refreshVisibleSize(): SolidParticleSystem;
  15050. /**
  15051. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  15052. * @param size the size (float) of the visibility box
  15053. * note : this doesn't lock the SPS mesh bounding box.
  15054. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  15055. */
  15056. setVisibilityBox(size: number): void;
  15057. /**
  15058. * Gets whether the SPS as always visible or not
  15059. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  15060. */
  15061. /**
  15062. * Sets the SPS as always visible or not
  15063. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  15064. */
  15065. isAlwaysVisible: boolean;
  15066. /**
  15067. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  15068. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  15069. */
  15070. /**
  15071. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  15072. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  15073. */
  15074. isVisibilityBoxLocked: boolean;
  15075. /**
  15076. * Gets if `setParticles()` computes the particle rotations or not.
  15077. * Default value : true. The SPS is faster when it's set to false.
  15078. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  15079. */
  15080. /**
  15081. * Tells to `setParticles()` to compute the particle rotations or not.
  15082. * Default value : true. The SPS is faster when it's set to false.
  15083. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  15084. */
  15085. computeParticleRotation: boolean;
  15086. /**
  15087. * Gets if `setParticles()` computes the particle colors or not.
  15088. * Default value : true. The SPS is faster when it's set to false.
  15089. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  15090. */
  15091. /**
  15092. * Tells to `setParticles()` to compute the particle colors or not.
  15093. * Default value : true. The SPS is faster when it's set to false.
  15094. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  15095. */
  15096. computeParticleColor: boolean;
  15097. /**
  15098. * Gets if `setParticles()` computes the particle textures or not.
  15099. * Default value : true. The SPS is faster when it's set to false.
  15100. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  15101. */
  15102. computeParticleTexture: boolean;
  15103. /**
  15104. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  15105. * Default value : false. The SPS is faster when it's set to false.
  15106. * Note : the particle custom vertex positions aren't stored values.
  15107. */
  15108. /**
  15109. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  15110. * Default value : false. The SPS is faster when it's set to false.
  15111. * Note : the particle custom vertex positions aren't stored values.
  15112. */
  15113. computeParticleVertex: boolean;
  15114. /**
  15115. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  15116. */
  15117. /**
  15118. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  15119. */
  15120. computeBoundingBox: boolean;
  15121. /**
  15122. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  15123. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  15124. * Default : `true`
  15125. */
  15126. /**
  15127. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  15128. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  15129. * Default : `true`
  15130. */
  15131. depthSortParticles: boolean;
  15132. /**
  15133. * This function does nothing. It may be overwritten to set all the particle first values.
  15134. * The SPS doesn't call this function, you may have to call it by your own.
  15135. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  15136. */
  15137. initParticles(): void;
  15138. /**
  15139. * This function does nothing. It may be overwritten to recycle a particle.
  15140. * The SPS doesn't call this function, you may have to call it by your own.
  15141. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  15142. * @param particle The particle to recycle
  15143. * @returns the recycled particle
  15144. */
  15145. recycleParticle(particle: SolidParticle): SolidParticle;
  15146. /**
  15147. * Updates a particle : this function should be overwritten by the user.
  15148. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  15149. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  15150. * @example : just set a particle position or velocity and recycle conditions
  15151. * @param particle The particle to update
  15152. * @returns the updated particle
  15153. */
  15154. updateParticle(particle: SolidParticle): SolidParticle;
  15155. /**
  15156. * Updates a vertex of a particle : it can be overwritten by the user.
  15157. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  15158. * @param particle the current particle
  15159. * @param vertex the current index of the current particle
  15160. * @param pt the index of the current vertex in the particle shape
  15161. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  15162. * @example : just set a vertex particle position
  15163. * @returns the updated vertex
  15164. */
  15165. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  15166. /**
  15167. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  15168. * This does nothing and may be overwritten by the user.
  15169. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  15170. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  15171. * @param update the boolean update value actually passed to setParticles()
  15172. */
  15173. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  15174. /**
  15175. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  15176. * This will be passed three parameters.
  15177. * This does nothing and may be overwritten by the user.
  15178. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  15179. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  15180. * @param update the boolean update value actually passed to setParticles()
  15181. */
  15182. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  15183. }
  15184. }
  15185. declare module BABYLON {
  15186. class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  15187. static OCCLUSION_TYPE_NONE: number;
  15188. static OCCLUSION_TYPE_OPTIMISTIC: number;
  15189. static OCCLUSION_TYPE_STRICT: number;
  15190. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  15191. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  15192. static readonly BILLBOARDMODE_NONE: number;
  15193. static readonly BILLBOARDMODE_X: number;
  15194. static readonly BILLBOARDMODE_Y: number;
  15195. static readonly BILLBOARDMODE_Z: number;
  15196. static readonly BILLBOARDMODE_ALL: number;
  15197. private _facetPositions;
  15198. private _facetNormals;
  15199. private _facetPartitioning;
  15200. private _facetNb;
  15201. private _partitioningSubdivisions;
  15202. private _partitioningBBoxRatio;
  15203. private _facetDataEnabled;
  15204. private _facetParameters;
  15205. private _bbSize;
  15206. private _subDiv;
  15207. private _facetDepthSort;
  15208. private _facetDepthSortEnabled;
  15209. private _depthSortedIndices;
  15210. private _depthSortedFacets;
  15211. private _facetDepthSortFunction;
  15212. private _facetDepthSortFrom;
  15213. private _facetDepthSortOrigin;
  15214. private _invertedMatrix;
  15215. /**
  15216. * Read-only : the number of facets in the mesh
  15217. */
  15218. readonly facetNb: number;
  15219. /**
  15220. * The number (integer) of subdivisions per axis in the partioning space
  15221. */
  15222. partitioningSubdivisions: number;
  15223. /**
  15224. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  15225. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box.
  15226. */
  15227. partitioningBBoxRatio: number;
  15228. /**
  15229. * Boolean : must the facet be depth sorted on next call to `updateFacetData()` ?
  15230. * Works only for updatable meshes.
  15231. * Doesn't work with multi-materials.
  15232. */
  15233. mustDepthSortFacets: boolean;
  15234. /**
  15235. * The location (Vector3) where the facet depth sort must be computed from.
  15236. * By default, the active camera position.
  15237. * Used only when facet depth sort is enabled.
  15238. */
  15239. facetDepthSortFrom: Vector3;
  15240. /**
  15241. * Read-only boolean : is the feature facetData enabled ?
  15242. */
  15243. readonly isFacetDataEnabled: boolean;
  15244. _updateNonUniformScalingState(value: boolean): boolean;
  15245. /**
  15246. * An event triggered when this mesh collides with another one
  15247. */
  15248. onCollideObservable: Observable<AbstractMesh>;
  15249. private _onCollideObserver;
  15250. onCollide: () => void;
  15251. /**
  15252. * An event triggered when the collision's position changes
  15253. */
  15254. onCollisionPositionChangeObservable: Observable<Vector3>;
  15255. private _onCollisionPositionChangeObserver;
  15256. onCollisionPositionChange: () => void;
  15257. /**
  15258. * An event triggered when material is changed
  15259. */
  15260. onMaterialChangedObservable: Observable<AbstractMesh>;
  15261. definedFacingForward: boolean;
  15262. /**
  15263. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  15264. * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  15265. * or
  15266. * 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.
  15267. * for more info check WebGl documentations
  15268. */
  15269. occlusionQueryAlgorithmType: number;
  15270. /**
  15271. * 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:
  15272. * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  15273. * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  15274. * 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.
  15275. */
  15276. occlusionType: number;
  15277. /**
  15278. * 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.
  15279. * The default value is -1 which means don't break the query and wait till the result.
  15280. */
  15281. occlusionRetryCount: number;
  15282. private _occlusionInternalRetryCounter;
  15283. protected _isOccluded: boolean;
  15284. /**
  15285. * 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.
  15286. */
  15287. isOccluded: boolean;
  15288. private _isOcclusionQueryInProgress;
  15289. /**
  15290. * Flag to check the progress status of the query
  15291. */
  15292. readonly isOcclusionQueryInProgress: boolean;
  15293. private _occlusionQuery;
  15294. private _visibility;
  15295. /**
  15296. * Gets or sets mesh visibility between 0 and 1 (defult is 1)
  15297. */
  15298. /**
  15299. * Gets or sets mesh visibility between 0 and 1 (defult is 1)
  15300. */
  15301. visibility: number;
  15302. alphaIndex: number;
  15303. isVisible: boolean;
  15304. isPickable: boolean;
  15305. showBoundingBox: boolean;
  15306. showSubMeshesBoundingBox: boolean;
  15307. isBlocker: boolean;
  15308. enablePointerMoveEvents: boolean;
  15309. renderingGroupId: number;
  15310. private _material;
  15311. material: Nullable<Material>;
  15312. private _receiveShadows;
  15313. receiveShadows: boolean;
  15314. renderOutline: boolean;
  15315. outlineColor: Color3;
  15316. outlineWidth: number;
  15317. renderOverlay: boolean;
  15318. overlayColor: Color3;
  15319. overlayAlpha: number;
  15320. private _hasVertexAlpha;
  15321. hasVertexAlpha: boolean;
  15322. private _useVertexColors;
  15323. useVertexColors: boolean;
  15324. private _computeBonesUsingShaders;
  15325. computeBonesUsingShaders: boolean;
  15326. private _numBoneInfluencers;
  15327. numBoneInfluencers: number;
  15328. private _applyFog;
  15329. applyFog: boolean;
  15330. useOctreeForRenderingSelection: boolean;
  15331. useOctreeForPicking: boolean;
  15332. useOctreeForCollisions: boolean;
  15333. private _layerMask;
  15334. layerMask: number;
  15335. /**
  15336. * True if the mesh must be rendered in any case.
  15337. */
  15338. alwaysSelectAsActiveMesh: boolean;
  15339. /**
  15340. * This scene's action manager
  15341. */
  15342. actionManager: Nullable<ActionManager>;
  15343. physicsImpostor: Nullable<PhysicsImpostor>;
  15344. private _checkCollisions;
  15345. private _collisionMask;
  15346. private _collisionGroup;
  15347. ellipsoid: Vector3;
  15348. ellipsoidOffset: Vector3;
  15349. private _collider;
  15350. private _oldPositionForCollisions;
  15351. private _diffPositionForCollisions;
  15352. collisionMask: number;
  15353. collisionGroup: number;
  15354. edgesWidth: number;
  15355. edgesColor: Color4;
  15356. _edgesRenderer: Nullable<EdgesRenderer>;
  15357. private _collisionsTransformMatrix;
  15358. private _collisionsScalingMatrix;
  15359. _masterMesh: Nullable<AbstractMesh>;
  15360. _boundingInfo: Nullable<BoundingInfo>;
  15361. _renderId: number;
  15362. subMeshes: SubMesh[];
  15363. _submeshesOctree: Octree<SubMesh>;
  15364. _intersectionsInProgress: AbstractMesh[];
  15365. _unIndexed: boolean;
  15366. _lightSources: Light[];
  15367. readonly _positions: Nullable<Vector3[]>;
  15368. _waitingActions: any;
  15369. _waitingFreezeWorldMatrix: Nullable<boolean>;
  15370. private _skeleton;
  15371. _bonesTransformMatrices: Nullable<Float32Array>;
  15372. skeleton: Nullable<Skeleton>;
  15373. constructor(name: string, scene?: Nullable<Scene>);
  15374. /**
  15375. * Returns the string "AbstractMesh"
  15376. */
  15377. getClassName(): string;
  15378. /**
  15379. * @param {boolean} fullDetails - support for multiple levels of logging within scene loading
  15380. */
  15381. toString(fullDetails?: boolean): string;
  15382. _rebuild(): void;
  15383. _resyncLightSources(): void;
  15384. _resyncLighSource(light: Light): void;
  15385. _removeLightSource(light: Light): void;
  15386. private _markSubMeshesAsDirty(func);
  15387. _markSubMeshesAsLightDirty(): void;
  15388. _markSubMeshesAsAttributesDirty(): void;
  15389. _markSubMeshesAsMiscDirty(): void;
  15390. /**
  15391. * Scaling property : a Vector3 depicting the mesh scaling along each local axis X, Y, Z.
  15392. * Default : (1.0, 1.0, 1.0)
  15393. */
  15394. /**
  15395. * Scaling property : a Vector3 depicting the mesh scaling along each local axis X, Y, Z.
  15396. * Default : (1.0, 1.0, 1.0)
  15397. */
  15398. scaling: Vector3;
  15399. /**
  15400. * Disables the mesh edger rendering mode.
  15401. * Returns the AbstractMesh.
  15402. */
  15403. disableEdgesRendering(): AbstractMesh;
  15404. /**
  15405. * Enables the edge rendering mode on the mesh.
  15406. * This mode makes the mesh edges visible.
  15407. * Returns the AbstractMesh.
  15408. */
  15409. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  15410. /**
  15411. * Returns true if the mesh is blocked. Used by the class Mesh.
  15412. * Returns the boolean `false` by default.
  15413. */
  15414. readonly isBlocked: boolean;
  15415. /**
  15416. * Returns the mesh itself by default, used by the class Mesh.
  15417. * Returned type : AbstractMesh
  15418. */
  15419. getLOD(camera: Camera): AbstractMesh;
  15420. /**
  15421. * Returns 0 by default, used by the class Mesh.
  15422. * Returns an integer.
  15423. */
  15424. getTotalVertices(): number;
  15425. /**
  15426. * Returns null by default, used by the class Mesh.
  15427. * Returned type : integer array
  15428. */
  15429. getIndices(): Nullable<IndicesArray>;
  15430. /**
  15431. * Returns the array of the requested vertex data kind. Used by the class Mesh. Returns null here.
  15432. * Returned type : float array or Float32Array
  15433. */
  15434. getVerticesData(kind: string): Nullable<FloatArray>;
  15435. /**
  15436. * Sets the vertex data of the mesh geometry for the requested `kind`.
  15437. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  15438. * The `data` are either a numeric array either a Float32Array.
  15439. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  15440. * 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).
  15441. * Note that a new underlying VertexBuffer object is created each call.
  15442. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  15443. *
  15444. * Possible `kind` values :
  15445. * - BABYLON.VertexBuffer.PositionKind
  15446. * - BABYLON.VertexBuffer.UVKind
  15447. * - BABYLON.VertexBuffer.UV2Kind
  15448. * - BABYLON.VertexBuffer.UV3Kind
  15449. * - BABYLON.VertexBuffer.UV4Kind
  15450. * - BABYLON.VertexBuffer.UV5Kind
  15451. * - BABYLON.VertexBuffer.UV6Kind
  15452. * - BABYLON.VertexBuffer.ColorKind
  15453. * - BABYLON.VertexBuffer.MatricesIndicesKind
  15454. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  15455. * - BABYLON.VertexBuffer.MatricesWeightsKind
  15456. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  15457. *
  15458. * Returns the Mesh.
  15459. */
  15460. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  15461. /**
  15462. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  15463. * If the mesh has no geometry, it is simply returned as it is.
  15464. * The `data` are either a numeric array either a Float32Array.
  15465. * No new underlying VertexBuffer object is created.
  15466. * 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.
  15467. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  15468. *
  15469. * Possible `kind` values :
  15470. * - BABYLON.VertexBuffer.PositionKind
  15471. * - BABYLON.VertexBuffer.UVKind
  15472. * - BABYLON.VertexBuffer.UV2Kind
  15473. * - BABYLON.VertexBuffer.UV3Kind
  15474. * - BABYLON.VertexBuffer.UV4Kind
  15475. * - BABYLON.VertexBuffer.UV5Kind
  15476. * - BABYLON.VertexBuffer.UV6Kind
  15477. * - BABYLON.VertexBuffer.ColorKind
  15478. * - BABYLON.VertexBuffer.MatricesIndicesKind
  15479. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  15480. * - BABYLON.VertexBuffer.MatricesWeightsKind
  15481. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  15482. *
  15483. * Returns the Mesh.
  15484. */
  15485. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  15486. /**
  15487. * Sets the mesh indices.
  15488. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  15489. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  15490. * This method creates a new index buffer each call.
  15491. * Returns the Mesh.
  15492. */
  15493. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  15494. /** Returns false by default, used by the class Mesh.
  15495. * Returns a boolean
  15496. */
  15497. isVerticesDataPresent(kind: string): boolean;
  15498. /**
  15499. * Returns the mesh BoundingInfo object or creates a new one and returns it if undefined.
  15500. * Returns a BoundingInfo
  15501. */
  15502. getBoundingInfo(): BoundingInfo;
  15503. /**
  15504. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units).
  15505. * @param includeDescendants Take the hierarchy's bounding box instead of the mesh's bounding box.
  15506. */
  15507. normalizeToUnitCube(includeDescendants?: boolean): AbstractMesh;
  15508. /**
  15509. * Sets a mesh new object BoundingInfo.
  15510. * Returns the AbstractMesh.
  15511. */
  15512. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  15513. readonly useBones: boolean;
  15514. _preActivate(): void;
  15515. _preActivateForIntermediateRendering(renderId: number): void;
  15516. _activate(renderId: number): void;
  15517. /**
  15518. * Returns the latest update of the World matrix
  15519. * Returns a Matrix.
  15520. */
  15521. getWorldMatrix(): Matrix;
  15522. /**
  15523. * Returns the latest update of the World matrix determinant.
  15524. */
  15525. protected _getWorldMatrixDeterminant(): number;
  15526. /**
  15527. * Perform relative position change from the point of view of behind the front of the mesh.
  15528. * This is performed taking into account the meshes current rotation, so you do not have to care.
  15529. * Supports definition of mesh facing forward or backward.
  15530. * @param {number} amountRight
  15531. * @param {number} amountUp
  15532. * @param {number} amountForward
  15533. *
  15534. * Returns the AbstractMesh.
  15535. */
  15536. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  15537. /**
  15538. * Calculate relative position change from the point of view of behind the front of the mesh.
  15539. * This is performed taking into account the meshes current rotation, so you do not have to care.
  15540. * Supports definition of mesh facing forward or backward.
  15541. * @param {number} amountRight
  15542. * @param {number} amountUp
  15543. * @param {number} amountForward
  15544. *
  15545. * Returns a new Vector3.
  15546. */
  15547. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  15548. /**
  15549. * Perform relative rotation change from the point of view of behind the front of the mesh.
  15550. * Supports definition of mesh facing forward or backward.
  15551. * @param {number} flipBack
  15552. * @param {number} twirlClockwise
  15553. * @param {number} tiltRight
  15554. *
  15555. * Returns the AbstractMesh.
  15556. */
  15557. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  15558. /**
  15559. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  15560. * Supports definition of mesh facing forward or backward.
  15561. * @param {number} flipBack
  15562. * @param {number} twirlClockwise
  15563. * @param {number} tiltRight
  15564. *
  15565. * Returns a new Vector3.
  15566. */
  15567. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  15568. /**
  15569. * Return the minimum and maximum world vectors of the entire hierarchy under current mesh
  15570. * @param includeDescendants Include bounding info from descendants as well (true by default).
  15571. */
  15572. getHierarchyBoundingVectors(includeDescendants?: boolean): {
  15573. min: Vector3;
  15574. max: Vector3;
  15575. };
  15576. /**
  15577. * Updates the mesh BoundingInfo object and all its children BoundingInfo objects also.
  15578. * Returns the AbstractMesh.
  15579. */
  15580. _updateBoundingInfo(): AbstractMesh;
  15581. /**
  15582. * Update a mesh's children BoundingInfo objects only.
  15583. * Returns the AbstractMesh.
  15584. */
  15585. _updateSubMeshesBoundingInfo(matrix: Matrix): AbstractMesh;
  15586. protected _afterComputeWorldMatrix(): void;
  15587. /**
  15588. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  15589. * A mesh is in the frustum if its bounding box intersects the frustum.
  15590. * Boolean returned.
  15591. */
  15592. isInFrustum(frustumPlanes: Plane[]): boolean;
  15593. /**
  15594. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  15595. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  15596. * Boolean returned.
  15597. */
  15598. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  15599. /**
  15600. * True if the mesh intersects another mesh or a SolidParticle object.
  15601. * 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)
  15602. * includeDescendants can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  15603. * Returns a boolean.
  15604. */
  15605. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  15606. /**
  15607. * Returns true if the passed point (Vector3) is inside the mesh bounding box.
  15608. * Returns a boolean.
  15609. */
  15610. intersectsPoint(point: Vector3): boolean;
  15611. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  15612. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  15613. /**
  15614. * Returns the distance from the mesh to the active camera.
  15615. * Returns a float.
  15616. */
  15617. getDistanceToCamera(camera?: Nullable<Camera>): number;
  15618. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  15619. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  15620. /**
  15621. * Property checkCollisions : Boolean, whether the camera should check the collisions against the mesh.
  15622. * Default `false`.
  15623. */
  15624. checkCollisions: boolean;
  15625. /**
  15626. * Gets Collider object used to compute collisions (not physics)
  15627. */
  15628. readonly collider: Collider;
  15629. moveWithCollisions(displacement: Vector3): AbstractMesh;
  15630. private _onCollisionPositionChange;
  15631. /**
  15632. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  15633. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree.
  15634. * Returns an Octree of submeshes.
  15635. */
  15636. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  15637. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  15638. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  15639. _checkCollision(collider: Collider): AbstractMesh;
  15640. _generatePointsArray(): boolean;
  15641. /**
  15642. * Checks if the passed Ray intersects with the mesh.
  15643. * Returns an object PickingInfo.
  15644. */
  15645. intersects(ray: Ray, fastCheck?: boolean): PickingInfo;
  15646. /**
  15647. * Clones the mesh, used by the class Mesh.
  15648. * Just returns `null` for an AbstractMesh.
  15649. */
  15650. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  15651. /**
  15652. * Disposes all the mesh submeshes.
  15653. * Returns the AbstractMesh.
  15654. */
  15655. releaseSubMeshes(): AbstractMesh;
  15656. /**
  15657. * Releases resources associated with this abstract mesh.
  15658. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  15659. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  15660. */
  15661. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  15662. /**
  15663. * Adds the passed mesh as a child to the current mesh.
  15664. * Returns the AbstractMesh.
  15665. */
  15666. addChild(mesh: AbstractMesh): AbstractMesh;
  15667. /**
  15668. * Removes the passed mesh from the current mesh children list.
  15669. * Returns the AbstractMesh.
  15670. */
  15671. removeChild(mesh: AbstractMesh): AbstractMesh;
  15672. /**
  15673. * Initialize the facet data arrays : facetNormals, facetPositions and facetPartitioning.
  15674. * Returns the AbstractMesh.
  15675. */
  15676. private _initFacetData();
  15677. /**
  15678. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  15679. * This method can be called within the render loop.
  15680. * 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.
  15681. * Returns the AbstractMesh.
  15682. */
  15683. updateFacetData(): AbstractMesh;
  15684. /**
  15685. * Returns the facetLocalNormals array.
  15686. * The normals are expressed in the mesh local space.
  15687. */
  15688. getFacetLocalNormals(): Vector3[];
  15689. /**
  15690. * Returns the facetLocalPositions array.
  15691. * The facet positions are expressed in the mesh local space.
  15692. */
  15693. getFacetLocalPositions(): Vector3[];
  15694. /**
  15695. * Returns the facetLocalPartioning array.
  15696. */
  15697. getFacetLocalPartitioning(): number[][];
  15698. /**
  15699. * Returns the i-th facet position in the world system.
  15700. * This method allocates a new Vector3 per call.
  15701. */
  15702. getFacetPosition(i: number): Vector3;
  15703. /**
  15704. * Sets the reference Vector3 with the i-th facet position in the world system.
  15705. * Returns the AbstractMesh.
  15706. */
  15707. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  15708. /**
  15709. * Returns the i-th facet normal in the world system.
  15710. * This method allocates a new Vector3 per call.
  15711. */
  15712. getFacetNormal(i: number): Vector3;
  15713. /**
  15714. * Sets the reference Vector3 with the i-th facet normal in the world system.
  15715. * Returns the AbstractMesh.
  15716. */
  15717. getFacetNormalToRef(i: number, ref: Vector3): this;
  15718. /**
  15719. * 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).
  15720. */
  15721. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  15722. /**
  15723. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found.
  15724. * If the parameter projected (vector3) is passed, it is set as the (x,y,z) World projection on the facet.
  15725. * 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.
  15726. * If facing and checkFace are true, only the facet "facing" to (x, y, z) are returned : positive dot (x, y, z) * facet position.
  15727. * 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.
  15728. */
  15729. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  15730. /**
  15731. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found.
  15732. * If the parameter projected (vector3) is passed, it is set as the (x,y,z) local projection on the facet.
  15733. * 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.
  15734. * If facing and checkFace are true, only the facet "facing" to (x, y, z) are returned : positive dot (x, y, z) * facet position.
  15735. * 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.
  15736. */
  15737. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  15738. /**
  15739. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  15740. */
  15741. getFacetDataParameters(): any;
  15742. /**
  15743. * Disables the feature FacetData and frees the related memory.
  15744. * Returns the AbstractMesh.
  15745. */
  15746. disableFacetData(): AbstractMesh;
  15747. /**
  15748. * Updates the AbstractMesh indices array. Actually, used by the Mesh object.
  15749. * Returns the mesh.
  15750. */
  15751. updateIndices(indices: IndicesArray): AbstractMesh;
  15752. /**
  15753. * The mesh Geometry. Actually used by the Mesh object.
  15754. * Returns a blank geometry object.
  15755. */
  15756. /**
  15757. * Creates new normals data for the mesh.
  15758. * @param updatable.
  15759. */
  15760. createNormals(updatable: boolean): void;
  15761. /**
  15762. * Align the mesh with a normal.
  15763. * Returns the mesh.
  15764. */
  15765. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  15766. protected checkOcclusionQuery(): void;
  15767. }
  15768. }
  15769. declare module BABYLON {
  15770. class Buffer {
  15771. private _engine;
  15772. private _buffer;
  15773. private _data;
  15774. private _updatable;
  15775. private _strideSize;
  15776. private _instanced;
  15777. constructor(engine: any, data: FloatArray, updatable: boolean, stride: number, postponeInternalCreation?: boolean, instanced?: boolean);
  15778. /**
  15779. * Create a new {BABYLON.VertexBuffer} based on the current buffer
  15780. * @param kind defines the vertex buffer kind (position, normal, etc.)
  15781. * @param offset defines offset in the buffer (0 by default)
  15782. * @param size defines the size in floats of attributes (position is 3 for instance)
  15783. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  15784. * @param instanced defines if the vertex buffer contains indexed data
  15785. * @returns the new vertex buffer
  15786. */
  15787. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean): VertexBuffer;
  15788. isUpdatable(): boolean;
  15789. getData(): Nullable<FloatArray>;
  15790. getBuffer(): Nullable<WebGLBuffer>;
  15791. getStrideSize(): number;
  15792. create(data?: Nullable<FloatArray>): void;
  15793. _rebuild(): void;
  15794. update(data: FloatArray): void;
  15795. updateDirectly(data: Float32Array, offset: number, vertexCount?: number): void;
  15796. dispose(): void;
  15797. }
  15798. }
  15799. declare module BABYLON {
  15800. class CSG {
  15801. private polygons;
  15802. matrix: Matrix;
  15803. position: Vector3;
  15804. rotation: Vector3;
  15805. rotationQuaternion: Nullable<Quaternion>;
  15806. scaling: Vector3;
  15807. static FromMesh(mesh: Mesh): CSG;
  15808. private static FromPolygons(polygons);
  15809. clone(): CSG;
  15810. union(csg: CSG): CSG;
  15811. unionInPlace(csg: CSG): void;
  15812. subtract(csg: CSG): CSG;
  15813. subtractInPlace(csg: CSG): void;
  15814. intersect(csg: CSG): CSG;
  15815. intersectInPlace(csg: CSG): void;
  15816. inverse(): CSG;
  15817. inverseInPlace(): void;
  15818. copyTransformAttributes(csg: CSG): CSG;
  15819. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  15820. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  15821. }
  15822. }
  15823. declare module BABYLON {
  15824. /**
  15825. * Class used to store geometry data (vertex buffers + index buffer)
  15826. */
  15827. class Geometry implements IGetSetVerticesData {
  15828. /**
  15829. * Gets or sets the unique ID of the geometry
  15830. */
  15831. id: string;
  15832. /**
  15833. * Gets the delay loading state of the geometry (none by default which means not delayed)
  15834. */
  15835. delayLoadState: number;
  15836. /**
  15837. * Gets the file containing the data to load when running in delay load state
  15838. */
  15839. delayLoadingFile: Nullable<string>;
  15840. /**
  15841. * Callback called when the geometry is updated
  15842. */
  15843. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  15844. private _scene;
  15845. private _engine;
  15846. private _meshes;
  15847. private _totalVertices;
  15848. private _indices;
  15849. private _vertexBuffers;
  15850. private _isDisposed;
  15851. private _extend;
  15852. private _boundingBias;
  15853. /** @ignore */
  15854. _delayInfo: Array<string>;
  15855. private _indexBuffer;
  15856. private _indexBufferIsUpdatable;
  15857. /** @ignore */
  15858. _boundingInfo: Nullable<BoundingInfo>;
  15859. /** @ignore */
  15860. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  15861. /** @ignore */
  15862. _softwareSkinningRenderId: number;
  15863. private _vertexArrayObjects;
  15864. private _updatable;
  15865. /** @ignore */
  15866. _positions: Nullable<Vector3[]>;
  15867. /**
  15868. * 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
  15869. */
  15870. /**
  15871. * 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
  15872. */
  15873. boundingBias: Vector2;
  15874. /**
  15875. * Static function used to attach a new empty geometry to a mesh
  15876. * @param mesh defines the mesh to attach the geometry to
  15877. * @returns the new {BABYLON.Geometry}
  15878. */
  15879. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  15880. /**
  15881. * Creates a new geometry
  15882. * @param id defines the unique ID
  15883. * @param scene defines the hosting scene
  15884. * @param vertexData defines the {BABYLON.VertexData} used to get geometry data
  15885. * @param updatable defines if geometry must be updatable (false by default)
  15886. * @param mesh defines the mesh that will be associated with the geometry
  15887. */
  15888. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  15889. /**
  15890. * Gets the current extend of the geometry
  15891. */
  15892. readonly extend: {
  15893. minimum: Vector3;
  15894. maximum: Vector3;
  15895. };
  15896. /**
  15897. * Gets the hosting scene
  15898. * @returns the hosting {BABYLON.Scene}
  15899. */
  15900. getScene(): Scene;
  15901. /**
  15902. * Gets the hosting engine
  15903. * @returns the hosting {BABYLON.Engine}
  15904. */
  15905. getEngine(): Engine;
  15906. /**
  15907. * Defines if the geometry is ready to use
  15908. * @returns true if the geometry is ready to be used
  15909. */
  15910. isReady(): boolean;
  15911. /**
  15912. * Gets a value indicating that the geometry should not be serialized
  15913. */
  15914. readonly doNotSerialize: boolean;
  15915. /** @ignore */
  15916. _rebuild(): void;
  15917. /**
  15918. * Affects all gemetry data in one call
  15919. * @param vertexData defines the geometry data
  15920. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  15921. */
  15922. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  15923. /**
  15924. * Set specific vertex data
  15925. * @param kind defines the data kind (Position, normal, etc...)
  15926. * @param data defines the vertex data to use
  15927. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  15928. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  15929. */
  15930. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  15931. /**
  15932. * Removes a specific vertex data
  15933. * @param kind defines the data kind (Position, normal, etc...)
  15934. */
  15935. removeVerticesData(kind: string): void;
  15936. /**
  15937. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  15938. * @param buffer defines the vertex buffer to use
  15939. */
  15940. setVerticesBuffer(buffer: VertexBuffer): void;
  15941. /**
  15942. * Update a specific vertex buffer
  15943. * This function will directly update the underlying WebGLBuffer according to the passed numeric array or Float32Array
  15944. * It will do nothing if the buffer is not updatable
  15945. * @param kind defines the data kind (Position, normal, etc...)
  15946. * @param data defines the data to use
  15947. * @param offset defines the offset in the target buffer where to store the data
  15948. */
  15949. updateVerticesDataDirectly(kind: string, data: Float32Array, offset: number): void;
  15950. /**
  15951. * Update a specific vertex buffer
  15952. * This function will create a new buffer if the current one is not updatable
  15953. * @param kind defines the data kind (Position, normal, etc...)
  15954. * @param data defines the data to use
  15955. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  15956. */
  15957. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  15958. private updateBoundingInfo(updateExtends, data);
  15959. /** @ignore */
  15960. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<WebGLBuffer>): void;
  15961. /**
  15962. * Gets total number of vertices
  15963. * @returns the total number of vertices
  15964. */
  15965. getTotalVertices(): number;
  15966. /**
  15967. * Gets a specific vertex data attached to this geometry
  15968. * @param kind defines the data kind (Position, normal, etc...)
  15969. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  15970. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  15971. * @returns a float array containing vertex data
  15972. */
  15973. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  15974. /**
  15975. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  15976. * @param kind defines the data kind (Position, normal, etc...)
  15977. * @returns true if the vertex buffer with the specified kind is updatable
  15978. */
  15979. isVertexBufferUpdatable(kind: string): boolean;
  15980. /**
  15981. * Gets a specific vertex buffer
  15982. * @param kind defines the data kind (Position, normal, etc...)
  15983. * @returns a {BABYLON.VertexBuffer}
  15984. */
  15985. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  15986. /**
  15987. * Returns all vertex buffers
  15988. * @return an object holding all vertex buffers indexed by kind
  15989. */
  15990. getVertexBuffers(): Nullable<{
  15991. [key: string]: VertexBuffer;
  15992. }>;
  15993. /**
  15994. * Gets a boolean indicating if specific vertex buffer is present
  15995. * @param kind defines the data kind (Position, normal, etc...)
  15996. * @returns true if data is present
  15997. */
  15998. isVerticesDataPresent(kind: string): boolean;
  15999. /**
  16000. * Gets a list of all attached data kinds (Position, normal, etc...)
  16001. * @returns a list of string containing all kinds
  16002. */
  16003. getVerticesDataKinds(): string[];
  16004. /**
  16005. * Update index buffer
  16006. * @param indices defines the indices to store in the index buffer
  16007. * @param offset defines the offset in the target buffer where to store the data
  16008. */
  16009. updateIndices(indices: IndicesArray, offset?: number): void;
  16010. /**
  16011. * Creates a new index buffer
  16012. * @param indices defines the indices to store in the index buffer
  16013. * @param totalVertices defines the total number of vertices (could be null)
  16014. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  16015. */
  16016. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  16017. /**
  16018. * Return the total number of indices
  16019. * @returns the total number of indices
  16020. */
  16021. getTotalIndices(): number;
  16022. /**
  16023. * Gets the index buffer array
  16024. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  16025. * @returns the index buffer array
  16026. */
  16027. getIndices(copyWhenShared?: boolean): Nullable<IndicesArray>;
  16028. /**
  16029. * Gets the index buffer
  16030. * @return the index buffer
  16031. */
  16032. getIndexBuffer(): Nullable<WebGLBuffer>;
  16033. /** @ignore */
  16034. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  16035. /**
  16036. * Release the associated resources for a specific mesh
  16037. * @param mesh defines the source mesh
  16038. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  16039. */
  16040. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  16041. /**
  16042. * Apply current geometry to a given mesh
  16043. * @param mesh defines the mesh to apply geometry to
  16044. */
  16045. applyToMesh(mesh: Mesh): void;
  16046. private updateExtend(data?, stride?);
  16047. private _applyToMesh(mesh);
  16048. private notifyUpdate(kind?);
  16049. /**
  16050. * Load the geometry if it was flagged as delay loaded
  16051. * @param scene defines the hosting scene
  16052. * @param onLoaded defines a callback called when the geometry is loaded
  16053. */
  16054. load(scene: Scene, onLoaded?: () => void): void;
  16055. private _queueLoad(scene, onLoaded?);
  16056. /**
  16057. * Invert the geometry to move from a right handed system to a left handed one.
  16058. */
  16059. toLeftHanded(): void;
  16060. /** @ignore */
  16061. _resetPointsArrayCache(): void;
  16062. /** @ignore */
  16063. _generatePointsArray(): boolean;
  16064. /**
  16065. * Gets a value indicating if the geometry is disposed
  16066. * @returns true if the geometry was disposed
  16067. */
  16068. isDisposed(): boolean;
  16069. private _disposeVertexArrayObjects();
  16070. /**
  16071. * Free all associated resources
  16072. */
  16073. dispose(): void;
  16074. /**
  16075. * Clone the current geometry into a new geometry
  16076. * @param id defines the unique ID of the new geometry
  16077. * @returns a new geometry object
  16078. */
  16079. copy(id: string): Geometry;
  16080. /**
  16081. * Serialize the current geometry info (and not the vertices data) into a JSON object
  16082. * @return a JSON representation of the current geometry data (without the vertices data)
  16083. */
  16084. serialize(): any;
  16085. private toNumberArray(origin);
  16086. /**
  16087. * Serialize all vertices data into a JSON oject
  16088. * @returns a JSON representation of the current geometry data
  16089. */
  16090. serializeVerticeData(): any;
  16091. /**
  16092. * Extracts a clone of a mesh geometry
  16093. * @param mesh defines the source mesh
  16094. * @param id defines the unique ID of the new geometry object
  16095. * @returns the new geometry object
  16096. */
  16097. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  16098. /**
  16099. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  16100. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  16101. * Be aware Math.random() could cause collisions, but:
  16102. * "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"
  16103. * @returns a string containing a new GUID
  16104. */
  16105. static RandomId(): string;
  16106. /** @ignore */
  16107. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  16108. private static _CleanMatricesWeights(parsedGeometry, mesh);
  16109. /**
  16110. * Create a new geometry from persisted data (Using .babylon file format)
  16111. * @param parsedVertexData defines the persisted data
  16112. * @param scene defines the hosting scene
  16113. * @param rootUrl defines the root url to use to load assets (like delayed data)
  16114. * @returns the new geometry object
  16115. */
  16116. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  16117. }
  16118. /**
  16119. * Abstract class used to provide common services for all typed geometries
  16120. */
  16121. class _PrimitiveGeometry extends Geometry {
  16122. private _canBeRegenerated;
  16123. private _beingRegenerated;
  16124. /**
  16125. * Creates a new typed geometry
  16126. * @param id defines the unique ID of the geometry
  16127. * @param scene defines the hosting scene
  16128. * @param _canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  16129. * @param mesh defines the hosting mesh (can be null)
  16130. */
  16131. constructor(id: string, scene: Scene, _canBeRegenerated?: boolean, mesh?: Nullable<Mesh>);
  16132. /**
  16133. * Gets a value indicating if the geometry supports being regenerated with new parameters (false by default)
  16134. * @returns true if the geometry can be regenerated
  16135. */
  16136. canBeRegenerated(): boolean;
  16137. /**
  16138. * If the geometry supports regeneration, the function will recreates the geometry with updated parameter values
  16139. */
  16140. regenerate(): void;
  16141. /**
  16142. * Clone the geometry
  16143. * @param id defines the unique ID of the new geometry
  16144. * @returns the new geometry
  16145. */
  16146. asNewGeometry(id: string): Geometry;
  16147. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  16148. setVerticesData(kind: string, data: FloatArray, updatable?: boolean): void;
  16149. /** @ignore */
  16150. _regenerateVertexData(): VertexData;
  16151. copy(id: string): Geometry;
  16152. serialize(): any;
  16153. }
  16154. /**
  16155. * Creates a ribbon geometry
  16156. * @description See http://doc.babylonjs.com/how_to/ribbon_tutorial, http://doc.babylonjs.com/resources/maths_make_ribbons
  16157. */
  16158. class RibbonGeometry extends _PrimitiveGeometry {
  16159. /**
  16160. * Defines the array of paths to use
  16161. */
  16162. pathArray: Vector3[][];
  16163. /**
  16164. * Defines if the last and first points of each path in your pathArray must be joined
  16165. */
  16166. closeArray: boolean;
  16167. /**
  16168. * Defines if the last and first points of each path in your pathArray must be joined
  16169. */
  16170. closePath: boolean;
  16171. /**
  16172. * Defines the offset between points
  16173. */
  16174. offset: number;
  16175. /**
  16176. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  16177. */
  16178. side: number;
  16179. /**
  16180. * Creates a ribbon geometry
  16181. * @param id defines the unique ID of the geometry
  16182. * @param scene defines the hosting scene
  16183. * @param pathArray defines the array of paths to use
  16184. * @param closeArray defines if the last path and the first path must be joined
  16185. * @param closePath defines if the last and first points of each path in your pathArray must be joined
  16186. * @param offset defines the offset between points
  16187. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  16188. * @param mesh defines the hosting mesh (can be null)
  16189. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  16190. */
  16191. constructor(id: string, scene: Scene,
  16192. /**
  16193. * Defines the array of paths to use
  16194. */
  16195. pathArray: Vector3[][],
  16196. /**
  16197. * Defines if the last and first points of each path in your pathArray must be joined
  16198. */
  16199. closeArray: boolean,
  16200. /**
  16201. * Defines if the last and first points of each path in your pathArray must be joined
  16202. */
  16203. closePath: boolean,
  16204. /**
  16205. * Defines the offset between points
  16206. */
  16207. offset: number, canBeRegenerated?: boolean, mesh?: Mesh,
  16208. /**
  16209. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  16210. */
  16211. side?: number);
  16212. /** @ignore */
  16213. _regenerateVertexData(): VertexData;
  16214. copy(id: string): Geometry;
  16215. }
  16216. /**
  16217. * Creates a box geometry
  16218. * @description see http://doc.babylonjs.com/how_to/set_shapes#box
  16219. */
  16220. class BoxGeometry extends _PrimitiveGeometry {
  16221. /**
  16222. * Defines the zise of the box (width, height and depth are the same)
  16223. */
  16224. size: number;
  16225. /**
  16226. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  16227. */
  16228. side: number;
  16229. /**
  16230. * Creates a box geometry
  16231. * @param id defines the unique ID of the geometry
  16232. * @param scene defines the hosting scene
  16233. * @param size defines the zise of the box (width, height and depth are the same)
  16234. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  16235. * @param mesh defines the hosting mesh (can be null)
  16236. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  16237. */
  16238. constructor(id: string, scene: Scene,
  16239. /**
  16240. * Defines the zise of the box (width, height and depth are the same)
  16241. */
  16242. size: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  16243. /**
  16244. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  16245. */
  16246. side?: number);
  16247. _regenerateVertexData(): VertexData;
  16248. copy(id: string): Geometry;
  16249. serialize(): any;
  16250. static Parse(parsedBox: any, scene: Scene): Nullable<BoxGeometry>;
  16251. }
  16252. /**
  16253. * Creates a sphere geometry
  16254. * @description see http://doc.babylonjs.com/how_to/set_shapes#sphere
  16255. */
  16256. class SphereGeometry extends _PrimitiveGeometry {
  16257. /**
  16258. * Defines the number of segments to use to create the sphere
  16259. */
  16260. segments: number;
  16261. /**
  16262. * Defines the diameter of the sphere
  16263. */
  16264. diameter: number;
  16265. /**
  16266. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  16267. */
  16268. side: number;
  16269. /**
  16270. * Create a new sphere geometry
  16271. * @param id defines the unique ID of the geometry
  16272. * @param scene defines the hosting scene
  16273. * @param segments defines the number of segments to use to create the sphere
  16274. * @param diameter defines the diameter of the sphere
  16275. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  16276. * @param mesh defines the hosting mesh (can be null)
  16277. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  16278. */
  16279. constructor(id: string, scene: Scene,
  16280. /**
  16281. * Defines the number of segments to use to create the sphere
  16282. */
  16283. segments: number,
  16284. /**
  16285. * Defines the diameter of the sphere
  16286. */
  16287. diameter: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  16288. /**
  16289. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  16290. */
  16291. side?: number);
  16292. _regenerateVertexData(): VertexData;
  16293. copy(id: string): Geometry;
  16294. serialize(): any;
  16295. static Parse(parsedSphere: any, scene: Scene): Nullable<SphereGeometry>;
  16296. }
  16297. /**
  16298. * Creates a disc geometry
  16299. * @description see http://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  16300. */
  16301. class DiscGeometry extends _PrimitiveGeometry {
  16302. /**
  16303. * Defines the radius of the disc
  16304. */
  16305. radius: number;
  16306. /**
  16307. * Defines the tesselation factor to apply to the disc
  16308. */
  16309. tessellation: number;
  16310. /**
  16311. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  16312. */
  16313. side: number;
  16314. /**
  16315. * Creates a new disc geometry
  16316. * @param id defines the unique ID of the geometry
  16317. * @param scene defines the hosting scene
  16318. * @param radius defines the radius of the disc
  16319. * @param tessellation defines the tesselation factor to apply to the disc
  16320. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  16321. * @param mesh defines the hosting mesh (can be null)
  16322. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  16323. */
  16324. constructor(id: string, scene: Scene,
  16325. /**
  16326. * Defines the radius of the disc
  16327. */
  16328. radius: number,
  16329. /**
  16330. * Defines the tesselation factor to apply to the disc
  16331. */
  16332. tessellation: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  16333. /**
  16334. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  16335. */
  16336. side?: number);
  16337. _regenerateVertexData(): VertexData;
  16338. copy(id: string): Geometry;
  16339. }
  16340. /**
  16341. * Creates a new cylinder geometry
  16342. * @description see http://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  16343. */
  16344. class CylinderGeometry extends _PrimitiveGeometry {
  16345. /**
  16346. * Defines the height of the cylinder
  16347. */
  16348. height: number;
  16349. /**
  16350. * Defines the diameter of the cylinder's top cap
  16351. */
  16352. diameterTop: number;
  16353. /**
  16354. * Defines the diameter of the cylinder's bottom cap
  16355. */
  16356. diameterBottom: number;
  16357. /**
  16358. * Defines the tessellation factor to apply to the cylinder
  16359. */
  16360. tessellation: number;
  16361. /**
  16362. * Defines the number of subdivisions to apply to the cylinder (1 by default)
  16363. */
  16364. subdivisions: number;
  16365. /**
  16366. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  16367. */
  16368. side: number;
  16369. /**
  16370. * Creates a new cylinder geometry
  16371. * @param id defines the unique ID of the geometry
  16372. * @param scene defines the hosting scene
  16373. * @param height defines the height of the cylinder
  16374. * @param diameterTop defines the diameter of the cylinder's top cap
  16375. * @param diameterBottom defines the diameter of the cylinder's bottom cap
  16376. * @param tessellation defines the tessellation factor to apply to the cylinder (number of radial sides)
  16377. * @param subdivisions defines the number of subdivisions to apply to the cylinder (number of rings) (1 by default)
  16378. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  16379. * @param mesh defines the hosting mesh (can be null)
  16380. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  16381. */
  16382. constructor(id: string, scene: Scene,
  16383. /**
  16384. * Defines the height of the cylinder
  16385. */
  16386. height: number,
  16387. /**
  16388. * Defines the diameter of the cylinder's top cap
  16389. */
  16390. diameterTop: number,
  16391. /**
  16392. * Defines the diameter of the cylinder's bottom cap
  16393. */
  16394. diameterBottom: number,
  16395. /**
  16396. * Defines the tessellation factor to apply to the cylinder
  16397. */
  16398. tessellation: number,
  16399. /**
  16400. * Defines the number of subdivisions to apply to the cylinder (1 by default)
  16401. */
  16402. subdivisions?: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  16403. /**
  16404. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  16405. */
  16406. side?: number);
  16407. _regenerateVertexData(): VertexData;
  16408. copy(id: string): Geometry;
  16409. serialize(): any;
  16410. static Parse(parsedCylinder: any, scene: Scene): Nullable<CylinderGeometry>;
  16411. }
  16412. /**
  16413. * Creates a new torus geometry
  16414. * @description see http://doc.babylonjs.com/how_to/set_shapes#torus
  16415. */
  16416. class TorusGeometry extends _PrimitiveGeometry {
  16417. /**
  16418. * Defines the diameter of the torus
  16419. */
  16420. diameter: number;
  16421. /**
  16422. * Defines the thickness of the torus (ie. internal diameter)
  16423. */
  16424. thickness: number;
  16425. /**
  16426. * Defines the tesselation factor to apply to the torus
  16427. */
  16428. tessellation: number;
  16429. /**
  16430. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  16431. */
  16432. side: number;
  16433. /**
  16434. * Creates a new torus geometry
  16435. * @param id defines the unique ID of the geometry
  16436. * @param scene defines the hosting scene
  16437. * @param diameter defines the diameter of the torus
  16438. * @param thickness defines the thickness of the torus (ie. internal diameter)
  16439. * @param tessellation defines the tesselation factor to apply to the torus (number of segments along the circle)
  16440. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  16441. * @param mesh defines the hosting mesh (can be null)
  16442. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  16443. */
  16444. constructor(id: string, scene: Scene,
  16445. /**
  16446. * Defines the diameter of the torus
  16447. */
  16448. diameter: number,
  16449. /**
  16450. * Defines the thickness of the torus (ie. internal diameter)
  16451. */
  16452. thickness: number,
  16453. /**
  16454. * Defines the tesselation factor to apply to the torus
  16455. */
  16456. tessellation: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  16457. /**
  16458. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  16459. */
  16460. side?: number);
  16461. _regenerateVertexData(): VertexData;
  16462. copy(id: string): Geometry;
  16463. serialize(): any;
  16464. static Parse(parsedTorus: any, scene: Scene): Nullable<TorusGeometry>;
  16465. }
  16466. /**
  16467. * Creates a new ground geometry
  16468. * @description see http://doc.babylonjs.com/how_to/set_shapes#ground
  16469. */
  16470. class GroundGeometry extends _PrimitiveGeometry {
  16471. /**
  16472. * Defines the width of the ground
  16473. */
  16474. width: number;
  16475. /**
  16476. * Defines the height of the ground
  16477. */
  16478. height: number;
  16479. /**
  16480. * Defines the subdivisions to apply to the ground
  16481. */
  16482. subdivisions: number;
  16483. /**
  16484. * Creates a new ground geometry
  16485. * @param id defines the unique ID of the geometry
  16486. * @param scene defines the hosting scene
  16487. * @param width defines the width of the ground
  16488. * @param height defines the height of the ground
  16489. * @param subdivisions defines the subdivisions to apply to the ground
  16490. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  16491. * @param mesh defines the hosting mesh (can be null)
  16492. */
  16493. constructor(id: string, scene: Scene,
  16494. /**
  16495. * Defines the width of the ground
  16496. */
  16497. width: number,
  16498. /**
  16499. * Defines the height of the ground
  16500. */
  16501. height: number,
  16502. /**
  16503. * Defines the subdivisions to apply to the ground
  16504. */
  16505. subdivisions: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>);
  16506. _regenerateVertexData(): VertexData;
  16507. copy(id: string): Geometry;
  16508. serialize(): any;
  16509. static Parse(parsedGround: any, scene: Scene): Nullable<GroundGeometry>;
  16510. }
  16511. /**
  16512. * Creates a tiled ground geometry
  16513. * @description see http://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  16514. */
  16515. class TiledGroundGeometry extends _PrimitiveGeometry {
  16516. /**
  16517. * Defines the minimum value on X axis
  16518. */
  16519. xmin: number;
  16520. /**
  16521. * Defines the minimum value on Z axis
  16522. */
  16523. zmin: number;
  16524. /**
  16525. * Defines the maximum value on X axis
  16526. */
  16527. xmax: number;
  16528. /**
  16529. * Defines the maximum value on Z axis
  16530. */
  16531. zmax: number;
  16532. /**
  16533. * Defines the subdivisions to apply to the ground
  16534. */
  16535. subdivisions: {
  16536. w: number;
  16537. h: number;
  16538. };
  16539. /**
  16540. * Defines the precision to use when computing the tiles
  16541. */
  16542. precision: {
  16543. w: number;
  16544. h: number;
  16545. };
  16546. /**
  16547. * Creates a tiled ground geometry
  16548. * @param id defines the unique ID of the geometry
  16549. * @param scene defines the hosting scene
  16550. * @param xmin defines the minimum value on X axis
  16551. * @param zmin defines the minimum value on Z axis
  16552. * @param xmax defines the maximum value on X axis
  16553. * @param zmax defines the maximum value on Z axis
  16554. * @param subdivisions defines the subdivisions to apply to the ground (number of subdivisions (tiles) on the height and the width of the map)
  16555. * @param precision defines the precision to use when computing the tiles
  16556. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  16557. * @param mesh defines the hosting mesh (can be null)
  16558. */
  16559. constructor(id: string, scene: Scene,
  16560. /**
  16561. * Defines the minimum value on X axis
  16562. */
  16563. xmin: number,
  16564. /**
  16565. * Defines the minimum value on Z axis
  16566. */
  16567. zmin: number,
  16568. /**
  16569. * Defines the maximum value on X axis
  16570. */
  16571. xmax: number,
  16572. /**
  16573. * Defines the maximum value on Z axis
  16574. */
  16575. zmax: number,
  16576. /**
  16577. * Defines the subdivisions to apply to the ground
  16578. */
  16579. subdivisions: {
  16580. w: number;
  16581. h: number;
  16582. },
  16583. /**
  16584. * Defines the precision to use when computing the tiles
  16585. */
  16586. precision: {
  16587. w: number;
  16588. h: number;
  16589. }, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>);
  16590. _regenerateVertexData(): VertexData;
  16591. copy(id: string): Geometry;
  16592. }
  16593. /**
  16594. * Creates a plane geometry
  16595. * @description see http://doc.babylonjs.com/how_to/set_shapes#plane
  16596. */
  16597. class PlaneGeometry extends _PrimitiveGeometry {
  16598. /**
  16599. * Defines the size of the plane (width === height)
  16600. */
  16601. size: number;
  16602. /**
  16603. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  16604. */
  16605. side: number;
  16606. /**
  16607. * Creates a plane geometry
  16608. * @param id defines the unique ID of the geometry
  16609. * @param scene defines the hosting scene
  16610. * @param size defines the size of the plane (width === height)
  16611. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  16612. * @param mesh defines the hosting mesh (can be null)
  16613. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  16614. */
  16615. constructor(id: string, scene: Scene,
  16616. /**
  16617. * Defines the size of the plane (width === height)
  16618. */
  16619. size: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  16620. /**
  16621. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  16622. */
  16623. side?: number);
  16624. _regenerateVertexData(): VertexData;
  16625. copy(id: string): Geometry;
  16626. serialize(): any;
  16627. static Parse(parsedPlane: any, scene: Scene): Nullable<PlaneGeometry>;
  16628. }
  16629. /**
  16630. * Creates a torus knot geometry
  16631. * @description see http://doc.babylonjs.com/how_to/set_shapes#torus-knot
  16632. */
  16633. class TorusKnotGeometry extends _PrimitiveGeometry {
  16634. /**
  16635. * Defines the radius of the torus knot
  16636. */
  16637. radius: number;
  16638. /**
  16639. * Defines the thickness of the torus knot tube
  16640. */
  16641. tube: number;
  16642. /**
  16643. * Defines the number of radial segments
  16644. */
  16645. radialSegments: number;
  16646. /**
  16647. * Defines the number of tubular segments
  16648. */
  16649. tubularSegments: number;
  16650. /**
  16651. * Defines the first number of windings
  16652. */
  16653. p: number;
  16654. /**
  16655. * Defines the second number of windings
  16656. */
  16657. q: number;
  16658. /**
  16659. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  16660. */
  16661. side: number;
  16662. /**
  16663. * Creates a torus knot geometry
  16664. * @param id defines the unique ID of the geometry
  16665. * @param scene defines the hosting scene
  16666. * @param radius defines the radius of the torus knot
  16667. * @param tube defines the thickness of the torus knot tube
  16668. * @param radialSegments defines the number of radial segments
  16669. * @param tubularSegments defines the number of tubular segments
  16670. * @param p defines the first number of windings
  16671. * @param q defines the second number of windings
  16672. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  16673. * @param mesh defines the hosting mesh (can be null)
  16674. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  16675. */
  16676. constructor(id: string, scene: Scene,
  16677. /**
  16678. * Defines the radius of the torus knot
  16679. */
  16680. radius: number,
  16681. /**
  16682. * Defines the thickness of the torus knot tube
  16683. */
  16684. tube: number,
  16685. /**
  16686. * Defines the number of radial segments
  16687. */
  16688. radialSegments: number,
  16689. /**
  16690. * Defines the number of tubular segments
  16691. */
  16692. tubularSegments: number,
  16693. /**
  16694. * Defines the first number of windings
  16695. */
  16696. p: number,
  16697. /**
  16698. * Defines the second number of windings
  16699. */
  16700. q: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  16701. /**
  16702. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  16703. */
  16704. side?: number);
  16705. _regenerateVertexData(): VertexData;
  16706. copy(id: string): Geometry;
  16707. serialize(): any;
  16708. static Parse(parsedTorusKnot: any, scene: Scene): Nullable<TorusKnotGeometry>;
  16709. }
  16710. }
  16711. declare module BABYLON {
  16712. class GroundMesh extends Mesh {
  16713. generateOctree: boolean;
  16714. private _heightQuads;
  16715. _subdivisionsX: number;
  16716. _subdivisionsY: number;
  16717. _width: number;
  16718. _height: number;
  16719. _minX: number;
  16720. _maxX: number;
  16721. _minZ: number;
  16722. _maxZ: number;
  16723. constructor(name: string, scene: Scene);
  16724. getClassName(): string;
  16725. readonly subdivisions: number;
  16726. readonly subdivisionsX: number;
  16727. readonly subdivisionsY: number;
  16728. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  16729. /**
  16730. * Returns a height (y) value in the Worl system :
  16731. * the ground altitude at the coordinates (x, z) expressed in the World system.
  16732. * Returns the ground y position if (x, z) are outside the ground surface.
  16733. */
  16734. getHeightAtCoordinates(x: number, z: number): number;
  16735. /**
  16736. * Returns a normalized vector (Vector3) orthogonal to the ground
  16737. * at the ground coordinates (x, z) expressed in the World system.
  16738. * Returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  16739. */
  16740. getNormalAtCoordinates(x: number, z: number): Vector3;
  16741. /**
  16742. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  16743. * at the ground coordinates (x, z) expressed in the World system.
  16744. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  16745. * Returns the GroundMesh.
  16746. */
  16747. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  16748. /**
  16749. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  16750. * if the ground has been updated.
  16751. * This can be used in the render loop.
  16752. * Returns the GroundMesh.
  16753. */
  16754. updateCoordinateHeights(): GroundMesh;
  16755. private _getFacetAt(x, z);
  16756. private _initHeightQuads();
  16757. private _computeHeightQuads();
  16758. serialize(serializationObject: any): void;
  16759. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  16760. }
  16761. }
  16762. declare module BABYLON {
  16763. /**
  16764. * Creates an instance based on a source mesh.
  16765. */
  16766. class InstancedMesh extends AbstractMesh {
  16767. private _sourceMesh;
  16768. private _currentLOD;
  16769. constructor(name: string, source: Mesh);
  16770. /**
  16771. * Returns the string "InstancedMesh".
  16772. */
  16773. getClassName(): string;
  16774. readonly receiveShadows: boolean;
  16775. readonly material: Nullable<Material>;
  16776. readonly visibility: number;
  16777. readonly skeleton: Nullable<Skeleton>;
  16778. renderingGroupId: number;
  16779. /**
  16780. * Returns the total number of vertices (integer).
  16781. */
  16782. getTotalVertices(): number;
  16783. readonly sourceMesh: Mesh;
  16784. /**
  16785. * Is this node ready to be used/rendered
  16786. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  16787. * @return {boolean} is it ready
  16788. */
  16789. isReady(completeCheck?: boolean): boolean;
  16790. /**
  16791. * Returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  16792. */
  16793. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  16794. /**
  16795. * Sets the vertex data of the mesh geometry for the requested `kind`.
  16796. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  16797. * The `data` are either a numeric array either a Float32Array.
  16798. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  16799. * 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).
  16800. * Note that a new underlying VertexBuffer object is created each call.
  16801. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  16802. *
  16803. * Possible `kind` values :
  16804. * - BABYLON.VertexBuffer.PositionKind
  16805. * - BABYLON.VertexBuffer.UVKind
  16806. * - BABYLON.VertexBuffer.UV2Kind
  16807. * - BABYLON.VertexBuffer.UV3Kind
  16808. * - BABYLON.VertexBuffer.UV4Kind
  16809. * - BABYLON.VertexBuffer.UV5Kind
  16810. * - BABYLON.VertexBuffer.UV6Kind
  16811. * - BABYLON.VertexBuffer.ColorKind
  16812. * - BABYLON.VertexBuffer.MatricesIndicesKind
  16813. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  16814. * - BABYLON.VertexBuffer.MatricesWeightsKind
  16815. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  16816. *
  16817. * Returns the Mesh.
  16818. */
  16819. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  16820. /**
  16821. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  16822. * If the mesh has no geometry, it is simply returned as it is.
  16823. * The `data` are either a numeric array either a Float32Array.
  16824. * No new underlying VertexBuffer object is created.
  16825. * 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.
  16826. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  16827. *
  16828. * Possible `kind` values :
  16829. * - BABYLON.VertexBuffer.PositionKind
  16830. * - BABYLON.VertexBuffer.UVKind
  16831. * - BABYLON.VertexBuffer.UV2Kind
  16832. * - BABYLON.VertexBuffer.UV3Kind
  16833. * - BABYLON.VertexBuffer.UV4Kind
  16834. * - BABYLON.VertexBuffer.UV5Kind
  16835. * - BABYLON.VertexBuffer.UV6Kind
  16836. * - BABYLON.VertexBuffer.ColorKind
  16837. * - BABYLON.VertexBuffer.MatricesIndicesKind
  16838. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  16839. * - BABYLON.VertexBuffer.MatricesWeightsKind
  16840. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  16841. *
  16842. * Returns the Mesh.
  16843. */
  16844. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  16845. /**
  16846. * Sets the mesh indices.
  16847. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  16848. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  16849. * This method creates a new index buffer each call.
  16850. * Returns the Mesh.
  16851. */
  16852. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  16853. /**
  16854. * Boolean : True if the mesh owns the requested kind of data.
  16855. */
  16856. isVerticesDataPresent(kind: string): boolean;
  16857. /**
  16858. * Returns an array of indices (IndicesArray).
  16859. */
  16860. getIndices(): Nullable<IndicesArray>;
  16861. readonly _positions: Nullable<Vector3[]>;
  16862. /**
  16863. * Sets a new updated BoundingInfo to the mesh.
  16864. * Returns the mesh.
  16865. */
  16866. refreshBoundingInfo(): InstancedMesh;
  16867. _preActivate(): InstancedMesh;
  16868. _activate(renderId: number): InstancedMesh;
  16869. /**
  16870. * Returns the current associated LOD AbstractMesh.
  16871. */
  16872. getLOD(camera: Camera): AbstractMesh;
  16873. _syncSubMeshes(): InstancedMesh;
  16874. _generatePointsArray(): boolean;
  16875. /**
  16876. * Creates a new InstancedMesh from the current mesh.
  16877. * - name (string) : the cloned mesh name
  16878. * - newParent (optional Node) : the optional Node to parent the clone to.
  16879. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  16880. *
  16881. * Returns the clone.
  16882. */
  16883. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  16884. /**
  16885. * Disposes the InstancedMesh.
  16886. * Returns nothing.
  16887. */
  16888. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  16889. }
  16890. }
  16891. declare module BABYLON {
  16892. class LinesMesh extends Mesh {
  16893. useVertexColor: boolean | undefined;
  16894. useVertexAlpha: boolean | undefined;
  16895. color: Color3;
  16896. alpha: number;
  16897. /**
  16898. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  16899. * This margin is expressed in world space coordinates, so its value may vary.
  16900. * Default value is 0.1
  16901. * @returns the intersection Threshold value.
  16902. */
  16903. /**
  16904. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  16905. * This margin is expressed in world space coordinates, so its value may vary.
  16906. * @param value the new threshold to apply
  16907. */
  16908. intersectionThreshold: number;
  16909. private _intersectionThreshold;
  16910. private _colorShader;
  16911. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean, useVertexColor?: boolean | undefined, useVertexAlpha?: boolean | undefined);
  16912. /**
  16913. * Returns the string "LineMesh"
  16914. */
  16915. getClassName(): string;
  16916. material: Material;
  16917. readonly checkCollisions: boolean;
  16918. createInstance(name: string): InstancedMesh;
  16919. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  16920. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  16921. dispose(doNotRecurse?: boolean): void;
  16922. /**
  16923. * Returns a new LineMesh object cloned from the current one.
  16924. */
  16925. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  16926. }
  16927. }
  16928. declare module BABYLON {
  16929. class _InstancesBatch {
  16930. mustReturn: boolean;
  16931. visibleInstances: Nullable<InstancedMesh[]>[];
  16932. renderSelf: boolean[];
  16933. }
  16934. class Mesh extends AbstractMesh implements IGetSetVerticesData {
  16935. static _FRONTSIDE: number;
  16936. static _BACKSIDE: number;
  16937. static _DOUBLESIDE: number;
  16938. static _DEFAULTSIDE: number;
  16939. static _NO_CAP: number;
  16940. static _CAP_START: number;
  16941. static _CAP_END: number;
  16942. static _CAP_ALL: number;
  16943. /**
  16944. * Mesh side orientation : usually the external or front surface
  16945. */
  16946. static readonly FRONTSIDE: number;
  16947. /**
  16948. * Mesh side orientation : usually the internal or back surface
  16949. */
  16950. static readonly BACKSIDE: number;
  16951. /**
  16952. * Mesh side orientation : both internal and external or front and back surfaces
  16953. */
  16954. static readonly DOUBLESIDE: number;
  16955. /**
  16956. * Mesh side orientation : by default, `FRONTSIDE`
  16957. */
  16958. static readonly DEFAULTSIDE: number;
  16959. /**
  16960. * Mesh cap setting : no cap
  16961. */
  16962. static readonly NO_CAP: number;
  16963. /**
  16964. * Mesh cap setting : one cap at the beginning of the mesh
  16965. */
  16966. static readonly CAP_START: number;
  16967. /**
  16968. * Mesh cap setting : one cap at the end of the mesh
  16969. */
  16970. static readonly CAP_END: number;
  16971. /**
  16972. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  16973. */
  16974. static readonly CAP_ALL: number;
  16975. /**
  16976. * An event triggered before rendering the mesh
  16977. */
  16978. onBeforeRenderObservable: Observable<Mesh>;
  16979. /**
  16980. * An event triggered after rendering the mesh
  16981. */
  16982. onAfterRenderObservable: Observable<Mesh>;
  16983. /**
  16984. * An event triggered before drawing the mesh
  16985. */
  16986. onBeforeDrawObservable: Observable<Mesh>;
  16987. private _onBeforeDrawObserver;
  16988. onBeforeDraw: () => void;
  16989. delayLoadState: number;
  16990. instances: InstancedMesh[];
  16991. delayLoadingFile: string;
  16992. _binaryInfo: any;
  16993. private _LODLevels;
  16994. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Mesh) => void;
  16995. private _morphTargetManager;
  16996. morphTargetManager: Nullable<MorphTargetManager>;
  16997. _geometry: Nullable<Geometry>;
  16998. _delayInfo: Array<string>;
  16999. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  17000. _visibleInstances: any;
  17001. private _renderIdForInstances;
  17002. private _batchCache;
  17003. private _instancesBufferSize;
  17004. private _instancesBuffer;
  17005. private _instancesData;
  17006. private _overridenInstanceCount;
  17007. private _effectiveMaterial;
  17008. _shouldGenerateFlatShading: boolean;
  17009. private _preActivateId;
  17010. _originalBuilderSideOrientation: number;
  17011. overrideMaterialSideOrientation: Nullable<number>;
  17012. private _areNormalsFrozen;
  17013. private _sourcePositions;
  17014. private _sourceNormals;
  17015. private _source;
  17016. readonly source: Nullable<Mesh>;
  17017. isUnIndexed: boolean;
  17018. /**
  17019. * @constructor
  17020. * @param {string} name The value used by scene.getMeshByName() to do a lookup.
  17021. * @param {Scene} scene The scene to add this mesh to.
  17022. * @param {Node} parent The parent of this mesh, if it has one
  17023. * @param {Mesh} source An optional Mesh from which geometry is shared, cloned.
  17024. * @param {boolean} doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  17025. * When false, achieved by calling a clone(), also passing False.
  17026. * This will make creation of children, recursive.
  17027. * @param {boolean} clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  17028. */
  17029. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  17030. /**
  17031. * Returns the string "Mesh".
  17032. */
  17033. getClassName(): string;
  17034. /**
  17035. * Returns a string.
  17036. * @param {boolean} fullDetails - support for multiple levels of logging within scene loading
  17037. */
  17038. toString(fullDetails?: boolean): string;
  17039. /**
  17040. * True if the mesh has some Levels Of Details (LOD).
  17041. * Returns a boolean.
  17042. */
  17043. readonly hasLODLevels: boolean;
  17044. /**
  17045. * Gets the list of {BABYLON.MeshLODLevel} associated with the current mesh
  17046. * @returns an array of {BABYLON.MeshLODLevel}
  17047. */
  17048. getLODLevels(): MeshLODLevel[];
  17049. private _sortLODLevels();
  17050. /**
  17051. * Add a mesh as LOD level triggered at the given distance.
  17052. * tuto : http://doc.babylonjs.com/tutorials/How_to_use_LOD
  17053. * @param {number} distance The distance from the center of the object to show this level
  17054. * @param {Mesh} mesh The mesh to be added as LOD level
  17055. * @return {Mesh} This mesh (for chaining)
  17056. */
  17057. addLODLevel(distance: number, mesh: Mesh): Mesh;
  17058. /**
  17059. * Returns the LOD level mesh at the passed distance or null if not found.
  17060. * It is related to the method `addLODLevel(distance, mesh)`.
  17061. * tuto : http://doc.babylonjs.com/tutorials/How_to_use_LOD
  17062. * Returns an object Mesh or `null`.
  17063. */
  17064. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  17065. /**
  17066. * Remove a mesh from the LOD array
  17067. * tuto : http://doc.babylonjs.com/tutorials/How_to_use_LOD
  17068. * @param {Mesh} mesh The mesh to be removed.
  17069. * @return {Mesh} This mesh (for chaining)
  17070. */
  17071. removeLODLevel(mesh: Mesh): Mesh;
  17072. /**
  17073. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  17074. * tuto : http://doc.babylonjs.com/tutorials/How_to_use_LOD
  17075. */
  17076. getLOD(camera: Camera, boundingSphere?: BoundingSphere): AbstractMesh;
  17077. /**
  17078. * Returns the mesh internal Geometry object.
  17079. */
  17080. readonly geometry: Nullable<Geometry>;
  17081. /**
  17082. * Returns a positive integer : the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  17083. */
  17084. getTotalVertices(): number;
  17085. /**
  17086. * Returns an array of integers or floats, or a Float32Array, depending on the requested `kind` (positions, indices, normals, etc).
  17087. * 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.
  17088. * You can force the copy with forceCopy === true
  17089. * Returns null if the mesh has no geometry or no vertex buffer.
  17090. * Possible `kind` values :
  17091. * - BABYLON.VertexBuffer.PositionKind
  17092. * - BABYLON.VertexBuffer.UVKind
  17093. * - BABYLON.VertexBuffer.UV2Kind
  17094. * - BABYLON.VertexBuffer.UV3Kind
  17095. * - BABYLON.VertexBuffer.UV4Kind
  17096. * - BABYLON.VertexBuffer.UV5Kind
  17097. * - BABYLON.VertexBuffer.UV6Kind
  17098. * - BABYLON.VertexBuffer.ColorKind
  17099. * - BABYLON.VertexBuffer.MatricesIndicesKind
  17100. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  17101. * - BABYLON.VertexBuffer.MatricesWeightsKind
  17102. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  17103. */
  17104. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  17105. /**
  17106. * Returns the mesh VertexBuffer object from the requested `kind` : positions, indices, normals, etc.
  17107. * Returns `null` if the mesh has no geometry.
  17108. * Possible `kind` values :
  17109. * - BABYLON.VertexBuffer.PositionKind
  17110. * - BABYLON.VertexBuffer.UVKind
  17111. * - BABYLON.VertexBuffer.UV2Kind
  17112. * - BABYLON.VertexBuffer.UV3Kind
  17113. * - BABYLON.VertexBuffer.UV4Kind
  17114. * - BABYLON.VertexBuffer.UV5Kind
  17115. * - BABYLON.VertexBuffer.UV6Kind
  17116. * - BABYLON.VertexBuffer.ColorKind
  17117. * - BABYLON.VertexBuffer.MatricesIndicesKind
  17118. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  17119. * - BABYLON.VertexBuffer.MatricesWeightsKind
  17120. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  17121. */
  17122. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  17123. /**
  17124. * Returns a boolean depending on the existence of the Vertex Data for the requested `kind`.
  17125. * Possible `kind` values :
  17126. * - BABYLON.VertexBuffer.PositionKind
  17127. * - BABYLON.VertexBuffer.UVKind
  17128. * - BABYLON.VertexBuffer.UV2Kind
  17129. * - BABYLON.VertexBuffer.UV3Kind
  17130. * - BABYLON.VertexBuffer.UV4Kind
  17131. * - BABYLON.VertexBuffer.UV5Kind
  17132. * - BABYLON.VertexBuffer.UV6Kind
  17133. * - BABYLON.VertexBuffer.ColorKind
  17134. * - BABYLON.VertexBuffer.MatricesIndicesKind
  17135. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  17136. * - BABYLON.VertexBuffer.MatricesWeightsKind
  17137. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  17138. */
  17139. isVerticesDataPresent(kind: string): boolean;
  17140. /**
  17141. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  17142. * Possible `kind` values :
  17143. * - BABYLON.VertexBuffer.PositionKind
  17144. * - BABYLON.VertexBuffer.UVKind
  17145. * - BABYLON.VertexBuffer.UV2Kind
  17146. * - BABYLON.VertexBuffer.UV3Kind
  17147. * - BABYLON.VertexBuffer.UV4Kind
  17148. * - BABYLON.VertexBuffer.UV5Kind
  17149. * - BABYLON.VertexBuffer.UV6Kind
  17150. * - BABYLON.VertexBuffer.ColorKind
  17151. * - BABYLON.VertexBuffer.MatricesIndicesKind
  17152. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  17153. * - BABYLON.VertexBuffer.MatricesWeightsKind
  17154. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  17155. */
  17156. isVertexBufferUpdatable(kind: string): boolean;
  17157. /**
  17158. * Returns a string : the list of existing `kinds` of Vertex Data for this mesh.
  17159. * Possible `kind` values :
  17160. * - BABYLON.VertexBuffer.PositionKind
  17161. * - BABYLON.VertexBuffer.UVKind
  17162. * - BABYLON.VertexBuffer.UV2Kind
  17163. * - BABYLON.VertexBuffer.UV3Kind
  17164. * - BABYLON.VertexBuffer.UV4Kind
  17165. * - BABYLON.VertexBuffer.UV5Kind
  17166. * - BABYLON.VertexBuffer.UV6Kind
  17167. * - BABYLON.VertexBuffer.ColorKind
  17168. * - BABYLON.VertexBuffer.MatricesIndicesKind
  17169. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  17170. * - BABYLON.VertexBuffer.MatricesWeightsKind
  17171. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  17172. */
  17173. getVerticesDataKinds(): string[];
  17174. /**
  17175. * Returns a positive integer : the total number of indices in this mesh geometry.
  17176. * Returns zero if the mesh has no geometry.
  17177. */
  17178. getTotalIndices(): number;
  17179. /**
  17180. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  17181. * 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.
  17182. * Returns an empty array if the mesh has no geometry.
  17183. */
  17184. getIndices(copyWhenShared?: boolean): Nullable<IndicesArray>;
  17185. readonly isBlocked: boolean;
  17186. /**
  17187. * Determine if the current mesh is ready to be rendered
  17188. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  17189. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  17190. * @returns true if all associated assets are ready (material, textures, shaders)
  17191. */
  17192. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  17193. /**
  17194. * Boolean : true if the normals aren't to be recomputed on next mesh `positions` array update.
  17195. * This property is pertinent only for updatable parametric shapes.
  17196. */
  17197. readonly areNormalsFrozen: boolean;
  17198. /**
  17199. * This function affects parametric shapes on vertex position update only : ribbons, tubes, etc.
  17200. * It has no effect at all on other shapes.
  17201. * It prevents the mesh normals from being recomputed on next `positions` array update.
  17202. * Returns the Mesh.
  17203. */
  17204. freezeNormals(): Mesh;
  17205. /**
  17206. * This function affects parametric shapes on vertex position update only : ribbons, tubes, etc.
  17207. * It has no effect at all on other shapes.
  17208. * It reactivates the mesh normals computation if it was previously frozen.
  17209. * Returns the Mesh.
  17210. */
  17211. unfreezeNormals(): Mesh;
  17212. /**
  17213. * Overrides instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  17214. */
  17215. overridenInstanceCount: number;
  17216. _preActivate(): Mesh;
  17217. _preActivateForIntermediateRendering(renderId: number): Mesh;
  17218. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  17219. /**
  17220. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  17221. * This means the mesh underlying bounding box and sphere are recomputed.
  17222. * Returns the Mesh.
  17223. */
  17224. refreshBoundingInfo(): Mesh;
  17225. _refreshBoundingInfo(applySkeleton: boolean): Mesh;
  17226. private _getPositionData(applySkeleton);
  17227. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  17228. subdivide(count: number): void;
  17229. /**
  17230. * Sets the vertex data of the mesh geometry for the requested `kind`.
  17231. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  17232. * The `data` are either a numeric array either a Float32Array.
  17233. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  17234. * 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).
  17235. * Note that a new underlying VertexBuffer object is created each call.
  17236. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  17237. *
  17238. * Possible `kind` values :
  17239. * - BABYLON.VertexBuffer.PositionKind
  17240. * - BABYLON.VertexBuffer.UVKind
  17241. * - BABYLON.VertexBuffer.UV2Kind
  17242. * - BABYLON.VertexBuffer.UV3Kind
  17243. * - BABYLON.VertexBuffer.UV4Kind
  17244. * - BABYLON.VertexBuffer.UV5Kind
  17245. * - BABYLON.VertexBuffer.UV6Kind
  17246. * - BABYLON.VertexBuffer.ColorKind
  17247. * - BABYLON.VertexBuffer.MatricesIndicesKind
  17248. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  17249. * - BABYLON.VertexBuffer.MatricesWeightsKind
  17250. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  17251. *
  17252. * Returns the Mesh.
  17253. */
  17254. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  17255. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  17256. /**
  17257. * Sets the mesh VertexBuffer.
  17258. * Returns the Mesh.
  17259. */
  17260. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  17261. /**
  17262. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  17263. * If the mesh has no geometry, it is simply returned as it is.
  17264. * The `data` are either a numeric array either a Float32Array.
  17265. * No new underlying VertexBuffer object is created.
  17266. * 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.
  17267. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  17268. *
  17269. * Possible `kind` values :
  17270. * - BABYLON.VertexBuffer.PositionKind
  17271. * - BABYLON.VertexBuffer.UVKind
  17272. * - BABYLON.VertexBuffer.UV2Kind
  17273. * - BABYLON.VertexBuffer.UV3Kind
  17274. * - BABYLON.VertexBuffer.UV4Kind
  17275. * - BABYLON.VertexBuffer.UV5Kind
  17276. * - BABYLON.VertexBuffer.UV6Kind
  17277. * - BABYLON.VertexBuffer.ColorKind
  17278. * - BABYLON.VertexBuffer.MatricesIndicesKind
  17279. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  17280. * - BABYLON.VertexBuffer.MatricesWeightsKind
  17281. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  17282. *
  17283. * Returns the Mesh.
  17284. */
  17285. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  17286. /**
  17287. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  17288. * tuto : http://doc.babylonjs.com/tutorials/How_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  17289. * The parameter `positionFunction` is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything.
  17290. * The parameter `computeNormals` is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update.
  17291. * Returns the Mesh.
  17292. */
  17293. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  17294. /**
  17295. * Creates a un-shared specific occurence of the geometry for the mesh.
  17296. * Returns the Mesh.
  17297. */
  17298. makeGeometryUnique(): Mesh;
  17299. /**
  17300. * Sets the mesh indices.
  17301. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  17302. * Type is Uint16Array by default unless the mesh has more than 65536 vertices.
  17303. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  17304. * This method creates a new index buffer each call.
  17305. * Returns the Mesh.
  17306. */
  17307. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  17308. /**
  17309. * Update the current index buffer
  17310. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  17311. * Returns the Mesh.
  17312. */
  17313. updateIndices(indices: IndicesArray, offset?: number): Mesh;
  17314. /**
  17315. * Invert the geometry to move from a right handed system to a left handed one.
  17316. * Returns the Mesh.
  17317. */
  17318. toLeftHanded(): Mesh;
  17319. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  17320. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number, alternate?: boolean): Mesh;
  17321. /**
  17322. * Registers for this mesh a javascript function called just before the rendering process.
  17323. * This function is passed the current mesh.
  17324. * Return the Mesh.
  17325. */
  17326. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  17327. /**
  17328. * Disposes a previously registered javascript function called before the rendering.
  17329. * This function is passed the current mesh.
  17330. * Returns the Mesh.
  17331. */
  17332. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  17333. /**
  17334. * Registers for this mesh a javascript function called just after the rendering is complete.
  17335. * This function is passed the current mesh.
  17336. * Returns the Mesh.
  17337. */
  17338. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  17339. /**
  17340. * Disposes a previously registered javascript function called after the rendering.
  17341. * This function is passed the current mesh.
  17342. * Return the Mesh.
  17343. */
  17344. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  17345. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  17346. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  17347. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  17348. /**
  17349. * Triggers the draw call for the mesh.
  17350. * Usually, you don't need to call this method by your own because the mesh rendering is handled by the scene rendering manager.
  17351. * Returns the Mesh.
  17352. */
  17353. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  17354. private _onBeforeDraw(isInstance, world, effectiveMaterial?);
  17355. /**
  17356. * Returns an array populated with ParticleSystem objects whose the mesh is the emitter.
  17357. */
  17358. getEmittedParticleSystems(): IParticleSystem[];
  17359. /**
  17360. * Returns an array populated with ParticleSystem objects whose the mesh or its children are the emitter.
  17361. */
  17362. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  17363. _checkDelayState(): Mesh;
  17364. private _queueLoad(scene);
  17365. /**
  17366. * Boolean, true is the mesh in the frustum defined by the Plane objects from the `frustumPlanes` array parameter.
  17367. */
  17368. isInFrustum(frustumPlanes: Plane[]): boolean;
  17369. /**
  17370. * Sets the mesh material by the material or multiMaterial `id` property.
  17371. * The material `id` is a string identifying the material or the multiMaterial.
  17372. * This method returns the Mesh.
  17373. */
  17374. setMaterialByID(id: string): Mesh;
  17375. /**
  17376. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  17377. */
  17378. getAnimatables(): IAnimatable[];
  17379. /**
  17380. * Modifies the mesh geometry according to the passed transformation matrix.
  17381. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  17382. * The mesh normals are modified accordingly the same transformation.
  17383. * tuto : http://doc.babylonjs.com/tutorials/How_Rotations_and_Translations_Work#baking-transform
  17384. * Note that, under the hood, this method sets a new VertexBuffer each call.
  17385. * Returns the Mesh.
  17386. */
  17387. bakeTransformIntoVertices(transform: Matrix): Mesh;
  17388. /**
  17389. * Modifies the mesh geometry according to its own current World Matrix.
  17390. * The mesh World Matrix is then reset.
  17391. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  17392. * tuto : tuto : http://doc.babylonjs.com/resources/baking_transformations
  17393. * Note that, under the hood, this method sets a new VertexBuffer each call.
  17394. * Returns the Mesh.
  17395. */
  17396. bakeCurrentTransformIntoVertices(): Mesh;
  17397. readonly _positions: Nullable<Vector3[]>;
  17398. _resetPointsArrayCache(): Mesh;
  17399. _generatePointsArray(): boolean;
  17400. /**
  17401. * Returns a new Mesh object generated from the current mesh properties.
  17402. * This method must not get confused with createInstance().
  17403. * The parameter `name` is a string, the name given to the new mesh.
  17404. * The optional parameter `newParent` can be any Node object (default `null`).
  17405. * The optional parameter `doNotCloneChildren` (default `false`) allows/denies the recursive cloning of the original mesh children if any.
  17406. * 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.
  17407. */
  17408. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  17409. /**
  17410. * Releases resources associated with this mesh.
  17411. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  17412. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  17413. */
  17414. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  17415. /**
  17416. * Modifies the mesh geometry according to a displacement map.
  17417. * 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.
  17418. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  17419. * This method returns nothing.
  17420. * The parameter `url` is a string, the URL from the image file is to be downloaded.
  17421. * The parameters `minHeight` and `maxHeight` are the lower and upper limits of the displacement.
  17422. * 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.
  17423. * The parameter `uvOffset` is an optional vector2 used to offset UV.
  17424. * The parameter `uvScale` is an optional vector2 used to scale UV.
  17425. *
  17426. * Returns the Mesh.
  17427. */
  17428. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2): Mesh;
  17429. /**
  17430. * Modifies the mesh geometry according to a displacementMap buffer.
  17431. * 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.
  17432. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  17433. * This method returns nothing.
  17434. * 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.
  17435. * The parameters `heightMapWidth` and `heightMapHeight` are positive integers to set the width and height of the buffer image.
  17436. * The parameters `minHeight` and `maxHeight` are the lower and upper limits of the displacement.
  17437. * The parameter `uvOffset` is an optional vector2 used to offset UV.
  17438. * The parameter `uvScale` is an optional vector2 used to scale UV.
  17439. *
  17440. * Returns the Mesh.
  17441. */
  17442. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2): Mesh;
  17443. /**
  17444. * Modify the mesh to get a flat shading rendering.
  17445. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  17446. * This method returns the Mesh.
  17447. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  17448. */
  17449. convertToFlatShadedMesh(): Mesh;
  17450. /**
  17451. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  17452. * In other words, more vertices, no more indices and a single bigger VBO.
  17453. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  17454. * Returns the Mesh.
  17455. */
  17456. convertToUnIndexedMesh(): Mesh;
  17457. /**
  17458. * Inverses facet orientations and inverts also the normals with `flipNormals` (default `false`) if true.
  17459. * This method returns the Mesh.
  17460. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  17461. */
  17462. flipFaces(flipNormals?: boolean): Mesh;
  17463. /**
  17464. * Creates a new InstancedMesh object from the mesh model.
  17465. * An instance shares the same properties and the same material than its model.
  17466. * Only these properties of each instance can then be set individually :
  17467. * - position
  17468. * - rotation
  17469. * - rotationQuaternion
  17470. * - setPivotMatrix
  17471. * - scaling
  17472. * tuto : http://doc.babylonjs.com/tutorials/How_to_use_Instances
  17473. * Warning : this method is not supported for Line mesh and LineSystem
  17474. */
  17475. createInstance(name: string): InstancedMesh;
  17476. /**
  17477. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  17478. * After this call, all the mesh instances have the same submeshes than the current mesh.
  17479. * This method returns the Mesh.
  17480. */
  17481. synchronizeInstances(): Mesh;
  17482. /**
  17483. * Simplify the mesh according to the given array of settings.
  17484. * Function will return immediately and will simplify async. It returns the Mesh.
  17485. * @param settings a collection of simplification settings.
  17486. * @param parallelProcessing should all levels calculate parallel or one after the other.
  17487. * @param type the type of simplification to run.
  17488. * @param successCallback optional success callback to be called after the simplification finished processing all settings.
  17489. */
  17490. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  17491. /**
  17492. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  17493. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  17494. * This should be used together with the simplification to avoid disappearing triangles.
  17495. * Returns the Mesh.
  17496. * @param successCallback an optional success callback to be called after the optimization finished.
  17497. */
  17498. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  17499. serialize(serializationObject: any): void;
  17500. _syncGeometryWithMorphTargetManager(): void;
  17501. /**
  17502. * Returns a new Mesh object parsed from the source provided.
  17503. * The parameter `parsedMesh` is the source.
  17504. * The parameter `rootUrl` is a string, it's the root URL to prefix the `delayLoadingFile` property with
  17505. */
  17506. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  17507. /**
  17508. * Creates a ribbon mesh.
  17509. * Please consider using the same method from the MeshBuilder class instead.
  17510. * 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.
  17511. *
  17512. * Please read this full tutorial to understand how to design a ribbon : http://doc.babylonjs.com/tutorials/Ribbon_Tutorial
  17513. * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  17514. * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array.
  17515. * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array.
  17516. * 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.
  17517. * 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.
  17518. * 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
  17519. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  17520. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  17521. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  17522. */
  17523. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean | undefined, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  17524. /**
  17525. * Creates a plane polygonal mesh. By default, this is a disc.
  17526. * Please consider using the same method from the MeshBuilder class instead.
  17527. * The parameter `radius` sets the radius size (float) of the polygon (default 0.5).
  17528. * 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.
  17529. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  17530. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  17531. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  17532. */
  17533. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  17534. /**
  17535. * Creates a box mesh.
  17536. * Please consider using the same method from the MeshBuilder class instead.
  17537. * The parameter `size` sets the size (float) of each box side (default 1).
  17538. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  17539. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  17540. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  17541. */
  17542. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  17543. /**
  17544. * Creates a sphere mesh.
  17545. * Please consider using the same method from the MeshBuilder class instead.
  17546. * The parameter `diameter` sets the diameter size (float) of the sphere (default 1).
  17547. * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32).
  17548. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  17549. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  17550. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  17551. */
  17552. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  17553. /**
  17554. * Creates a cylinder or a cone mesh.
  17555. * Please consider using the same method from the MeshBuilder class instead.
  17556. * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  17557. * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  17558. * 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.
  17559. * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  17560. * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  17561. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  17562. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  17563. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  17564. */
  17565. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  17566. /**
  17567. * Creates a torus mesh.
  17568. * Please consider using the same method from the MeshBuilder class instead.
  17569. * The parameter `diameter` sets the diameter size (float) of the torus (default 1).
  17570. * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5).
  17571. * The parameter `tessellation` sets the number of torus sides (postive integer, default 16).
  17572. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  17573. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  17574. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  17575. */
  17576. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  17577. /**
  17578. * Creates a torus knot mesh.
  17579. * Please consider using the same method from the MeshBuilder class instead.
  17580. * The parameter `radius` sets the global radius size (float) of the torus knot (default 2).
  17581. * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32).
  17582. * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32).
  17583. * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3).
  17584. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  17585. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  17586. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  17587. */
  17588. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  17589. /**
  17590. * Creates a line mesh.
  17591. * Please consider using the same method from the MeshBuilder class instead.
  17592. * 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.
  17593. * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function.
  17594. * The parameter `points` is an array successive Vector3.
  17595. * 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
  17596. * When updating an instance, remember that only point positions can change, not the number of points.
  17597. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  17598. */
  17599. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  17600. /**
  17601. * Creates a dashed line mesh.
  17602. * Please consider using the same method from the MeshBuilder class instead.
  17603. * 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.
  17604. * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function.
  17605. * The parameter `points` is an array successive Vector3.
  17606. * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200).
  17607. * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3).
  17608. * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1).
  17609. * 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
  17610. * When updating an instance, remember that only point positions can change, not the number of points.
  17611. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  17612. */
  17613. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  17614. /**
  17615. * Creates a polygon mesh.
  17616. * Please consider using the same method from the MeshBuilder class instead.
  17617. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  17618. * 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.
  17619. * You can set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  17620. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  17621. * Remember you can only change the shape positions, not their number when updating a polygon.
  17622. */
  17623. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number): Mesh;
  17624. /**
  17625. * Creates an extruded polygon mesh, with depth in the Y direction.
  17626. * Please consider using the same method from the MeshBuilder class instead.
  17627. */
  17628. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number): Mesh;
  17629. /**
  17630. * Creates an extruded shape mesh.
  17631. * 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.
  17632. * Please consider using the same method from the MeshBuilder class instead.
  17633. *
  17634. * Please read this full tutorial to understand how to design an extruded shape : http://doc.babylonjs.com/tutorials/Parametric_Shapes#extrusion
  17635. * 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
  17636. * extruded along the Z axis.
  17637. * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  17638. * 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.
  17639. * The parameter `scale` (float, default 1) is the value to scale the shape.
  17640. * 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
  17641. * 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
  17642. * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  17643. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  17644. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  17645. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  17646. */
  17647. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  17648. /**
  17649. * Creates an custom extruded shape mesh.
  17650. * 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.
  17651. * Please consider using the same method from the MeshBuilder class instead.
  17652. *
  17653. * Please read this full tutorial to understand how to design a custom extruded shape : http://doc.babylonjs.com/tutorials/Parametric_Shapes#extrusion
  17654. * 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
  17655. * extruded along the Z axis.
  17656. * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  17657. * 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
  17658. * and the distance of this point from the begining of the path :
  17659. * ```javascript
  17660. * var rotationFunction = function(i, distance) {
  17661. * // do things
  17662. * return rotationValue; }
  17663. * ```
  17664. * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  17665. * 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
  17666. * and the distance of this point from the begining of the path :
  17667. * ```javascript
  17668. * var scaleFunction = function(i, distance) {
  17669. * // do things
  17670. * return scaleValue;}
  17671. * ```
  17672. * It must returns a float value that will be the scale value applied to the shape on each path point.
  17673. * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`.
  17674. * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`.
  17675. * 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
  17676. * 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
  17677. * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  17678. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  17679. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  17680. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  17681. */
  17682. 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;
  17683. /**
  17684. * Creates lathe mesh.
  17685. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  17686. * Please consider using the same method from the MeshBuilder class instead.
  17687. * 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
  17688. * rotated around the Y axis. It's usually a 2D shape, so the Vector3 z coordinates are often set to zero.
  17689. * The parameter `radius` (positive float, default 1) is the radius value of the lathe.
  17690. * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe.
  17691. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  17692. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  17693. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  17694. */
  17695. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  17696. /**
  17697. * Creates a plane mesh.
  17698. * Please consider using the same method from the MeshBuilder class instead.
  17699. * The parameter `size` sets the size (float) of both sides of the plane at once (default 1).
  17700. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  17701. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  17702. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  17703. */
  17704. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  17705. /**
  17706. * Creates a ground mesh.
  17707. * Please consider using the same method from the MeshBuilder class instead.
  17708. * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground.
  17709. * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side.
  17710. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  17711. */
  17712. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  17713. /**
  17714. * Creates a tiled ground mesh.
  17715. * Please consider using the same method from the MeshBuilder class instead.
  17716. * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates.
  17717. * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates.
  17718. * The parameter `subdivisions` is a javascript object `{w: positive integer, h: positive integer}` (default `{w: 6, h: 6}`). `w` and `h` are the
  17719. * numbers of subdivisions on the ground width and height. Each subdivision is called a tile.
  17720. * The parameter `precision` is a javascript object `{w: positive integer, h: positive integer}` (default `{w: 2, h: 2}`). `w` and `h` are the
  17721. * numbers of subdivisions on the ground width and height of each tile.
  17722. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  17723. */
  17724. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  17725. w: number;
  17726. h: number;
  17727. }, precision: {
  17728. w: number;
  17729. h: number;
  17730. }, scene: Scene, updatable?: boolean): Mesh;
  17731. /**
  17732. * Creates a ground mesh from a height map.
  17733. * tuto : http://doc.babylonjs.com/tutorials/14._Height_Map
  17734. * Please consider using the same method from the MeshBuilder class instead.
  17735. * The parameter `url` sets the URL of the height map image resource.
  17736. * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  17737. * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  17738. * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  17739. * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  17740. * 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).
  17741. * This function is passed the newly built mesh :
  17742. * ```javascript
  17743. * function(mesh) { // do things
  17744. * return; }
  17745. * ```
  17746. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  17747. */
  17748. 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;
  17749. /**
  17750. * Creates a tube mesh.
  17751. * 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.
  17752. * Please consider using the same method from the MeshBuilder class instead.
  17753. * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube.
  17754. * The parameter `radius` (positive float, default 1) sets the tube radius size.
  17755. * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface.
  17756. * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`.
  17757. * 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.
  17758. * It must return a radius value (positive float) :
  17759. * ```javascript
  17760. * var radiusFunction = function(i, distance) {
  17761. * // do things
  17762. * return radius; }
  17763. * ```
  17764. * 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
  17765. * 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
  17766. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  17767. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  17768. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  17769. */
  17770. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  17771. (i: number, distance: number): number;
  17772. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  17773. /**
  17774. * Creates a polyhedron mesh.
  17775. * Please consider using the same method from the MeshBuilder class instead.
  17776. * 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
  17777. * to choose the wanted type.
  17778. * The parameter `size` (positive float, default 1) sets the polygon size.
  17779. * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value).
  17780. * 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`.
  17781. * 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
  17782. * 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)`).
  17783. * 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
  17784. * 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.
  17785. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  17786. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  17787. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  17788. */
  17789. static CreatePolyhedron(name: string, options: {
  17790. type?: number;
  17791. size?: number;
  17792. sizeX?: number;
  17793. sizeY?: number;
  17794. sizeZ?: number;
  17795. custom?: any;
  17796. faceUV?: Vector4[];
  17797. faceColors?: Color4[];
  17798. updatable?: boolean;
  17799. sideOrientation?: number;
  17800. }, scene: Scene): Mesh;
  17801. /**
  17802. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided.
  17803. * Please consider using the same method from the MeshBuilder class instead.
  17804. * The parameter `radius` sets the radius size (float) of the icosphere (default 1).
  17805. * 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`).
  17806. * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size.
  17807. * 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.
  17808. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  17809. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  17810. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  17811. */
  17812. static CreateIcoSphere(name: string, options: {
  17813. radius?: number;
  17814. flat?: boolean;
  17815. subdivisions?: number;
  17816. sideOrientation?: number;
  17817. updatable?: boolean;
  17818. }, scene: Scene): Mesh;
  17819. /**
  17820. * Creates a decal mesh.
  17821. * Please consider using the same method from the MeshBuilder class instead.
  17822. * 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.
  17823. * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates.
  17824. * The parameter `normal` (Vector3, default Vector3.Up) sets the normal of the mesh where the decal is applied onto in World coordinates.
  17825. * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling.
  17826. * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal.
  17827. */
  17828. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  17829. /**
  17830. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  17831. */
  17832. setPositionsForCPUSkinning(): Float32Array;
  17833. /**
  17834. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  17835. */
  17836. setNormalsForCPUSkinning(): Float32Array;
  17837. /**
  17838. * Updates the vertex buffer by applying transformation from the bones.
  17839. * Returns the Mesh.
  17840. *
  17841. * @param {skeleton} skeleton to apply
  17842. */
  17843. applySkeleton(skeleton: Skeleton): Mesh;
  17844. /**
  17845. * Returns an object `{min:` Vector3`, max:` Vector3`}`
  17846. * This min and max Vector3 are the minimum and maximum vectors of each mesh bounding box from the passed array, in the World system
  17847. */
  17848. static MinMax(meshes: AbstractMesh[]): {
  17849. min: Vector3;
  17850. max: Vector3;
  17851. };
  17852. /**
  17853. * Returns a Vector3, the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array.
  17854. */
  17855. static Center(meshesOrMinMaxVector: {
  17856. min: Vector3;
  17857. max: Vector3;
  17858. } | AbstractMesh[]): Vector3;
  17859. /**
  17860. * Merge the array of meshes into a single mesh for performance reasons.
  17861. * @param {Array<Mesh>} meshes - The vertices source. They should all be of the same material. Entries can empty
  17862. * @param {boolean} disposeSource - When true (default), dispose of the vertices from the source meshes
  17863. * @param {boolean} allow32BitsIndices - When the sum of the vertices > 64k, this must be set to true.
  17864. * @param {Mesh} meshSubclass - When set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  17865. * @param {boolean} subdivideWithSubMeshes - When true (false default), subdivide mesh to his subMesh array with meshes source.
  17866. */
  17867. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean): Nullable<Mesh>;
  17868. }
  17869. }
  17870. declare module BABYLON {
  17871. interface IGetSetVerticesData {
  17872. isVerticesDataPresent(kind: string): boolean;
  17873. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  17874. getIndices(copyWhenShared?: boolean): Nullable<IndicesArray>;
  17875. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  17876. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  17877. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  17878. }
  17879. class VertexData {
  17880. positions: Nullable<FloatArray>;
  17881. normals: Nullable<FloatArray>;
  17882. tangents: Nullable<FloatArray>;
  17883. uvs: Nullable<FloatArray>;
  17884. uvs2: Nullable<FloatArray>;
  17885. uvs3: Nullable<FloatArray>;
  17886. uvs4: Nullable<FloatArray>;
  17887. uvs5: Nullable<FloatArray>;
  17888. uvs6: Nullable<FloatArray>;
  17889. colors: Nullable<FloatArray>;
  17890. matricesIndices: Nullable<FloatArray>;
  17891. matricesWeights: Nullable<FloatArray>;
  17892. matricesIndicesExtra: Nullable<FloatArray>;
  17893. matricesWeightsExtra: Nullable<FloatArray>;
  17894. indices: Nullable<IndicesArray>;
  17895. set(data: FloatArray, kind: string): void;
  17896. /**
  17897. * Associates the vertexData to the passed Mesh.
  17898. * Sets it as updatable or not (default `false`).
  17899. * Returns the VertexData.
  17900. */
  17901. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  17902. /**
  17903. * Associates the vertexData to the passed Geometry.
  17904. * Sets it as updatable or not (default `false`).
  17905. * Returns the VertexData.
  17906. */
  17907. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  17908. /**
  17909. * Updates the associated mesh.
  17910. * Returns the VertexData.
  17911. */
  17912. updateMesh(mesh: Mesh, updateExtends?: boolean, makeItUnique?: boolean): VertexData;
  17913. /**
  17914. * Updates the associated geometry.
  17915. * Returns the VertexData.
  17916. */
  17917. updateGeometry(geometry: Geometry, updateExtends?: boolean, makeItUnique?: boolean): VertexData;
  17918. private _applyTo(meshOrGeometry, updatable?);
  17919. private _update(meshOrGeometry, updateExtends?, makeItUnique?);
  17920. /**
  17921. * Transforms each position and each normal of the vertexData according to the passed Matrix.
  17922. * Returns the VertexData.
  17923. */
  17924. transform(matrix: Matrix): VertexData;
  17925. /**
  17926. * Merges the passed VertexData into the current one.
  17927. * Returns the modified VertexData.
  17928. */
  17929. merge(other: VertexData): VertexData;
  17930. private _mergeElement(source, other);
  17931. private _validate();
  17932. /**
  17933. * Serializes the VertexData.
  17934. * Returns a serialized object.
  17935. */
  17936. serialize(): any;
  17937. /**
  17938. * Returns the object VertexData associated to the passed mesh.
  17939. */
  17940. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  17941. /**
  17942. * Returns the object VertexData associated to the passed geometry.
  17943. */
  17944. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  17945. private static _ExtractFrom(meshOrGeometry, copyWhenShared?, forceCopy?);
  17946. /**
  17947. * Creates the vertexData of the Ribbon.
  17948. */
  17949. static CreateRibbon(options: {
  17950. pathArray: Vector3[][];
  17951. closeArray?: boolean;
  17952. closePath?: boolean;
  17953. offset?: number;
  17954. sideOrientation?: number;
  17955. frontUVs?: Vector4;
  17956. backUVs?: Vector4;
  17957. invertUV?: boolean;
  17958. uvs?: Vector2[];
  17959. colors?: Color4[];
  17960. }): VertexData;
  17961. /**
  17962. * Creates the VertexData of the Box.
  17963. */
  17964. static CreateBox(options: {
  17965. size?: number;
  17966. width?: number;
  17967. height?: number;
  17968. depth?: number;
  17969. faceUV?: Vector4[];
  17970. faceColors?: Color4[];
  17971. sideOrientation?: number;
  17972. frontUVs?: Vector4;
  17973. backUVs?: Vector4;
  17974. }): VertexData;
  17975. /**
  17976. * Creates the VertexData of the Sphere.
  17977. */
  17978. static CreateSphere(options: {
  17979. segments?: number;
  17980. diameter?: number;
  17981. diameterX?: number;
  17982. diameterY?: number;
  17983. diameterZ?: number;
  17984. arc?: number;
  17985. slice?: number;
  17986. sideOrientation?: number;
  17987. frontUVs?: Vector4;
  17988. backUVs?: Vector4;
  17989. }): VertexData;
  17990. /**
  17991. * Creates the VertexData of the Cylinder or Cone.
  17992. */
  17993. static CreateCylinder(options: {
  17994. height?: number;
  17995. diameterTop?: number;
  17996. diameterBottom?: number;
  17997. diameter?: number;
  17998. tessellation?: number;
  17999. subdivisions?: number;
  18000. arc?: number;
  18001. faceColors?: Color4[];
  18002. faceUV?: Vector4[];
  18003. hasRings?: boolean;
  18004. enclose?: boolean;
  18005. sideOrientation?: number;
  18006. frontUVs?: Vector4;
  18007. backUVs?: Vector4;
  18008. }): VertexData;
  18009. /**
  18010. * Creates the VertexData of the Torus.
  18011. */
  18012. static CreateTorus(options: {
  18013. diameter?: number;
  18014. thickness?: number;
  18015. tessellation?: number;
  18016. sideOrientation?: number;
  18017. frontUVs?: Vector4;
  18018. backUVs?: Vector4;
  18019. }): VertexData;
  18020. /**
  18021. * Creates the VertexData of the LineSystem.
  18022. */
  18023. static CreateLineSystem(options: {
  18024. lines: Vector3[][];
  18025. colors?: Nullable<Color4[][]>;
  18026. }): VertexData;
  18027. /**
  18028. * Create the VertexData of the DashedLines.
  18029. */
  18030. static CreateDashedLines(options: {
  18031. points: Vector3[];
  18032. dashSize?: number;
  18033. gapSize?: number;
  18034. dashNb?: number;
  18035. }): VertexData;
  18036. /**
  18037. * Creates the VertexData of the Ground.
  18038. */
  18039. static CreateGround(options: {
  18040. width?: number;
  18041. height?: number;
  18042. subdivisions?: number;
  18043. subdivisionsX?: number;
  18044. subdivisionsY?: number;
  18045. }): VertexData;
  18046. /**
  18047. * Creates the VertexData of the TiledGround.
  18048. */
  18049. static CreateTiledGround(options: {
  18050. xmin: number;
  18051. zmin: number;
  18052. xmax: number;
  18053. zmax: number;
  18054. subdivisions?: {
  18055. w: number;
  18056. h: number;
  18057. };
  18058. precision?: {
  18059. w: number;
  18060. h: number;
  18061. };
  18062. }): VertexData;
  18063. /**
  18064. * Creates the VertexData of the Ground designed from a heightmap.
  18065. */
  18066. static CreateGroundFromHeightMap(options: {
  18067. width: number;
  18068. height: number;
  18069. subdivisions: number;
  18070. minHeight: number;
  18071. maxHeight: number;
  18072. colorFilter: Color3;
  18073. buffer: Uint8Array;
  18074. bufferWidth: number;
  18075. bufferHeight: number;
  18076. }): VertexData;
  18077. /**
  18078. * Creates the VertexData of the Plane.
  18079. */
  18080. static CreatePlane(options: {
  18081. size?: number;
  18082. width?: number;
  18083. height?: number;
  18084. sideOrientation?: number;
  18085. frontUVs?: Vector4;
  18086. backUVs?: Vector4;
  18087. }): VertexData;
  18088. /**
  18089. * Creates the VertexData of the Disc or regular Polygon.
  18090. */
  18091. static CreateDisc(options: {
  18092. radius?: number;
  18093. tessellation?: number;
  18094. arc?: number;
  18095. sideOrientation?: number;
  18096. frontUVs?: Vector4;
  18097. backUVs?: Vector4;
  18098. }): VertexData;
  18099. /**
  18100. * Re-creates the VertexData of the Polygon for sideOrientation.
  18101. */
  18102. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  18103. /**
  18104. * Creates the VertexData of the IcoSphere.
  18105. */
  18106. static CreateIcoSphere(options: {
  18107. radius?: number;
  18108. radiusX?: number;
  18109. radiusY?: number;
  18110. radiusZ?: number;
  18111. flat?: boolean;
  18112. subdivisions?: number;
  18113. sideOrientation?: number;
  18114. frontUVs?: Vector4;
  18115. backUVs?: Vector4;
  18116. }): VertexData;
  18117. /**
  18118. * Creates the VertexData of the Polyhedron.
  18119. */
  18120. static CreatePolyhedron(options: {
  18121. type?: number;
  18122. size?: number;
  18123. sizeX?: number;
  18124. sizeY?: number;
  18125. sizeZ?: number;
  18126. custom?: any;
  18127. faceUV?: Vector4[];
  18128. faceColors?: Color4[];
  18129. flat?: boolean;
  18130. sideOrientation?: number;
  18131. frontUVs?: Vector4;
  18132. backUVs?: Vector4;
  18133. }): VertexData;
  18134. /**
  18135. * Creates the VertexData of the Torus Knot.
  18136. */
  18137. static CreateTorusKnot(options: {
  18138. radius?: number;
  18139. tube?: number;
  18140. radialSegments?: number;
  18141. tubularSegments?: number;
  18142. p?: number;
  18143. q?: number;
  18144. sideOrientation?: number;
  18145. frontUVs?: Vector4;
  18146. backUVs?: Vector4;
  18147. }): VertexData;
  18148. /**
  18149. * @param {any} - positions (number[] or Float32Array)
  18150. * @param {any} - indices (number[] or Uint16Array)
  18151. * @param {any} - normals (number[] or Float32Array)
  18152. * options (optional) :
  18153. * facetPositions : optional array of facet positions (vector3)
  18154. * facetNormals : optional array of facet normals (vector3)
  18155. * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  18156. * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  18157. * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  18158. * bbSize : optional bounding box size data, required for facetPartitioning computation
  18159. * bInfo : optional bounding info, required for facetPartitioning computation
  18160. * useRightHandedSystem: optional boolean to for right handed system computation
  18161. * depthSort : optional boolean to enable the facet depth sort computation
  18162. * distanceTo : optional Vector3 to compute the facet depth from this location
  18163. * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  18164. */
  18165. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  18166. facetNormals?: any;
  18167. facetPositions?: any;
  18168. facetPartitioning?: any;
  18169. ratio?: number;
  18170. bInfo?: any;
  18171. bbSize?: Vector3;
  18172. subDiv?: any;
  18173. useRightHandedSystem?: boolean;
  18174. depthSort?: boolean;
  18175. distanceTo?: Vector3;
  18176. depthSortedFacets?: any;
  18177. }): void;
  18178. private static _ComputeSides(sideOrientation, positions, indices, normals, uvs, frontUVs?, backUVs?);
  18179. /**
  18180. * Creates a new VertexData from the imported parameters.
  18181. */
  18182. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  18183. }
  18184. }
  18185. declare module BABYLON {
  18186. class MeshBuilder {
  18187. private static updateSideOrientation(orientation?);
  18188. /**
  18189. * Creates a box mesh.
  18190. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#box
  18191. * The parameter `size` sets the size (float) of each box side (default 1).
  18192. * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value than `size`).
  18193. * 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).
  18194. * Please read this tutorial : http://doc.babylonjs.com/tutorials/CreateBox_Per_Face_Textures_And_Colors
  18195. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  18196. * 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).
  18197. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  18198. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  18199. */
  18200. static CreateBox(name: string, options: {
  18201. size?: number;
  18202. width?: number;
  18203. height?: number;
  18204. depth?: number;
  18205. faceUV?: Vector4[];
  18206. faceColors?: Color4[];
  18207. sideOrientation?: number;
  18208. frontUVs?: Vector4;
  18209. backUVs?: Vector4;
  18210. updatable?: boolean;
  18211. }, scene?: Nullable<Scene>): Mesh;
  18212. /**
  18213. * Creates a sphere mesh.
  18214. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#sphere
  18215. * The parameter `diameter` sets the diameter size (float) of the sphere (default 1).
  18216. * 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`).
  18217. * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32).
  18218. * 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
  18219. * 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).
  18220. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  18221. * 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).
  18222. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  18223. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  18224. */
  18225. static CreateSphere(name: string, options: {
  18226. segments?: number;
  18227. diameter?: number;
  18228. diameterX?: number;
  18229. diameterY?: number;
  18230. diameterZ?: number;
  18231. arc?: number;
  18232. slice?: number;
  18233. sideOrientation?: number;
  18234. frontUVs?: Vector4;
  18235. backUVs?: Vector4;
  18236. updatable?: boolean;
  18237. }, scene: any): Mesh;
  18238. /**
  18239. * Creates a plane polygonal mesh. By default, this is a disc.
  18240. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#disc
  18241. * The parameter `radius` sets the radius size (float) of the polygon (default 0.5).
  18242. * 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.
  18243. * 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
  18244. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  18245. * 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).
  18246. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  18247. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  18248. */
  18249. static CreateDisc(name: string, options: {
  18250. radius?: number;
  18251. tessellation?: number;
  18252. arc?: number;
  18253. updatable?: boolean;
  18254. sideOrientation?: number;
  18255. frontUVs?: Vector4;
  18256. backUVs?: Vector4;
  18257. }, scene?: Nullable<Scene>): Mesh;
  18258. /**
  18259. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided.
  18260. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#icosphere
  18261. * The parameter `radius` sets the radius size (float) of the icosphere (default 1).
  18262. * 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`).
  18263. * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size.
  18264. * 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.
  18265. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  18266. * 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).
  18267. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  18268. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  18269. */
  18270. static CreateIcoSphere(name: string, options: {
  18271. radius?: number;
  18272. radiusX?: number;
  18273. radiusY?: number;
  18274. radiusZ?: number;
  18275. flat?: boolean;
  18276. subdivisions?: number;
  18277. sideOrientation?: number;
  18278. frontUVs?: Vector4;
  18279. backUVs?: Vector4;
  18280. updatable?: boolean;
  18281. }, scene: Scene): Mesh;
  18282. /**
  18283. * Creates a ribbon mesh.
  18284. * 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.
  18285. *
  18286. * Please read this full tutorial to understand how to design a ribbon : http://doc.babylonjs.com/tutorials/Ribbon_Tutorial
  18287. * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  18288. * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array.
  18289. * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array.
  18290. * 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.
  18291. * 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.
  18292. * 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
  18293. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  18294. * 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).
  18295. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  18296. * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  18297. * 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.
  18298. * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values.
  18299. * 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
  18300. * if you set `closePath` to `true`, there's one extra vertex per path in the geometry.
  18301. * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time.
  18302. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  18303. */
  18304. static CreateRibbon(name: string, options: {
  18305. pathArray: Vector3[][];
  18306. closeArray?: boolean;
  18307. closePath?: boolean;
  18308. offset?: number;
  18309. updatable?: boolean;
  18310. sideOrientation?: number;
  18311. frontUVs?: Vector4;
  18312. backUVs?: Vector4;
  18313. instance?: Mesh;
  18314. invertUV?: boolean;
  18315. uvs?: Vector2[];
  18316. colors?: Color4[];
  18317. }, scene?: Nullable<Scene>): Mesh;
  18318. /**
  18319. * Creates a cylinder or a cone mesh.
  18320. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#cylinder-or-cone
  18321. * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  18322. * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  18323. * 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.
  18324. * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  18325. * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  18326. * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  18327. * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  18328. * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  18329. * 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).
  18330. * 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
  18331. * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  18332. * 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
  18333. * 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.
  18334. * If `enclose` is false, a ring surface is one element.
  18335. * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  18336. * 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
  18337. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  18338. * 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).
  18339. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  18340. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  18341. */
  18342. static CreateCylinder(name: string, options: {
  18343. height?: number;
  18344. diameterTop?: number;
  18345. diameterBottom?: number;
  18346. diameter?: number;
  18347. tessellation?: number;
  18348. subdivisions?: number;
  18349. arc?: number;
  18350. faceColors?: Color4[];
  18351. faceUV?: Vector4[];
  18352. updatable?: boolean;
  18353. hasRings?: boolean;
  18354. enclose?: boolean;
  18355. sideOrientation?: number;
  18356. frontUVs?: Vector4;
  18357. backUVs?: Vector4;
  18358. }, scene: any): Mesh;
  18359. /**
  18360. * Creates a torus mesh.
  18361. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#torus
  18362. * The parameter `diameter` sets the diameter size (float) of the torus (default 1).
  18363. * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5).
  18364. * The parameter `tessellation` sets the number of torus sides (postive integer, default 16).
  18365. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  18366. * 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).
  18367. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  18368. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  18369. */
  18370. static CreateTorus(name: string, options: {
  18371. diameter?: number;
  18372. thickness?: number;
  18373. tessellation?: number;
  18374. updatable?: boolean;
  18375. sideOrientation?: number;
  18376. frontUVs?: Vector4;
  18377. backUVs?: Vector4;
  18378. }, scene: any): Mesh;
  18379. /**
  18380. * Creates a torus knot mesh.
  18381. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#torus-knot
  18382. * The parameter `radius` sets the global radius size (float) of the torus knot (default 2).
  18383. * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32).
  18384. * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32).
  18385. * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3).
  18386. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  18387. * 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).
  18388. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  18389. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  18390. */
  18391. static CreateTorusKnot(name: string, options: {
  18392. radius?: number;
  18393. tube?: number;
  18394. radialSegments?: number;
  18395. tubularSegments?: number;
  18396. p?: number;
  18397. q?: number;
  18398. updatable?: boolean;
  18399. sideOrientation?: number;
  18400. frontUVs?: Vector4;
  18401. backUVs?: Vector4;
  18402. }, scene: any): Mesh;
  18403. /**
  18404. * Creates a line system mesh.
  18405. * A line system is a pool of many lines gathered in a single mesh.
  18406. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#linesystem
  18407. * 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.
  18408. * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function.
  18409. * The parameter `lines` is an array of lines, each line being an array of successive Vector3.
  18410. * 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
  18411. * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point.
  18412. * The optional parameter `useVertexAlpha' is to be set to `false` (default `true`) when you don't need the alpha blending (faster).
  18413. * 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
  18414. * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines.
  18415. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  18416. */
  18417. static CreateLineSystem(name: string, options: {
  18418. lines: Vector3[][];
  18419. updatable: boolean;
  18420. instance: Nullable<LinesMesh>;
  18421. colors?: Nullable<Color4[][]>;
  18422. useVertexAlpha?: boolean;
  18423. }, scene: Nullable<Scene>): LinesMesh;
  18424. /**
  18425. * Creates a line mesh.
  18426. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#lines
  18427. * 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.
  18428. * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function.
  18429. * The parameter `points` is an array successive Vector3.
  18430. * 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
  18431. * The optional parameter `colors` is an array of successive Color4, one per line point.
  18432. * The optional parameter `useVertexAlpha' is to be set to `false` (default `true`) when you don't need alpha blending (faster).
  18433. * When updating an instance, remember that only point positions can change, not the number of points.
  18434. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  18435. */
  18436. static CreateLines(name: string, options: {
  18437. points: Vector3[];
  18438. updatable: boolean;
  18439. instance: Nullable<LinesMesh>;
  18440. colors?: Color4[];
  18441. useVertexAlpha?: boolean;
  18442. }, scene?: Nullable<Scene>): LinesMesh;
  18443. /**
  18444. * Creates a dashed line mesh.
  18445. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#dashed-lines
  18446. * 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.
  18447. * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function.
  18448. * The parameter `points` is an array successive Vector3.
  18449. * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200).
  18450. * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3).
  18451. * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1).
  18452. * 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
  18453. * When updating an instance, remember that only point positions can change, not the number of points.
  18454. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  18455. */
  18456. static CreateDashedLines(name: string, options: {
  18457. points: Vector3[];
  18458. dashSize?: number;
  18459. gapSize?: number;
  18460. dashNb?: number;
  18461. updatable?: boolean;
  18462. instance?: LinesMesh;
  18463. }, scene?: Nullable<Scene>): LinesMesh;
  18464. /**
  18465. * Creates an extruded shape mesh.
  18466. * 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.
  18467. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#extruded-shapes
  18468. *
  18469. * Please read this full tutorial to understand how to design an extruded shape : http://doc.babylonjs.com/tutorials/Parametric_Shapes#extrusion
  18470. * 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
  18471. * extruded along the Z axis.
  18472. * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  18473. * 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.
  18474. * The parameter `scale` (float, default 1) is the value to scale the shape.
  18475. * 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
  18476. * 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
  18477. * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  18478. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  18479. * 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).
  18480. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  18481. * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  18482. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  18483. */
  18484. static ExtrudeShape(name: string, options: {
  18485. shape: Vector3[];
  18486. path: Vector3[];
  18487. scale?: number;
  18488. rotation?: number;
  18489. cap?: number;
  18490. updatable?: boolean;
  18491. sideOrientation?: number;
  18492. frontUVs?: Vector4;
  18493. backUVs?: Vector4;
  18494. instance?: Mesh;
  18495. invertUV?: boolean;
  18496. }, scene?: Nullable<Scene>): Mesh;
  18497. /**
  18498. * Creates an custom extruded shape mesh.
  18499. * 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.
  18500. * tuto :http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#custom-extruded-shapes
  18501. *
  18502. * Please read this full tutorial to understand how to design a custom extruded shape : http://doc.babylonjs.com/tutorials/Parametric_Shapes#extrusion
  18503. * 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
  18504. * extruded along the Z axis.
  18505. * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  18506. * 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
  18507. * and the distance of this point from the begining of the path :
  18508. * ```javascript
  18509. * var rotationFunction = function(i, distance) {
  18510. * // do things
  18511. * return rotationValue; }
  18512. * ```
  18513. * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  18514. * 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
  18515. * and the distance of this point from the begining of the path :
  18516. * ```javascript
  18517. * var scaleFunction = function(i, distance) {
  18518. * // do things
  18519. * return scaleValue;}
  18520. * ```
  18521. * It must returns a float value that will be the scale value applied to the shape on each path point.
  18522. * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`.
  18523. * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`.
  18524. * 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
  18525. * 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
  18526. * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  18527. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  18528. * 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).
  18529. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  18530. * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  18531. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  18532. */
  18533. static ExtrudeShapeCustom(name: string, options: {
  18534. shape: Vector3[];
  18535. path: Vector3[];
  18536. scaleFunction?: any;
  18537. rotationFunction?: any;
  18538. ribbonCloseArray?: boolean;
  18539. ribbonClosePath?: boolean;
  18540. cap?: number;
  18541. updatable?: boolean;
  18542. sideOrientation?: number;
  18543. frontUVs?: Vector4;
  18544. backUVs?: Vector4;
  18545. instance?: Mesh;
  18546. invertUV?: boolean;
  18547. }, scene: Scene): Mesh;
  18548. /**
  18549. * Creates lathe mesh.
  18550. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  18551. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#lathe
  18552. *
  18553. * 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
  18554. * rotated around the Y axis. It's usually a 2D shape, so the Vector3 z coordinates are often set to zero.
  18555. * The parameter `radius` (positive float, default 1) is the radius value of the lathe.
  18556. * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe.
  18557. * 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.
  18558. * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc".
  18559. * 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
  18560. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  18561. * 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).
  18562. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  18563. * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  18564. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  18565. */
  18566. static CreateLathe(name: string, options: {
  18567. shape: Vector3[];
  18568. radius?: number;
  18569. tessellation?: number;
  18570. arc?: number;
  18571. closed?: boolean;
  18572. updatable?: boolean;
  18573. sideOrientation?: number;
  18574. frontUVs?: Vector4;
  18575. backUVs?: Vector4;
  18576. cap?: number;
  18577. invertUV?: boolean;
  18578. }, scene: Scene): Mesh;
  18579. /**
  18580. * Creates a plane mesh.
  18581. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#plane
  18582. * The parameter `size` sets the size (float) of both sides of the plane at once (default 1).
  18583. * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value than `size`).
  18584. * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane.
  18585. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  18586. * 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).
  18587. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  18588. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  18589. */
  18590. static CreatePlane(name: string, options: {
  18591. size?: number;
  18592. width?: number;
  18593. height?: number;
  18594. sideOrientation?: number;
  18595. frontUVs?: Vector4;
  18596. backUVs?: Vector4;
  18597. updatable?: boolean;
  18598. sourcePlane?: Plane;
  18599. }, scene: Scene): Mesh;
  18600. /**
  18601. * Creates a ground mesh.
  18602. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#plane
  18603. * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground.
  18604. * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side.
  18605. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  18606. */
  18607. static CreateGround(name: string, options: {
  18608. width?: number;
  18609. height?: number;
  18610. subdivisions?: number;
  18611. subdivisionsX?: number;
  18612. subdivisionsY?: number;
  18613. updatable?: boolean;
  18614. }, scene: any): Mesh;
  18615. /**
  18616. * Creates a tiled ground mesh.
  18617. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#tiled-ground
  18618. * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates.
  18619. * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates.
  18620. * The parameter `subdivisions` is a javascript object `{w: positive integer, h: positive integer}` (default `{w: 6, h: 6}`). `w` and `h` are the
  18621. * numbers of subdivisions on the ground width and height. Each subdivision is called a tile.
  18622. * The parameter `precision` is a javascript object `{w: positive integer, h: positive integer}` (default `{w: 2, h: 2}`). `w` and `h` are the
  18623. * numbers of subdivisions on the ground width and height of each tile.
  18624. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  18625. */
  18626. static CreateTiledGround(name: string, options: {
  18627. xmin: number;
  18628. zmin: number;
  18629. xmax: number;
  18630. zmax: number;
  18631. subdivisions?: {
  18632. w: number;
  18633. h: number;
  18634. };
  18635. precision?: {
  18636. w: number;
  18637. h: number;
  18638. };
  18639. updatable?: boolean;
  18640. }, scene: Scene): Mesh;
  18641. /**
  18642. * Creates a ground mesh from a height map.
  18643. * tuto : http://doc.babylonjs.com/tutorials/14._Height_Map
  18644. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#ground-from-a-height-map
  18645. * The parameter `url` sets the URL of the height map image resource.
  18646. * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  18647. * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  18648. * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  18649. * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  18650. * 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.
  18651. * 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).
  18652. * This function is passed the newly built mesh :
  18653. * ```javascript
  18654. * function(mesh) { // do things
  18655. * return; }
  18656. * ```
  18657. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  18658. */
  18659. static CreateGroundFromHeightMap(name: string, url: string, options: {
  18660. width?: number;
  18661. height?: number;
  18662. subdivisions?: number;
  18663. minHeight?: number;
  18664. maxHeight?: number;
  18665. colorFilter?: Color3;
  18666. updatable?: boolean;
  18667. onReady?: (mesh: GroundMesh) => void;
  18668. }, scene: Scene): GroundMesh;
  18669. /**
  18670. * Creates a polygon mesh.
  18671. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  18672. * 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.
  18673. * You can set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  18674. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  18675. * 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).
  18676. * Remember you can only change the shape positions, not their number when updating a polygon.
  18677. */
  18678. static CreatePolygon(name: string, options: {
  18679. shape: Vector3[];
  18680. holes?: Vector3[][];
  18681. depth?: number;
  18682. faceUV?: Vector4[];
  18683. faceColors?: Color4[];
  18684. updatable?: boolean;
  18685. sideOrientation?: number;
  18686. frontUVs?: Vector4;
  18687. backUVs?: Vector4;
  18688. }, scene: Scene): Mesh;
  18689. /**
  18690. * Creates an extruded polygon mesh, with depth in the Y direction.
  18691. * 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).
  18692. * Please read this tutorial : http://doc.babylonjs.com/tutorials/CreateBox_Per_Face_Textures_And_Colors
  18693. */
  18694. static ExtrudePolygon(name: string, options: {
  18695. shape: Vector3[];
  18696. holes?: Vector3[][];
  18697. depth?: number;
  18698. faceUV?: Vector4[];
  18699. faceColors?: Color4[];
  18700. updatable?: boolean;
  18701. sideOrientation?: number;
  18702. frontUVs?: Vector4;
  18703. backUVs?: Vector4;
  18704. }, scene: Scene): Mesh;
  18705. /**
  18706. * Creates a tube mesh.
  18707. * 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.
  18708. *
  18709. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#tube
  18710. * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube.
  18711. * The parameter `radius` (positive float, default 1) sets the tube radius size.
  18712. * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface.
  18713. * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`.
  18714. * 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.
  18715. * It must return a radius value (positive float) :
  18716. * ```javascript
  18717. * var radiusFunction = function(i, distance) {
  18718. * // do things
  18719. * return radius; }
  18720. * ```
  18721. * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc.
  18722. * 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
  18723. * 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
  18724. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  18725. * 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).
  18726. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  18727. * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  18728. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  18729. */
  18730. static CreateTube(name: string, options: {
  18731. path: Vector3[];
  18732. radius?: number;
  18733. tessellation?: number;
  18734. radiusFunction?: {
  18735. (i: number, distance: number): number;
  18736. };
  18737. cap?: number;
  18738. arc?: number;
  18739. updatable?: boolean;
  18740. sideOrientation?: number;
  18741. frontUVs?: Vector4;
  18742. backUVs?: Vector4;
  18743. instance?: Mesh;
  18744. invertUV?: boolean;
  18745. }, scene: Scene): Mesh;
  18746. /**
  18747. * Creates a polyhedron mesh.
  18748. *
  18749. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#polyhedron
  18750. * 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
  18751. * to choose the wanted type.
  18752. * The parameter `size` (positive float, default 1) sets the polygon size.
  18753. * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value).
  18754. * 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`.
  18755. * 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
  18756. * 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)`).
  18757. * 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
  18758. * 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.
  18759. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  18760. * 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).
  18761. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  18762. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  18763. */
  18764. static CreatePolyhedron(name: string, options: {
  18765. type?: number;
  18766. size?: number;
  18767. sizeX?: number;
  18768. sizeY?: number;
  18769. sizeZ?: number;
  18770. custom?: any;
  18771. faceUV?: Vector4[];
  18772. faceColors?: Color4[];
  18773. flat?: boolean;
  18774. updatable?: boolean;
  18775. sideOrientation?: number;
  18776. frontUVs?: Vector4;
  18777. backUVs?: Vector4;
  18778. }, scene: Scene): Mesh;
  18779. /**
  18780. * Creates a decal mesh.
  18781. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#decals
  18782. * 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.
  18783. * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates.
  18784. * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates.
  18785. * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling.
  18786. * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal.
  18787. */
  18788. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  18789. position?: Vector3;
  18790. normal?: Vector3;
  18791. size?: Vector3;
  18792. angle?: number;
  18793. }): Mesh;
  18794. private static _ExtrudeShapeGeneric(name, shape, curve, scale, rotation, scaleFunction, rotateFunction, rbCA, rbCP, cap, custom, scene, updtbl, side, instance, invertUV, frontUVs, backUVs);
  18795. }
  18796. }
  18797. declare module BABYLON {
  18798. class MeshLODLevel {
  18799. distance: number;
  18800. mesh: Mesh;
  18801. constructor(distance: number, mesh: Mesh);
  18802. }
  18803. }
  18804. declare module BABYLON {
  18805. /**
  18806. * A simplifier interface for future simplification implementations.
  18807. */
  18808. interface ISimplifier {
  18809. /**
  18810. * Simplification of a given mesh according to the given settings.
  18811. * Since this requires computation, it is assumed that the function runs async.
  18812. * @param settings The settings of the simplification, including quality and distance
  18813. * @param successCallback A callback that will be called after the mesh was simplified.
  18814. * @param errorCallback in case of an error, this callback will be called. optional.
  18815. */
  18816. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  18817. }
  18818. /**
  18819. * Expected simplification settings.
  18820. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%);
  18821. */
  18822. interface ISimplificationSettings {
  18823. quality: number;
  18824. distance: number;
  18825. optimizeMesh?: boolean;
  18826. }
  18827. class SimplificationSettings implements ISimplificationSettings {
  18828. quality: number;
  18829. distance: number;
  18830. optimizeMesh: boolean | undefined;
  18831. constructor(quality: number, distance: number, optimizeMesh?: boolean | undefined);
  18832. }
  18833. interface ISimplificationTask {
  18834. settings: Array<ISimplificationSettings>;
  18835. simplificationType: SimplificationType;
  18836. mesh: Mesh;
  18837. successCallback?: () => void;
  18838. parallelProcessing: boolean;
  18839. }
  18840. class SimplificationQueue {
  18841. private _simplificationArray;
  18842. running: boolean;
  18843. constructor();
  18844. addTask(task: ISimplificationTask): void;
  18845. executeNext(): void;
  18846. runSimplification(task: ISimplificationTask): void;
  18847. private getSimplifier(task);
  18848. }
  18849. /**
  18850. * The implemented types of simplification.
  18851. * At the moment only Quadratic Error Decimation is implemented.
  18852. */
  18853. enum SimplificationType {
  18854. QUADRATIC = 0,
  18855. }
  18856. class DecimationTriangle {
  18857. vertices: Array<DecimationVertex>;
  18858. normal: Vector3;
  18859. error: Array<number>;
  18860. deleted: boolean;
  18861. isDirty: boolean;
  18862. borderFactor: number;
  18863. deletePending: boolean;
  18864. originalOffset: number;
  18865. constructor(vertices: Array<DecimationVertex>);
  18866. }
  18867. class DecimationVertex {
  18868. position: Vector3;
  18869. id: number;
  18870. q: QuadraticMatrix;
  18871. isBorder: boolean;
  18872. triangleStart: number;
  18873. triangleCount: number;
  18874. originalOffsets: Array<number>;
  18875. constructor(position: Vector3, id: number);
  18876. updatePosition(newPosition: Vector3): void;
  18877. }
  18878. class QuadraticMatrix {
  18879. data: Array<number>;
  18880. constructor(data?: Array<number>);
  18881. det(a11: number, a12: number, a13: number, a21: number, a22: number, a23: number, a31: number, a32: number, a33: number): number;
  18882. addInPlace(matrix: QuadraticMatrix): void;
  18883. addArrayInPlace(data: Array<number>): void;
  18884. add(matrix: QuadraticMatrix): QuadraticMatrix;
  18885. static FromData(a: number, b: number, c: number, d: number): QuadraticMatrix;
  18886. static DataFromNumbers(a: number, b: number, c: number, d: number): number[];
  18887. }
  18888. class Reference {
  18889. vertexId: number;
  18890. triangleId: number;
  18891. constructor(vertexId: number, triangleId: number);
  18892. }
  18893. /**
  18894. * An implementation of the Quadratic Error simplification algorithm.
  18895. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  18896. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  18897. * @author RaananW
  18898. */
  18899. class QuadraticErrorSimplification implements ISimplifier {
  18900. private _mesh;
  18901. private triangles;
  18902. private vertices;
  18903. private references;
  18904. private _reconstructedMesh;
  18905. syncIterations: number;
  18906. aggressiveness: number;
  18907. decimationIterations: number;
  18908. boundingBoxEpsilon: number;
  18909. constructor(_mesh: Mesh);
  18910. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  18911. private runDecimation(settings, submeshIndex, successCallback);
  18912. private initWithMesh(submeshIndex, callback, optimizeMesh?);
  18913. private init(callback);
  18914. private reconstructMesh(submeshIndex);
  18915. private initDecimatedMesh();
  18916. private isFlipped(vertex1, vertex2, point, deletedArray, borderFactor, delTr);
  18917. private updateTriangles(origVertex, vertex, deletedArray, deletedTriangles);
  18918. private identifyBorder();
  18919. private updateMesh(identifyBorders?);
  18920. private vertexError(q, point);
  18921. private calculateError(vertex1, vertex2, pointResult?, normalResult?, uvResult?, colorResult?);
  18922. }
  18923. }
  18924. declare module BABYLON {
  18925. class Polygon {
  18926. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  18927. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  18928. static Parse(input: string): Vector2[];
  18929. static StartingAt(x: number, y: number): Path2;
  18930. }
  18931. class PolygonMeshBuilder {
  18932. private _points;
  18933. private _outlinepoints;
  18934. private _holes;
  18935. private _name;
  18936. private _scene;
  18937. private _epoints;
  18938. private _eholes;
  18939. private _addToepoint(points);
  18940. constructor(name: string, contours: Path2, scene: Scene);
  18941. constructor(name: string, contours: Vector2[], scene: Scene);
  18942. addHole(hole: Vector2[]): PolygonMeshBuilder;
  18943. build(updatable?: boolean, depth?: number): Mesh;
  18944. private addSide(positions, normals, uvs, indices, bounds, points, depth, flip);
  18945. }
  18946. }
  18947. declare module BABYLON {
  18948. class BaseSubMesh {
  18949. _materialDefines: Nullable<MaterialDefines>;
  18950. _materialEffect: Nullable<Effect>;
  18951. readonly effect: Nullable<Effect>;
  18952. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  18953. }
  18954. class SubMesh extends BaseSubMesh implements ICullable {
  18955. materialIndex: number;
  18956. verticesStart: number;
  18957. verticesCount: number;
  18958. indexStart: number;
  18959. indexCount: number;
  18960. linesIndexCount: number;
  18961. private _mesh;
  18962. private _renderingMesh;
  18963. private _boundingInfo;
  18964. private _linesIndexBuffer;
  18965. _lastColliderWorldVertices: Nullable<Vector3[]>;
  18966. _trianglePlanes: Plane[];
  18967. _lastColliderTransformMatrix: Matrix;
  18968. _renderId: number;
  18969. _alphaIndex: number;
  18970. _distanceToCamera: number;
  18971. _id: number;
  18972. private _currentMaterial;
  18973. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  18974. constructor(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  18975. readonly IsGlobal: boolean;
  18976. /**
  18977. * Returns the submesh BoudingInfo object.
  18978. */
  18979. getBoundingInfo(): BoundingInfo;
  18980. /**
  18981. * Sets the submesh BoundingInfo.
  18982. * Return the SubMesh.
  18983. */
  18984. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  18985. /**
  18986. * Returns the mesh of the current submesh.
  18987. */
  18988. getMesh(): AbstractMesh;
  18989. /**
  18990. * Returns the rendering mesh of the submesh.
  18991. */
  18992. getRenderingMesh(): Mesh;
  18993. /**
  18994. * Returns the submesh material.
  18995. */
  18996. getMaterial(): Nullable<Material>;
  18997. /**
  18998. * Sets a new updated BoundingInfo object to the submesh.
  18999. * Returns the SubMesh.
  19000. */
  19001. refreshBoundingInfo(): SubMesh;
  19002. _checkCollision(collider: Collider): boolean;
  19003. /**
  19004. * Updates the submesh BoundingInfo.
  19005. * Returns the Submesh.
  19006. */
  19007. updateBoundingInfo(world: Matrix): SubMesh;
  19008. /**
  19009. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  19010. * Boolean returned.
  19011. */
  19012. isInFrustum(frustumPlanes: Plane[]): boolean;
  19013. /**
  19014. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes.
  19015. * Boolean returned.
  19016. */
  19017. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  19018. /**
  19019. * Renders the submesh.
  19020. * Returns it.
  19021. */
  19022. render(enableAlphaMode: boolean): SubMesh;
  19023. /**
  19024. * Returns a new Index Buffer.
  19025. * Type returned : WebGLBuffer.
  19026. */
  19027. getLinesIndexBuffer(indices: IndicesArray, engine: Engine): WebGLBuffer;
  19028. /**
  19029. * True is the passed Ray intersects the submesh bounding box.
  19030. * Boolean returned.
  19031. */
  19032. canIntersects(ray: Ray): boolean;
  19033. /**
  19034. * Returns an object IntersectionInfo.
  19035. */
  19036. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean): Nullable<IntersectionInfo>;
  19037. _rebuild(): void;
  19038. /**
  19039. * Creates a new Submesh from the passed Mesh.
  19040. */
  19041. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  19042. /**
  19043. * Disposes the Submesh.
  19044. * Returns nothing.
  19045. */
  19046. dispose(): void;
  19047. /**
  19048. * Creates a new Submesh from the passed parameters :
  19049. * - materialIndex (integer) : the index of the main mesh material.
  19050. * - startIndex (integer) : the index where to start the copy in the mesh indices array.
  19051. * - indexCount (integer) : the number of indices to copy then from the startIndex.
  19052. * - mesh (Mesh) : the main mesh to create the submesh from.
  19053. * - renderingMesh (optional Mesh) : rendering mesh.
  19054. */
  19055. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  19056. }
  19057. }
  19058. declare module BABYLON {
  19059. class TransformNode extends Node {
  19060. static BILLBOARDMODE_NONE: number;
  19061. static BILLBOARDMODE_X: number;
  19062. static BILLBOARDMODE_Y: number;
  19063. static BILLBOARDMODE_Z: number;
  19064. static BILLBOARDMODE_ALL: number;
  19065. private _forward;
  19066. private _forwardInverted;
  19067. private _up;
  19068. private _right;
  19069. private _rightInverted;
  19070. private _rotation;
  19071. private _rotationQuaternion;
  19072. protected _scaling: Vector3;
  19073. protected _isDirty: boolean;
  19074. private _transformToBoneReferal;
  19075. billboardMode: number;
  19076. scalingDeterminant: number;
  19077. infiniteDistance: boolean;
  19078. position: Vector3;
  19079. _poseMatrix: Matrix;
  19080. private _localWorld;
  19081. _worldMatrix: Matrix;
  19082. _worldMatrixDeterminant: number;
  19083. private _absolutePosition;
  19084. private _pivotMatrix;
  19085. private _pivotMatrixInverse;
  19086. private _postMultiplyPivotMatrix;
  19087. protected _isWorldMatrixFrozen: boolean;
  19088. /**
  19089. * An event triggered after the world matrix is updated
  19090. */
  19091. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  19092. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  19093. /**
  19094. * Gets a string idenfifying the name of the class
  19095. * @returns "TransformNode" string
  19096. */
  19097. getClassName(): string;
  19098. /**
  19099. * Rotation property : a Vector3 depicting the rotation value in radians around each local axis X, Y, Z.
  19100. * If rotation quaternion is set, this Vector3 will (almost always) be the Zero vector!
  19101. * Default : (0.0, 0.0, 0.0)
  19102. */
  19103. rotation: Vector3;
  19104. /**
  19105. * Scaling property : a Vector3 depicting the mesh scaling along each local axis X, Y, Z.
  19106. * Default : (1.0, 1.0, 1.0)
  19107. */
  19108. /**
  19109. * Scaling property : a Vector3 depicting the mesh scaling along each local axis X, Y, Z.
  19110. * Default : (1.0, 1.0, 1.0)
  19111. */
  19112. scaling: Vector3;
  19113. /**
  19114. * Rotation Quaternion property : this a Quaternion object depicting the mesh rotation by using a unit quaternion.
  19115. * It's null by default.
  19116. * 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)
  19117. */
  19118. rotationQuaternion: Nullable<Quaternion>;
  19119. /**
  19120. * The forward direction of that transform in world space.
  19121. */
  19122. readonly forward: Vector3;
  19123. /**
  19124. * The up direction of that transform in world space.
  19125. */
  19126. readonly up: Vector3;
  19127. /**
  19128. * The right direction of that transform in world space.
  19129. */
  19130. readonly right: Vector3;
  19131. /**
  19132. * Returns the latest update of the World matrix
  19133. * Returns a Matrix.
  19134. */
  19135. getWorldMatrix(): Matrix;
  19136. /**
  19137. * Returns the latest update of the World matrix determinant.
  19138. */
  19139. protected _getWorldMatrixDeterminant(): number;
  19140. /**
  19141. * Returns directly the latest state of the mesh World matrix.
  19142. * A Matrix is returned.
  19143. */
  19144. readonly worldMatrixFromCache: Matrix;
  19145. /**
  19146. * Copies the paramater passed Matrix into the mesh Pose matrix.
  19147. * Returns the TransformNode.
  19148. */
  19149. updatePoseMatrix(matrix: Matrix): TransformNode;
  19150. /**
  19151. * Returns the mesh Pose matrix.
  19152. * Returned object : Matrix
  19153. */
  19154. getPoseMatrix(): Matrix;
  19155. _isSynchronized(): boolean;
  19156. _initCache(): void;
  19157. markAsDirty(property: string): TransformNode;
  19158. /**
  19159. * Returns the current mesh absolute position.
  19160. * Retuns a Vector3.
  19161. */
  19162. readonly absolutePosition: Vector3;
  19163. /**
  19164. * Sets a new matrix to apply before all other transformation
  19165. * @param matrix defines the transform matrix
  19166. * @returns the current TransformNode
  19167. */
  19168. setPreTransformMatrix(matrix: Matrix): TransformNode;
  19169. /**
  19170. * Sets a new pivot matrix to the current node
  19171. * @param matrix defines the new pivot matrix to use
  19172. * @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
  19173. * @returns the current TransformNode
  19174. */
  19175. setPivotMatrix(matrix: Matrix, postMultiplyPivotMatrix?: boolean): TransformNode;
  19176. /**
  19177. * Returns the mesh pivot matrix.
  19178. * Default : Identity.
  19179. * A Matrix is returned.
  19180. */
  19181. getPivotMatrix(): Matrix;
  19182. /**
  19183. * Prevents the World matrix to be computed any longer.
  19184. * Returns the TransformNode.
  19185. */
  19186. freezeWorldMatrix(): TransformNode;
  19187. /**
  19188. * Allows back the World matrix computation.
  19189. * Returns the TransformNode.
  19190. */
  19191. unfreezeWorldMatrix(): this;
  19192. /**
  19193. * True if the World matrix has been frozen.
  19194. * Returns a boolean.
  19195. */
  19196. readonly isWorldMatrixFrozen: boolean;
  19197. /**
  19198. * Retuns the mesh absolute position in the World.
  19199. * Returns a Vector3.
  19200. */
  19201. getAbsolutePosition(): Vector3;
  19202. /**
  19203. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  19204. * Returns the TransformNode.
  19205. */
  19206. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  19207. /**
  19208. * Sets the mesh position in its local space.
  19209. * Returns the TransformNode.
  19210. */
  19211. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  19212. /**
  19213. * Returns the mesh position in the local space from the current World matrix values.
  19214. * Returns a new Vector3.
  19215. */
  19216. getPositionExpressedInLocalSpace(): Vector3;
  19217. /**
  19218. * Translates the mesh along the passed Vector3 in its local space.
  19219. * Returns the TransformNode.
  19220. */
  19221. locallyTranslate(vector3: Vector3): TransformNode;
  19222. private static _lookAtVectorCache;
  19223. /**
  19224. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  19225. * @param targetPoint the position (must be in same space as current mesh) to look at
  19226. * @param yawCor optional yaw (y-axis) correction in radians
  19227. * @param pitchCor optional pitch (x-axis) correction in radians
  19228. * @param rollCor optional roll (z-axis) correction in radians
  19229. * @param space the choosen space of the target
  19230. * @returns the TransformNode.
  19231. */
  19232. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  19233. /**
  19234. * Returns a new Vector3 what is the localAxis, expressed in the mesh local space, rotated like the mesh.
  19235. * This Vector3 is expressed in the World space.
  19236. */
  19237. getDirection(localAxis: Vector3): Vector3;
  19238. /**
  19239. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  19240. * localAxis is expressed in the mesh local space.
  19241. * result is computed in the Wordl space from the mesh World matrix.
  19242. * Returns the TransformNode.
  19243. */
  19244. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  19245. /**
  19246. * Sets a new pivot point to the current node
  19247. * @param point defines the new pivot point to use
  19248. * @param space defines if the point is in world or local space (local by default)
  19249. * @returns the current TransformNode
  19250. */
  19251. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  19252. /**
  19253. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  19254. */
  19255. getPivotPoint(): Vector3;
  19256. /**
  19257. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  19258. * Returns the TransformNode.
  19259. */
  19260. getPivotPointToRef(result: Vector3): TransformNode;
  19261. /**
  19262. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  19263. */
  19264. getAbsolutePivotPoint(): Vector3;
  19265. /**
  19266. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  19267. * Returns the TransformNode.
  19268. */
  19269. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  19270. /**
  19271. * Defines the passed node as the parent of the current node.
  19272. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  19273. * Returns the TransformNode.
  19274. */
  19275. setParent(node: Nullable<Node>): TransformNode;
  19276. private _nonUniformScaling;
  19277. readonly nonUniformScaling: boolean;
  19278. _updateNonUniformScalingState(value: boolean): boolean;
  19279. /**
  19280. * Attach the current TransformNode to another TransformNode associated with a bone
  19281. * @param bone Bone affecting the TransformNode
  19282. * @param affectedTransformNode TransformNode associated with the bone
  19283. */
  19284. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  19285. detachFromBone(): TransformNode;
  19286. private static _rotationAxisCache;
  19287. /**
  19288. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  19289. * space (default LOCAL) can be either BABYLON.Space.LOCAL, either BABYLON.Space.WORLD.
  19290. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  19291. * The passed axis is also normalized.
  19292. * Returns the TransformNode.
  19293. */
  19294. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  19295. /**
  19296. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  19297. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  19298. * The passed axis is also normalized.
  19299. * Returns the TransformNode.
  19300. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  19301. */
  19302. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  19303. /**
  19304. * Translates the mesh along the axis vector for the passed distance in the given space.
  19305. * space (default LOCAL) can be either BABYLON.Space.LOCAL, either BABYLON.Space.WORLD.
  19306. * Returns the TransformNode.
  19307. */
  19308. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  19309. /**
  19310. * Adds a rotation step to the mesh current rotation.
  19311. * x, y, z are Euler angles expressed in radians.
  19312. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  19313. * This means this rotation is made in the mesh local space only.
  19314. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  19315. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  19316. * ```javascript
  19317. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  19318. * ```
  19319. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  19320. * 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.
  19321. * Returns the TransformNode.
  19322. */
  19323. addRotation(x: number, y: number, z: number): TransformNode;
  19324. /**
  19325. * Computes the mesh World matrix and returns it.
  19326. * If the mesh world matrix is frozen, this computation does nothing more than returning the last frozen values.
  19327. * If the parameter `force` is let to `false` (default), the current cached World matrix is returned.
  19328. * If the parameter `force`is set to `true`, the actual computation is done.
  19329. * Returns the mesh World Matrix.
  19330. */
  19331. computeWorldMatrix(force?: boolean): Matrix;
  19332. protected _afterComputeWorldMatrix(): void;
  19333. /**
  19334. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  19335. * @param func: callback function to add
  19336. *
  19337. * Returns the TransformNode.
  19338. */
  19339. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  19340. /**
  19341. * Removes a registered callback function.
  19342. * Returns the TransformNode.
  19343. */
  19344. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  19345. /**
  19346. * Clone the current transform node
  19347. * Returns the new transform node
  19348. * @param name Name of the new clone
  19349. * @param newParent New parent for the clone
  19350. * @param doNotCloneChildren Do not clone children hierarchy
  19351. */
  19352. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  19353. serialize(currentSerializationObject?: any): any;
  19354. /**
  19355. * Returns a new TransformNode object parsed from the source provided.
  19356. * The parameter `parsedMesh` is the source.
  19357. * The parameter `rootUrl` is a string, it's the root URL to prefix the `delayLoadingFile` property with
  19358. */
  19359. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  19360. /**
  19361. * Releases resources associated with this transform node.
  19362. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  19363. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  19364. */
  19365. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  19366. }
  19367. }
  19368. declare module BABYLON {
  19369. class VertexBuffer {
  19370. private _buffer;
  19371. private _kind;
  19372. private _offset;
  19373. private _size;
  19374. private _stride;
  19375. private _ownsBuffer;
  19376. private _instanced;
  19377. private _instanceDivisor;
  19378. /**
  19379. * Gets or sets the instance divisor when in instanced mode
  19380. */
  19381. instanceDivisor: number;
  19382. constructor(engine: any, data: FloatArray | Buffer, kind: string, updatable: boolean, postponeInternalCreation?: boolean, stride?: number, instanced?: boolean, offset?: number, size?: number);
  19383. _rebuild(): void;
  19384. /**
  19385. * Returns the kind of the VertexBuffer (string).
  19386. */
  19387. getKind(): string;
  19388. /**
  19389. * Boolean : is the VertexBuffer updatable ?
  19390. */
  19391. isUpdatable(): boolean;
  19392. /**
  19393. * Returns an array of numbers or a Float32Array containing the VertexBuffer data.
  19394. */
  19395. getData(): Nullable<FloatArray>;
  19396. /**
  19397. * Returns the WebGLBuffer associated to the VertexBuffer.
  19398. */
  19399. getBuffer(): Nullable<WebGLBuffer>;
  19400. /**
  19401. * Returns the stride of the VertexBuffer (integer).
  19402. */
  19403. getStrideSize(): number;
  19404. /**
  19405. * Returns the offset (integer).
  19406. */
  19407. getOffset(): number;
  19408. /**
  19409. * Returns the VertexBuffer total size (integer).
  19410. */
  19411. getSize(): number;
  19412. /**
  19413. * Boolean : is the WebGLBuffer of the VertexBuffer instanced now ?
  19414. */
  19415. getIsInstanced(): boolean;
  19416. /**
  19417. * Returns the instancing divisor, zero for non-instanced (integer).
  19418. */
  19419. getInstanceDivisor(): number;
  19420. /**
  19421. * Creates the underlying WebGLBuffer from the passed numeric array or Float32Array.
  19422. * Returns the created WebGLBuffer.
  19423. */
  19424. create(data?: FloatArray): void;
  19425. /**
  19426. * Updates the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  19427. * This function will create a new buffer if the current one is not updatable
  19428. * Returns the updated WebGLBuffer.
  19429. */
  19430. update(data: FloatArray): void;
  19431. /**
  19432. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  19433. * Returns the directly updated WebGLBuffer.
  19434. */
  19435. updateDirectly(data: Float32Array, offset: number): void;
  19436. /**
  19437. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  19438. */
  19439. dispose(): void;
  19440. private static _PositionKind;
  19441. private static _NormalKind;
  19442. private static _TangentKind;
  19443. private static _UVKind;
  19444. private static _UV2Kind;
  19445. private static _UV3Kind;
  19446. private static _UV4Kind;
  19447. private static _UV5Kind;
  19448. private static _UV6Kind;
  19449. private static _ColorKind;
  19450. private static _MatricesIndicesKind;
  19451. private static _MatricesWeightsKind;
  19452. private static _MatricesIndicesExtraKind;
  19453. private static _MatricesWeightsExtraKind;
  19454. static readonly PositionKind: string;
  19455. static readonly NormalKind: string;
  19456. static readonly TangentKind: string;
  19457. static readonly UVKind: string;
  19458. static readonly UV2Kind: string;
  19459. static readonly UV3Kind: string;
  19460. static readonly UV4Kind: string;
  19461. static readonly UV5Kind: string;
  19462. static readonly UV6Kind: string;
  19463. static readonly ColorKind: string;
  19464. static readonly MatricesIndicesKind: string;
  19465. static readonly MatricesWeightsKind: string;
  19466. static readonly MatricesIndicesExtraKind: string;
  19467. static readonly MatricesWeightsExtraKind: string;
  19468. /**
  19469. * Deduces the stride given a kind.
  19470. * @param kind The kind string to deduce
  19471. * @returns The deduced stride
  19472. */
  19473. static DeduceStride(kind: string): number;
  19474. }
  19475. }
  19476. declare module BABYLON {
  19477. interface PhysicsImpostorJoint {
  19478. mainImpostor: PhysicsImpostor;
  19479. connectedImpostor: PhysicsImpostor;
  19480. joint: PhysicsJoint;
  19481. }
  19482. class PhysicsEngine {
  19483. private _physicsPlugin;
  19484. gravity: Vector3;
  19485. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  19486. setGravity(gravity: Vector3): void;
  19487. /**
  19488. * Set the time step of the physics engine.
  19489. * default is 1/60.
  19490. * To slow it down, enter 1/600 for example.
  19491. * To speed it up, 1/30
  19492. * @param {number} newTimeStep the new timestep to apply to this world.
  19493. */
  19494. setTimeStep(newTimeStep?: number): void;
  19495. /**
  19496. * Get the time step of the physics engine.
  19497. */
  19498. getTimeStep(): number;
  19499. dispose(): void;
  19500. getPhysicsPluginName(): string;
  19501. static Epsilon: number;
  19502. private _impostors;
  19503. private _joints;
  19504. /**
  19505. * Adding a new impostor for the impostor tracking.
  19506. * This will be done by the impostor itself.
  19507. * @param {PhysicsImpostor} impostor the impostor to add
  19508. */
  19509. addImpostor(impostor: PhysicsImpostor): void;
  19510. /**
  19511. * Remove an impostor from the engine.
  19512. * This impostor and its mesh will not longer be updated by the physics engine.
  19513. * @param {PhysicsImpostor} impostor the impostor to remove
  19514. */
  19515. removeImpostor(impostor: PhysicsImpostor): void;
  19516. /**
  19517. * Add a joint to the physics engine
  19518. * @param {PhysicsImpostor} mainImpostor the main impostor to which the joint is added.
  19519. * @param {PhysicsImpostor} connectedImpostor the impostor that is connected to the main impostor using this joint
  19520. * @param {PhysicsJoint} the joint that will connect both impostors.
  19521. */
  19522. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  19523. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  19524. /**
  19525. * Called by the scene. no need to call it.
  19526. */
  19527. _step(delta: number): void;
  19528. getPhysicsPlugin(): IPhysicsEnginePlugin;
  19529. getImpostors(): Array<PhysicsImpostor>;
  19530. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  19531. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  19532. }
  19533. interface IPhysicsEnginePlugin {
  19534. world: any;
  19535. name: string;
  19536. setGravity(gravity: Vector3): void;
  19537. setTimeStep(timeStep: number): void;
  19538. getTimeStep(): number;
  19539. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  19540. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  19541. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  19542. generatePhysicsBody(impostor: PhysicsImpostor): void;
  19543. removePhysicsBody(impostor: PhysicsImpostor): void;
  19544. generateJoint(joint: PhysicsImpostorJoint): void;
  19545. removeJoint(joint: PhysicsImpostorJoint): void;
  19546. isSupported(): boolean;
  19547. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  19548. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  19549. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  19550. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  19551. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  19552. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  19553. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  19554. getBodyMass(impostor: PhysicsImpostor): number;
  19555. getBodyFriction(impostor: PhysicsImpostor): number;
  19556. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  19557. getBodyRestitution(impostor: PhysicsImpostor): number;
  19558. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  19559. sleepBody(impostor: PhysicsImpostor): void;
  19560. wakeUpBody(impostor: PhysicsImpostor): void;
  19561. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  19562. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  19563. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  19564. getRadius(impostor: PhysicsImpostor): number;
  19565. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  19566. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  19567. dispose(): void;
  19568. }
  19569. }
  19570. declare module BABYLON {
  19571. class PhysicsHelper {
  19572. private _scene;
  19573. private _physicsEngine;
  19574. constructor(scene: Scene);
  19575. /**
  19576. * @param {Vector3} origin the origin of the explosion
  19577. * @param {number} radius the explosion radius
  19578. * @param {number} strength the explosion strength
  19579. * @param {PhysicsRadialImpulseFalloff} falloff possible options: Constant & Linear. Defaults to Constant
  19580. */
  19581. applyRadialExplosionImpulse(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  19582. /**
  19583. * @param {Vector3} origin the origin of the explosion
  19584. * @param {number} radius the explosion radius
  19585. * @param {number} strength the explosion strength
  19586. * @param {PhysicsRadialImpulseFalloff} falloff possible options: Constant & Linear. Defaults to Constant
  19587. */
  19588. applyRadialExplosionForce(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  19589. /**
  19590. * @param {Vector3} origin the origin of the explosion
  19591. * @param {number} radius the explosion radius
  19592. * @param {number} strength the explosion strength
  19593. * @param {PhysicsRadialImpulseFalloff} falloff possible options: Constant & Linear. Defaults to Constant
  19594. */
  19595. gravitationalField(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  19596. /**
  19597. * @param {Vector3} origin the origin of the updraft
  19598. * @param {number} radius the radius of the updraft
  19599. * @param {number} strength the strength of the updraft
  19600. * @param {number} height the height of the updraft
  19601. * @param {PhysicsUpdraftMode} updraftMode possible options: Center & Perpendicular. Defaults to Center
  19602. */
  19603. updraft(origin: Vector3, radius: number, strength: number, height: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  19604. /**
  19605. * @param {Vector3} origin the of the vortex
  19606. * @param {number} radius the radius of the vortex
  19607. * @param {number} strength the strength of the vortex
  19608. * @param {number} height the height of the vortex
  19609. */
  19610. vortex(origin: Vector3, radius: number, strength: number, height: number): Nullable<PhysicsVortexEvent>;
  19611. }
  19612. /***** Radial explosion *****/
  19613. class PhysicsRadialExplosionEvent {
  19614. private _scene;
  19615. private _sphere;
  19616. private _sphereOptions;
  19617. private _rays;
  19618. private _dataFetched;
  19619. constructor(scene: Scene);
  19620. /**
  19621. * Returns the data related to the radial explosion event (sphere & rays).
  19622. * @returns {PhysicsRadialExplosionEventData}
  19623. */
  19624. getData(): PhysicsRadialExplosionEventData;
  19625. /**
  19626. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  19627. * @param impostor
  19628. * @param {Vector3} origin the origin of the explosion
  19629. * @param {number} radius the explosion radius
  19630. * @param {number} strength the explosion strength
  19631. * @param {PhysicsRadialImpulseFalloff} falloff possible options: Constant & Linear
  19632. * @returns {Nullable<PhysicsForceAndContactPoint>}
  19633. */
  19634. getImpostorForceAndContactPoint(impostor: PhysicsImpostor, origin: Vector3, radius: number, strength: number, falloff: PhysicsRadialImpulseFalloff): Nullable<PhysicsForceAndContactPoint>;
  19635. /**
  19636. * Disposes the sphere.
  19637. * @param {bolean} force
  19638. */
  19639. dispose(force?: boolean): void;
  19640. /*** Helpers ***/
  19641. private _prepareSphere();
  19642. private _intersectsWithSphere(impostor, origin, radius);
  19643. }
  19644. /***** Gravitational Field *****/
  19645. class PhysicsGravitationalFieldEvent {
  19646. private _physicsHelper;
  19647. private _scene;
  19648. private _origin;
  19649. private _radius;
  19650. private _strength;
  19651. private _falloff;
  19652. private _tickCallback;
  19653. private _sphere;
  19654. private _dataFetched;
  19655. constructor(physicsHelper: PhysicsHelper, scene: Scene, origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff);
  19656. /**
  19657. * Returns the data related to the gravitational field event (sphere).
  19658. * @returns {PhysicsGravitationalFieldEventData}
  19659. */
  19660. getData(): PhysicsGravitationalFieldEventData;
  19661. /**
  19662. * Enables the gravitational field.
  19663. */
  19664. enable(): void;
  19665. /**
  19666. * Disables the gravitational field.
  19667. */
  19668. disable(): void;
  19669. /**
  19670. * Disposes the sphere.
  19671. * @param {bolean} force
  19672. */
  19673. dispose(force?: boolean): void;
  19674. private _tick();
  19675. }
  19676. /***** Updraft *****/
  19677. class PhysicsUpdraftEvent {
  19678. private _scene;
  19679. private _origin;
  19680. private _radius;
  19681. private _strength;
  19682. private _height;
  19683. private _updraftMode;
  19684. private _physicsEngine;
  19685. private _originTop;
  19686. private _originDirection;
  19687. private _tickCallback;
  19688. private _cylinder;
  19689. private _cylinderPosition;
  19690. private _dataFetched;
  19691. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number, _updraftMode: PhysicsUpdraftMode);
  19692. /**
  19693. * Returns the data related to the updraft event (cylinder).
  19694. * @returns {PhysicsUpdraftEventData}
  19695. */
  19696. getData(): PhysicsUpdraftEventData;
  19697. /**
  19698. * Enables the updraft.
  19699. */
  19700. enable(): void;
  19701. /**
  19702. * Disables the cortex.
  19703. */
  19704. disable(): void;
  19705. /**
  19706. * Disposes the sphere.
  19707. * @param {bolean} force
  19708. */
  19709. dispose(force?: boolean): void;
  19710. private getImpostorForceAndContactPoint(impostor);
  19711. private _tick();
  19712. /*** Helpers ***/
  19713. private _prepareCylinder();
  19714. private _intersectsWithCylinder(impostor);
  19715. }
  19716. /***** Vortex *****/
  19717. class PhysicsVortexEvent {
  19718. private _scene;
  19719. private _origin;
  19720. private _radius;
  19721. private _strength;
  19722. private _height;
  19723. private _physicsEngine;
  19724. private _originTop;
  19725. private _centripetalForceThreshold;
  19726. private _updraftMultiplier;
  19727. private _tickCallback;
  19728. private _cylinder;
  19729. private _cylinderPosition;
  19730. private _dataFetched;
  19731. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number);
  19732. /**
  19733. * Returns the data related to the vortex event (cylinder).
  19734. * @returns {PhysicsVortexEventData}
  19735. */
  19736. getData(): PhysicsVortexEventData;
  19737. /**
  19738. * Enables the vortex.
  19739. */
  19740. enable(): void;
  19741. /**
  19742. * Disables the cortex.
  19743. */
  19744. disable(): void;
  19745. /**
  19746. * Disposes the sphere.
  19747. * @param {bolean} force
  19748. */
  19749. dispose(force?: boolean): void;
  19750. private getImpostorForceAndContactPoint(impostor);
  19751. private _tick();
  19752. /*** Helpers ***/
  19753. private _prepareCylinder();
  19754. private _intersectsWithCylinder(impostor);
  19755. }
  19756. /***** Enums *****/
  19757. /**
  19758. * The strenght of the force in correspondence to the distance of the affected object
  19759. */
  19760. enum PhysicsRadialImpulseFalloff {
  19761. Constant = 0,
  19762. Linear = 1,
  19763. }
  19764. /**
  19765. * The strenght of the force in correspondence to the distance of the affected object
  19766. */
  19767. enum PhysicsUpdraftMode {
  19768. Center = 0,
  19769. Perpendicular = 1,
  19770. }
  19771. /***** Data interfaces *****/
  19772. interface PhysicsForceAndContactPoint {
  19773. force: Vector3;
  19774. contactPoint: Vector3;
  19775. }
  19776. interface PhysicsRadialExplosionEventData {
  19777. sphere: Mesh;
  19778. rays: Array<Ray>;
  19779. }
  19780. interface PhysicsGravitationalFieldEventData {
  19781. sphere: Mesh;
  19782. }
  19783. interface PhysicsUpdraftEventData {
  19784. cylinder: Mesh;
  19785. }
  19786. interface PhysicsVortexEventData {
  19787. cylinder: Mesh;
  19788. }
  19789. }
  19790. declare module BABYLON {
  19791. interface PhysicsImpostorParameters {
  19792. mass: number;
  19793. friction?: number;
  19794. restitution?: number;
  19795. nativeOptions?: any;
  19796. ignoreParent?: boolean;
  19797. disableBidirectionalTransformation?: boolean;
  19798. }
  19799. interface IPhysicsEnabledObject {
  19800. position: Vector3;
  19801. rotationQuaternion: Nullable<Quaternion>;
  19802. scaling: Vector3;
  19803. rotation?: Vector3;
  19804. parent?: any;
  19805. getBoundingInfo(): BoundingInfo;
  19806. computeWorldMatrix(force: boolean): Matrix;
  19807. getWorldMatrix?(): Matrix;
  19808. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  19809. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  19810. getIndices?(): Nullable<IndicesArray>;
  19811. getScene?(): Scene;
  19812. getAbsolutePosition(): Vector3;
  19813. getAbsolutePivotPoint(): Vector3;
  19814. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  19815. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  19816. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  19817. getClassName(): string;
  19818. }
  19819. class PhysicsImpostor {
  19820. object: IPhysicsEnabledObject;
  19821. type: number;
  19822. private _options;
  19823. private _scene;
  19824. static DEFAULT_OBJECT_SIZE: Vector3;
  19825. static IDENTITY_QUATERNION: Quaternion;
  19826. private _physicsEngine;
  19827. private _physicsBody;
  19828. private _bodyUpdateRequired;
  19829. private _onBeforePhysicsStepCallbacks;
  19830. private _onAfterPhysicsStepCallbacks;
  19831. private _onPhysicsCollideCallbacks;
  19832. private _deltaPosition;
  19833. private _deltaRotation;
  19834. private _deltaRotationConjugated;
  19835. private _parent;
  19836. private _isDisposed;
  19837. private static _tmpVecs;
  19838. private static _tmpQuat;
  19839. readonly isDisposed: boolean;
  19840. mass: number;
  19841. friction: number;
  19842. restitution: number;
  19843. uniqueId: number;
  19844. private _joints;
  19845. constructor(object: IPhysicsEnabledObject, type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  19846. /**
  19847. * This function will completly initialize this impostor.
  19848. * It will create a new body - but only if this mesh has no parent.
  19849. * If it has, this impostor will not be used other than to define the impostor
  19850. * of the child mesh.
  19851. */
  19852. _init(): void;
  19853. private _getPhysicsParent();
  19854. /**
  19855. * Should a new body be generated.
  19856. */
  19857. isBodyInitRequired(): boolean;
  19858. setScalingUpdated(updated: boolean): void;
  19859. /**
  19860. * Force a regeneration of this or the parent's impostor's body.
  19861. * Use under cautious - This will remove all joints already implemented.
  19862. */
  19863. forceUpdate(): void;
  19864. /**
  19865. * Gets the body that holds this impostor. Either its own, or its parent.
  19866. */
  19867. /**
  19868. * Set the physics body. Used mainly by the physics engine/plugin
  19869. */
  19870. physicsBody: any;
  19871. parent: Nullable<PhysicsImpostor>;
  19872. resetUpdateFlags(): void;
  19873. getObjectExtendSize(): Vector3;
  19874. getObjectCenter(): Vector3;
  19875. /**
  19876. * Get a specific parametes from the options parameter.
  19877. */
  19878. getParam(paramName: string): any;
  19879. /**
  19880. * Sets a specific parameter in the options given to the physics plugin
  19881. */
  19882. setParam(paramName: string, value: number): void;
  19883. /**
  19884. * Specifically change the body's mass option. Won't recreate the physics body object
  19885. */
  19886. setMass(mass: number): void;
  19887. getLinearVelocity(): Nullable<Vector3>;
  19888. setLinearVelocity(velocity: Nullable<Vector3>): void;
  19889. getAngularVelocity(): Nullable<Vector3>;
  19890. setAngularVelocity(velocity: Nullable<Vector3>): void;
  19891. /**
  19892. * Execute a function with the physics plugin native code.
  19893. * Provide a function the will have two variables - the world object and the physics body object.
  19894. */
  19895. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  19896. /**
  19897. * Register a function that will be executed before the physics world is stepping forward.
  19898. */
  19899. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  19900. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  19901. /**
  19902. * Register a function that will be executed after the physics step
  19903. */
  19904. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  19905. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  19906. /**
  19907. * register a function that will be executed when this impostor collides against a different body.
  19908. */
  19909. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  19910. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  19911. private _tmpQuat;
  19912. private _tmpQuat2;
  19913. getParentsRotation(): Quaternion;
  19914. /**
  19915. * this function is executed by the physics engine.
  19916. */
  19917. beforeStep: () => void;
  19918. /**
  19919. * this function is executed by the physics engine.
  19920. */
  19921. afterStep: () => void;
  19922. /**
  19923. * Legacy collision detection event support
  19924. */
  19925. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  19926. onCollide: (e: {
  19927. body: any;
  19928. }) => void;
  19929. /**
  19930. * Apply a force
  19931. */
  19932. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  19933. /**
  19934. * Apply an impulse
  19935. */
  19936. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  19937. /**
  19938. * A help function to create a joint.
  19939. */
  19940. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  19941. /**
  19942. * Add a joint to this impostor with a different impostor.
  19943. */
  19944. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  19945. /**
  19946. * Will keep this body still, in a sleep mode.
  19947. */
  19948. sleep(): PhysicsImpostor;
  19949. /**
  19950. * Wake the body up.
  19951. */
  19952. wakeUp(): PhysicsImpostor;
  19953. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  19954. dispose(): void;
  19955. setDeltaPosition(position: Vector3): void;
  19956. setDeltaRotation(rotation: Quaternion): void;
  19957. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  19958. getRadius(): number;
  19959. /**
  19960. * Sync a bone with this impostor
  19961. * @param bone The bone to sync to the impostor.
  19962. * @param boneMesh The mesh that the bone is influencing.
  19963. * @param jointPivot The pivot of the joint / bone in local space.
  19964. * @param distToJoint Optional distance from the impostor to the joint.
  19965. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  19966. */
  19967. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  19968. /**
  19969. * Sync impostor to a bone
  19970. * @param bone The bone that the impostor will be synced to.
  19971. * @param boneMesh The mesh that the bone is influencing.
  19972. * @param jointPivot The pivot of the joint / bone in local space.
  19973. * @param distToJoint Optional distance from the impostor to the joint.
  19974. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  19975. * @param boneAxis Optional vector3 axis the bone is aligned with
  19976. */
  19977. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  19978. static NoImpostor: number;
  19979. static SphereImpostor: number;
  19980. static BoxImpostor: number;
  19981. static PlaneImpostor: number;
  19982. static MeshImpostor: number;
  19983. static CylinderImpostor: number;
  19984. static ParticleImpostor: number;
  19985. static HeightmapImpostor: number;
  19986. }
  19987. }
  19988. declare module BABYLON {
  19989. interface PhysicsJointData {
  19990. mainPivot?: Vector3;
  19991. connectedPivot?: Vector3;
  19992. mainAxis?: Vector3;
  19993. connectedAxis?: Vector3;
  19994. collision?: boolean;
  19995. nativeParams?: any;
  19996. }
  19997. /**
  19998. * This is a holder class for the physics joint created by the physics plugin.
  19999. * It holds a set of functions to control the underlying joint.
  20000. */
  20001. class PhysicsJoint {
  20002. type: number;
  20003. jointData: PhysicsJointData;
  20004. private _physicsJoint;
  20005. protected _physicsPlugin: IPhysicsEnginePlugin;
  20006. constructor(type: number, jointData: PhysicsJointData);
  20007. physicsJoint: any;
  20008. physicsPlugin: IPhysicsEnginePlugin;
  20009. /**
  20010. * Execute a function that is physics-plugin specific.
  20011. * @param {Function} func the function that will be executed.
  20012. * It accepts two parameters: the physics world and the physics joint.
  20013. */
  20014. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  20015. static DistanceJoint: number;
  20016. static HingeJoint: number;
  20017. static BallAndSocketJoint: number;
  20018. static WheelJoint: number;
  20019. static SliderJoint: number;
  20020. static PrismaticJoint: number;
  20021. static UniversalJoint: number;
  20022. static Hinge2Joint: number;
  20023. static PointToPointJoint: number;
  20024. static SpringJoint: number;
  20025. static LockJoint: number;
  20026. }
  20027. /**
  20028. * A class representing a physics distance joint.
  20029. */
  20030. class DistanceJoint extends PhysicsJoint {
  20031. constructor(jointData: DistanceJointData);
  20032. /**
  20033. * Update the predefined distance.
  20034. */
  20035. updateDistance(maxDistance: number, minDistance?: number): void;
  20036. }
  20037. class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  20038. constructor(type: number, jointData: PhysicsJointData);
  20039. /**
  20040. * Set the motor values.
  20041. * Attention, this function is plugin specific. Engines won't react 100% the same.
  20042. * @param {number} force the force to apply
  20043. * @param {number} maxForce max force for this motor.
  20044. */
  20045. setMotor(force?: number, maxForce?: number): void;
  20046. /**
  20047. * Set the motor's limits.
  20048. * Attention, this function is plugin specific. Engines won't react 100% the same.
  20049. */
  20050. setLimit(upperLimit: number, lowerLimit?: number): void;
  20051. }
  20052. /**
  20053. * This class represents a single hinge physics joint
  20054. */
  20055. class HingeJoint extends MotorEnabledJoint {
  20056. constructor(jointData: PhysicsJointData);
  20057. /**
  20058. * Set the motor values.
  20059. * Attention, this function is plugin specific. Engines won't react 100% the same.
  20060. * @param {number} force the force to apply
  20061. * @param {number} maxForce max force for this motor.
  20062. */
  20063. setMotor(force?: number, maxForce?: number): void;
  20064. /**
  20065. * Set the motor's limits.
  20066. * Attention, this function is plugin specific. Engines won't react 100% the same.
  20067. */
  20068. setLimit(upperLimit: number, lowerLimit?: number): void;
  20069. }
  20070. /**
  20071. * This class represents a dual hinge physics joint (same as wheel joint)
  20072. */
  20073. class Hinge2Joint extends MotorEnabledJoint {
  20074. constructor(jointData: PhysicsJointData);
  20075. /**
  20076. * Set the motor values.
  20077. * Attention, this function is plugin specific. Engines won't react 100% the same.
  20078. * @param {number} force the force to apply
  20079. * @param {number} maxForce max force for this motor.
  20080. * @param {motorIndex} the motor's index, 0 or 1.
  20081. */
  20082. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  20083. /**
  20084. * Set the motor limits.
  20085. * Attention, this function is plugin specific. Engines won't react 100% the same.
  20086. * @param {number} upperLimit the upper limit
  20087. * @param {number} lowerLimit lower limit
  20088. * @param {motorIndex} the motor's index, 0 or 1.
  20089. */
  20090. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  20091. }
  20092. interface IMotorEnabledJoint {
  20093. physicsJoint: any;
  20094. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  20095. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  20096. }
  20097. interface DistanceJointData extends PhysicsJointData {
  20098. maxDistance: number;
  20099. }
  20100. interface SpringJointData extends PhysicsJointData {
  20101. length: number;
  20102. stiffness: number;
  20103. damping: number;
  20104. }
  20105. }
  20106. declare module BABYLON {
  20107. class ReflectionProbe {
  20108. name: string;
  20109. private _scene;
  20110. private _renderTargetTexture;
  20111. private _projectionMatrix;
  20112. private _viewMatrix;
  20113. private _target;
  20114. private _add;
  20115. private _attachedMesh;
  20116. private _invertYAxis;
  20117. position: Vector3;
  20118. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  20119. samples: number;
  20120. refreshRate: number;
  20121. getScene(): Scene;
  20122. readonly cubeTexture: RenderTargetTexture;
  20123. readonly renderList: Nullable<AbstractMesh[]>;
  20124. attachToMesh(mesh: AbstractMesh): void;
  20125. /**
  20126. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  20127. *
  20128. * @param renderingGroupId The rendering group id corresponding to its index
  20129. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  20130. */
  20131. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  20132. dispose(): void;
  20133. }
  20134. }
  20135. declare module BABYLON {
  20136. class BoundingBoxRenderer {
  20137. frontColor: Color3;
  20138. backColor: Color3;
  20139. showBackLines: boolean;
  20140. renderList: SmartArray<BoundingBox>;
  20141. private _scene;
  20142. private _colorShader;
  20143. private _vertexBuffers;
  20144. private _indexBuffer;
  20145. constructor(scene: Scene);
  20146. private _prepareRessources();
  20147. private _createIndexBuffer();
  20148. _rebuild(): void;
  20149. reset(): void;
  20150. render(): void;
  20151. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  20152. dispose(): void;
  20153. }
  20154. }
  20155. declare module BABYLON {
  20156. /**
  20157. * This represents a depth renderer in Babylon.
  20158. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  20159. */
  20160. class DepthRenderer {
  20161. private _scene;
  20162. private _depthMap;
  20163. private _effect;
  20164. private _cachedDefines;
  20165. private _camera;
  20166. /**
  20167. * Instantiates a depth renderer
  20168. * @param scene The scene the renderer belongs to
  20169. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  20170. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  20171. */
  20172. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  20173. /**
  20174. * Creates the depth rendering effect and checks if the effect is ready.
  20175. * @param subMesh The submesh to be used to render the depth map of
  20176. * @param useInstances If multiple world instances should be used
  20177. * @returns if the depth renderer is ready to render the depth map
  20178. */
  20179. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  20180. /**
  20181. * Gets the texture which the depth map will be written to.
  20182. * @returns The depth map texture
  20183. */
  20184. getDepthMap(): RenderTargetTexture;
  20185. /**
  20186. * Disposes of the depth renderer.
  20187. */
  20188. dispose(): void;
  20189. }
  20190. }
  20191. declare module BABYLON {
  20192. class EdgesRenderer {
  20193. edgesWidthScalerForOrthographic: number;
  20194. edgesWidthScalerForPerspective: number;
  20195. private _source;
  20196. private _linesPositions;
  20197. private _linesNormals;
  20198. private _linesIndices;
  20199. private _epsilon;
  20200. private _indicesCount;
  20201. private _lineShader;
  20202. private _ib;
  20203. private _buffers;
  20204. private _checkVerticesInsteadOfIndices;
  20205. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  20206. private _prepareRessources();
  20207. _rebuild(): void;
  20208. dispose(): void;
  20209. private _processEdgeForAdjacencies(pa, pb, p0, p1, p2);
  20210. private _processEdgeForAdjacenciesWithVertices(pa, pb, p0, p1, p2);
  20211. private _checkEdge(faceIndex, edge, faceNormals, p0, p1);
  20212. _generateEdgesLines(): void;
  20213. render(): void;
  20214. }
  20215. }
  20216. declare module BABYLON {
  20217. /**
  20218. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  20219. */
  20220. class GeometryBufferRenderer {
  20221. private _scene;
  20222. private _multiRenderTarget;
  20223. private _ratio;
  20224. private _enablePosition;
  20225. protected _effect: Effect;
  20226. protected _cachedDefines: string;
  20227. /**
  20228. * Set the render list (meshes to be rendered) used in the G buffer.
  20229. */
  20230. renderList: Mesh[];
  20231. /**
  20232. * Gets wether or not G buffer are supported by the running hardware.
  20233. * This requires draw buffer supports
  20234. */
  20235. readonly isSupported: boolean;
  20236. /**
  20237. * Gets wether or not position are enabled for the G buffer.
  20238. */
  20239. /**
  20240. * Sets wether or not position are enabled for the G buffer.
  20241. */
  20242. enablePosition: boolean;
  20243. /**
  20244. * Gets the scene associated with the buffer.
  20245. */
  20246. readonly scene: Scene;
  20247. /**
  20248. * Gets the ratio used by the buffer during its creation.
  20249. * How big is the buffer related to the main canvas.
  20250. */
  20251. readonly ratio: number;
  20252. /**
  20253. * Creates a new G Buffer for the scene
  20254. * @param scene The scene the buffer belongs to
  20255. * @param ratio How big is the buffer related to the main canvas.
  20256. */
  20257. constructor(scene: Scene, ratio?: number);
  20258. /**
  20259. * Checks wether everything is ready to render a submesh to the G buffer.
  20260. * @param subMesh the submesh to check readiness for
  20261. * @param useInstances is the mesh drawn using instance or not
  20262. * @returns true if ready otherwise false
  20263. */
  20264. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  20265. /**
  20266. * Gets the current underlying G Buffer.
  20267. * @returns the buffer
  20268. */
  20269. getGBuffer(): MultiRenderTarget;
  20270. /**
  20271. * Gets the number of samples used to render the buffer (anti aliasing).
  20272. */
  20273. /**
  20274. * Sets the number of samples used to render the buffer (anti aliasing).
  20275. */
  20276. samples: number;
  20277. /**
  20278. * Disposes the renderer and frees up associated resources.
  20279. */
  20280. dispose(): void;
  20281. protected _createRenderTargets(): void;
  20282. }
  20283. }
  20284. declare module BABYLON {
  20285. class OutlineRenderer {
  20286. private _scene;
  20287. private _effect;
  20288. private _cachedDefines;
  20289. zOffset: number;
  20290. constructor(scene: Scene);
  20291. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  20292. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  20293. }
  20294. }
  20295. declare module BABYLON {
  20296. class RenderingGroup {
  20297. index: number;
  20298. private _scene;
  20299. private _opaqueSubMeshes;
  20300. private _transparentSubMeshes;
  20301. private _alphaTestSubMeshes;
  20302. private _depthOnlySubMeshes;
  20303. private _particleSystems;
  20304. private _spriteManagers;
  20305. private _opaqueSortCompareFn;
  20306. private _alphaTestSortCompareFn;
  20307. private _transparentSortCompareFn;
  20308. private _renderOpaque;
  20309. private _renderAlphaTest;
  20310. private _renderTransparent;
  20311. private _edgesRenderers;
  20312. onBeforeTransparentRendering: () => void;
  20313. /**
  20314. * Set the opaque sort comparison function.
  20315. * If null the sub meshes will be render in the order they were created
  20316. */
  20317. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  20318. /**
  20319. * Set the alpha test sort comparison function.
  20320. * If null the sub meshes will be render in the order they were created
  20321. */
  20322. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  20323. /**
  20324. * Set the transparent sort comparison function.
  20325. * If null the sub meshes will be render in the order they were created
  20326. */
  20327. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  20328. /**
  20329. * Creates a new rendering group.
  20330. * @param index The rendering group index
  20331. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  20332. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  20333. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  20334. */
  20335. 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>);
  20336. /**
  20337. * Render all the sub meshes contained in the group.
  20338. * @param customRenderFunction Used to override the default render behaviour of the group.
  20339. * @returns true if rendered some submeshes.
  20340. */
  20341. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  20342. /**
  20343. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  20344. * @param subMeshes The submeshes to render
  20345. */
  20346. private renderOpaqueSorted(subMeshes);
  20347. /**
  20348. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  20349. * @param subMeshes The submeshes to render
  20350. */
  20351. private renderAlphaTestSorted(subMeshes);
  20352. /**
  20353. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  20354. * @param subMeshes The submeshes to render
  20355. */
  20356. private renderTransparentSorted(subMeshes);
  20357. /**
  20358. * Renders the submeshes in a specified order.
  20359. * @param subMeshes The submeshes to sort before render
  20360. * @param sortCompareFn The comparison function use to sort
  20361. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  20362. * @param transparent Specifies to activate blending if true
  20363. */
  20364. private static renderSorted(subMeshes, sortCompareFn, camera, transparent);
  20365. /**
  20366. * Renders the submeshes in the order they were dispatched (no sort applied).
  20367. * @param subMeshes The submeshes to render
  20368. */
  20369. private static renderUnsorted(subMeshes);
  20370. /**
  20371. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  20372. * are rendered back to front if in the same alpha index.
  20373. *
  20374. * @param a The first submesh
  20375. * @param b The second submesh
  20376. * @returns The result of the comparison
  20377. */
  20378. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  20379. /**
  20380. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  20381. * are rendered back to front.
  20382. *
  20383. * @param a The first submesh
  20384. * @param b The second submesh
  20385. * @returns The result of the comparison
  20386. */
  20387. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  20388. /**
  20389. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  20390. * are rendered front to back (prevent overdraw).
  20391. *
  20392. * @param a The first submesh
  20393. * @param b The second submesh
  20394. * @returns The result of the comparison
  20395. */
  20396. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  20397. /**
  20398. * Resets the different lists of submeshes to prepare a new frame.
  20399. */
  20400. prepare(): void;
  20401. dispose(): void;
  20402. /**
  20403. * Inserts the submesh in its correct queue depending on its material.
  20404. * @param subMesh The submesh to dispatch
  20405. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  20406. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  20407. */
  20408. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  20409. dispatchSprites(spriteManager: SpriteManager): void;
  20410. dispatchParticles(particleSystem: IParticleSystem): void;
  20411. private _renderParticles(activeMeshes);
  20412. private _renderSprites();
  20413. }
  20414. }
  20415. declare module BABYLON {
  20416. class RenderingManager {
  20417. /**
  20418. * The max id used for rendering groups (not included)
  20419. */
  20420. static MAX_RENDERINGGROUPS: number;
  20421. /**
  20422. * The min id used for rendering groups (included)
  20423. */
  20424. static MIN_RENDERINGGROUPS: number;
  20425. /**
  20426. * Used to globally prevent autoclearing scenes.
  20427. */
  20428. static AUTOCLEAR: boolean;
  20429. private _scene;
  20430. private _renderingGroups;
  20431. private _depthStencilBufferAlreadyCleaned;
  20432. private _autoClearDepthStencil;
  20433. private _customOpaqueSortCompareFn;
  20434. private _customAlphaTestSortCompareFn;
  20435. private _customTransparentSortCompareFn;
  20436. private _renderinGroupInfo;
  20437. constructor(scene: Scene);
  20438. private _clearDepthStencilBuffer(depth?, stencil?);
  20439. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  20440. reset(): void;
  20441. dispose(): void;
  20442. /**
  20443. * Clear the info related to rendering groups preventing retention points during dispose.
  20444. */
  20445. freeRenderingGroups(): void;
  20446. private _prepareRenderingGroup(renderingGroupId);
  20447. dispatchSprites(spriteManager: SpriteManager): void;
  20448. dispatchParticles(particleSystem: IParticleSystem): void;
  20449. /**
  20450. * @param subMesh The submesh to dispatch
  20451. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  20452. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  20453. */
  20454. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  20455. /**
  20456. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  20457. * This allowed control for front to back rendering or reversly depending of the special needs.
  20458. *
  20459. * @param renderingGroupId The rendering group id corresponding to its index
  20460. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  20461. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  20462. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  20463. */
  20464. 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;
  20465. /**
  20466. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  20467. *
  20468. * @param renderingGroupId The rendering group id corresponding to its index
  20469. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  20470. * @param depth Automatically clears depth between groups if true and autoClear is true.
  20471. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  20472. */
  20473. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  20474. }
  20475. }
  20476. declare module BABYLON {
  20477. class Sprite {
  20478. name: string;
  20479. position: Vector3;
  20480. color: Color4;
  20481. width: number;
  20482. height: number;
  20483. angle: number;
  20484. cellIndex: number;
  20485. invertU: number;
  20486. invertV: number;
  20487. disposeWhenFinishedAnimating: boolean;
  20488. animations: Animation[];
  20489. isPickable: boolean;
  20490. actionManager: ActionManager;
  20491. private _animationStarted;
  20492. private _loopAnimation;
  20493. private _fromIndex;
  20494. private _toIndex;
  20495. private _delay;
  20496. private _direction;
  20497. private _manager;
  20498. private _time;
  20499. private _onAnimationEnd;
  20500. size: number;
  20501. constructor(name: string, manager: SpriteManager);
  20502. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  20503. stopAnimation(): void;
  20504. _animate(deltaTime: number): void;
  20505. dispose(): void;
  20506. }
  20507. }
  20508. declare module BABYLON {
  20509. class SpriteManager {
  20510. name: string;
  20511. sprites: Sprite[];
  20512. renderingGroupId: number;
  20513. layerMask: number;
  20514. fogEnabled: boolean;
  20515. isPickable: boolean;
  20516. cellWidth: number;
  20517. cellHeight: number;
  20518. /**
  20519. * An event triggered when the manager is disposed.
  20520. */
  20521. onDisposeObservable: Observable<SpriteManager>;
  20522. private _onDisposeObserver;
  20523. onDispose: () => void;
  20524. private _capacity;
  20525. private _spriteTexture;
  20526. private _epsilon;
  20527. private _scene;
  20528. private _vertexData;
  20529. private _buffer;
  20530. private _vertexBuffers;
  20531. private _indexBuffer;
  20532. private _effectBase;
  20533. private _effectFog;
  20534. texture: Texture;
  20535. constructor(name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  20536. private _appendSpriteVertex(index, sprite, offsetX, offsetY, rowSize);
  20537. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  20538. render(): void;
  20539. dispose(): void;
  20540. }
  20541. }
  20542. declare module BABYLON {
  20543. class AnaglyphPostProcess extends PostProcess {
  20544. private _passedProcess;
  20545. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  20546. }
  20547. }
  20548. declare module BABYLON {
  20549. class BlackAndWhitePostProcess extends PostProcess {
  20550. degree: number;
  20551. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  20552. }
  20553. }
  20554. declare module BABYLON {
  20555. /**
  20556. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  20557. */
  20558. class BloomEffect extends PostProcessRenderEffect {
  20559. private bloomScale;
  20560. /**
  20561. * Internal
  20562. */
  20563. _effects: Array<PostProcess>;
  20564. /**
  20565. * Internal
  20566. */
  20567. _downscale: ExtractHighlightsPostProcess;
  20568. private _blurX;
  20569. private _blurY;
  20570. private _merge;
  20571. /**
  20572. * The luminance threshold to find bright areas of the image to bloom.
  20573. */
  20574. threshold: number;
  20575. /**
  20576. * The strength of the bloom.
  20577. */
  20578. weight: number;
  20579. /**
  20580. * Specifies the size of the bloom blur kernel, relative to the final output size
  20581. */
  20582. kernel: number;
  20583. /**
  20584. * Creates a new instance of @see BloomEffect
  20585. * @param scene The scene the effect belongs to.
  20586. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  20587. * @param bloomKernel The size of the kernel to be used when applying the blur.
  20588. * @param bloomWeight The the strength of bloom.
  20589. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  20590. * @param blockCompilation If compilation of the shader should not be done in the constructor. The updateEffect method can be used to compile the shader at a later time. (default: false)
  20591. */
  20592. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  20593. /**
  20594. * Disposes each of the internal effects for a given camera.
  20595. * @param camera The camera to dispose the effect on.
  20596. */
  20597. disposeEffects(camera: Camera): void;
  20598. /**
  20599. * Internal
  20600. */
  20601. _updateEffects(): void;
  20602. /**
  20603. * Internal
  20604. * @returns if all the contained post processes are ready.
  20605. */
  20606. _isReady(): boolean;
  20607. }
  20608. }
  20609. declare module BABYLON {
  20610. /**
  20611. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  20612. */
  20613. class BloomMergePostProcess extends PostProcess {
  20614. /** Weight of the bloom to be added to the original input. */ weight: number;
  20615. /**
  20616. * Creates a new instance of @see BloomMergePostProcess
  20617. * @param name The name of the effect.
  20618. * @param originalFromInput Post process which's input will be used for the merge.
  20619. * @param blurred Blurred highlights post process which's output will be used.
  20620. * @param weight Weight of the bloom to be added to the original input.
  20621. * @param options The required width/height ratio to downsize to before computing the render pass.
  20622. * @param camera The camera to apply the render pass to.
  20623. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  20624. * @param engine The engine which the post process will be applied. (default: current engine)
  20625. * @param reusable If the post process can be reused on the same frame. (default: false)
  20626. * @param textureType Type of textures used when performing the post process. (default: 0)
  20627. * @param blockCompilation If compilation of the shader should not be done in the constructor. The updateEffect method can be used to compile the shader at a later time. (default: false)
  20628. */
  20629. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess, /** Weight of the bloom to be added to the original input. */ weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  20630. }
  20631. }
  20632. declare module BABYLON {
  20633. /**
  20634. * The Blur Post Process which blurs an image based on a kernel and direction.
  20635. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  20636. */
  20637. class BlurPostProcess extends PostProcess {
  20638. /** The direction in which to blur the image. */ direction: Vector2;
  20639. private blockCompilation;
  20640. protected _kernel: number;
  20641. protected _idealKernel: number;
  20642. protected _packedFloat: boolean;
  20643. private _staticDefines;
  20644. /**
  20645. * Gets the length in pixels of the blur sample region
  20646. */
  20647. /**
  20648. * Sets the length in pixels of the blur sample region
  20649. */
  20650. kernel: number;
  20651. /**
  20652. * Gets wether or not the blur is unpacking/repacking floats
  20653. */
  20654. /**
  20655. * Sets wether or not the blur needs to unpack/repack floats
  20656. */
  20657. packedFloat: boolean;
  20658. /**
  20659. * Creates a new instance BlurPostProcess
  20660. * @param name The name of the effect.
  20661. * @param direction The direction in which to blur the image.
  20662. * @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.
  20663. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  20664. * @param camera The camera to apply the render pass to.
  20665. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  20666. * @param engine The engine which the post process will be applied. (default: current engine)
  20667. * @param reusable If the post process can be reused on the same frame. (default: false)
  20668. * @param textureType Type of textures used when performing the post process. (default: 0)
  20669. * @param blockCompilation If compilation of the shader should not be done in the constructor. The updateEffect method can be used to compile the shader at a later time. (default: false)
  20670. */
  20671. constructor(name: string, /** The direction in which to blur the image. */ direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  20672. /**
  20673. * Updates the effect with the current post process compile time values and recompiles the shader.
  20674. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  20675. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  20676. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  20677. * @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
  20678. * @param onCompiled Called when the shader has been compiled.
  20679. * @param onError Called if there is an error when compiling a shader.
  20680. */
  20681. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  20682. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  20683. /**
  20684. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  20685. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  20686. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  20687. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  20688. * The gaps between physical kernels are compensated for in the weighting of the samples
  20689. * @param idealKernel Ideal blur kernel.
  20690. * @return Nearest best kernel.
  20691. */
  20692. protected _nearestBestKernel(idealKernel: number): number;
  20693. /**
  20694. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  20695. * @param x The point on the Gaussian distribution to sample.
  20696. * @return the value of the Gaussian function at x.
  20697. */
  20698. protected _gaussianWeight(x: number): number;
  20699. /**
  20700. * Generates a string that can be used as a floating point number in GLSL.
  20701. * @param x Value to print.
  20702. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  20703. * @return GLSL float string.
  20704. */
  20705. protected _glslFloat(x: number, decimalFigures?: number): string;
  20706. }
  20707. }
  20708. declare module BABYLON {
  20709. /**
  20710. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  20711. */
  20712. class ChromaticAberrationPostProcess extends PostProcess {
  20713. /**
  20714. * The amount of seperation of rgb channels (default: 30)
  20715. */
  20716. aberrationAmount: number;
  20717. /**
  20718. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  20719. */
  20720. radialIntensity: number;
  20721. /**
  20722. * The normilized direction in which the rgb channels should be seperated. If set to 0,0 radial direction will be used. (default: Vector2(0.707,0.707))
  20723. */
  20724. direction: Vector2;
  20725. /**
  20726. * The center position where the radialIntensity should be around. [0.5,0.5 is center of screen, 1,1 is top right corder] (default: Vector2(0.5 ,0.5))
  20727. */
  20728. centerPosition: Vector2;
  20729. /**
  20730. * Creates a new instance ChromaticAberrationPostProcess
  20731. * @param name The name of the effect.
  20732. * @param screenWidth The width of the screen to apply the effect on.
  20733. * @param screenHeight The height of the screen to apply the effect on.
  20734. * @param options The required width/height ratio to downsize to before computing the render pass.
  20735. * @param camera The camera to apply the render pass to.
  20736. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  20737. * @param engine The engine which the post process will be applied. (default: current engine)
  20738. * @param reusable If the post process can be reused on the same frame. (default: false)
  20739. * @param textureType Type of textures used when performing the post process. (default: 0)
  20740. * @param blockCompilation If compilation of the shader should not be done in the constructor. The updateEffect method can be used to compile the shader at a later time. (default: false)
  20741. */
  20742. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  20743. }
  20744. }
  20745. declare module BABYLON {
  20746. /**
  20747. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  20748. */
  20749. class CircleOfConfusionPostProcess extends PostProcess {
  20750. /**
  20751. * 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.
  20752. */
  20753. lensSize: number;
  20754. /**
  20755. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  20756. */
  20757. fStop: number;
  20758. /**
  20759. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  20760. */
  20761. focusDistance: number;
  20762. /**
  20763. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  20764. */
  20765. focalLength: number;
  20766. private _depthTexture;
  20767. /**
  20768. * Creates a new instance CircleOfConfusionPostProcess
  20769. * @param name The name of the effect.
  20770. * @param depthTexture The depth texture of the scene to compute the circle of confusion. This must be set in order for this to function but may be set after initialization if needed.
  20771. * @param options The required width/height ratio to downsize to before computing the render pass.
  20772. * @param camera The camera to apply the render pass to.
  20773. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  20774. * @param engine The engine which the post process will be applied. (default: current engine)
  20775. * @param reusable If the post process can be reused on the same frame. (default: false)
  20776. * @param textureType Type of textures used when performing the post process. (default: 0)
  20777. * @param blockCompilation If compilation of the shader should not be done in the constructor. The updateEffect method can be used to compile the shader at a later time. (default: false)
  20778. */
  20779. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  20780. /**
  20781. * Depth texture to be used to compute the circle of confusion. This must be set here or in the constructor in order for the post process to function.
  20782. */
  20783. depthTexture: RenderTargetTexture;
  20784. }
  20785. }
  20786. declare module BABYLON {
  20787. class ColorCorrectionPostProcess extends PostProcess {
  20788. private _colorTableTexture;
  20789. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  20790. }
  20791. }
  20792. declare module BABYLON {
  20793. /**
  20794. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  20795. * input texture to perform effects such as edge detection or sharpening
  20796. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  20797. */
  20798. class ConvolutionPostProcess extends PostProcess {
  20799. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */ kernel: number[];
  20800. /**
  20801. * Creates a new instance ConvolutionPostProcess
  20802. * @param name The name of the effect.
  20803. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  20804. * @param options The required width/height ratio to downsize to before computing the render pass.
  20805. * @param camera The camera to apply the render pass to.
  20806. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  20807. * @param engine The engine which the post process will be applied. (default: current engine)
  20808. * @param reusable If the post process can be reused on the same frame. (default: false)
  20809. * @param textureType Type of textures used when performing the post process. (default: 0)
  20810. */
  20811. constructor(name: string, /** Array of 9 values corrisponding to the 3x3 kernel to be applied */ kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  20812. /**
  20813. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  20814. */
  20815. static EdgeDetect0Kernel: number[];
  20816. /**
  20817. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  20818. */
  20819. static EdgeDetect1Kernel: number[];
  20820. /**
  20821. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  20822. */
  20823. static EdgeDetect2Kernel: number[];
  20824. /**
  20825. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  20826. */
  20827. static SharpenKernel: number[];
  20828. /**
  20829. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  20830. */
  20831. static EmbossKernel: number[];
  20832. /**
  20833. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  20834. */
  20835. static GaussianKernel: number[];
  20836. }
  20837. }
  20838. declare module BABYLON {
  20839. /**
  20840. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  20841. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  20842. * based on samples that have a large difference in distance than the center pixel.
  20843. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  20844. */
  20845. class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  20846. direction: Vector2;
  20847. /**
  20848. * Creates a new instance CircleOfConfusionPostProcess
  20849. * @param name The name of the effect.
  20850. * @param scene The scene the effect belongs to.
  20851. * @param direction The direction the blur should be applied.
  20852. * @param kernel The size of the kernel used to blur.
  20853. * @param options The required width/height ratio to downsize to before computing the render pass.
  20854. * @param camera The camera to apply the render pass to.
  20855. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  20856. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  20857. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  20858. * @param engine The engine which the post process will be applied. (default: current engine)
  20859. * @param reusable If the post process can be reused on the same frame. (default: false)
  20860. * @param textureType Type of textures used when performing the post process. (default: 0)
  20861. * @param blockCompilation If compilation of the shader should not be done in the constructor. The updateEffect method can be used to compile the shader at a later time. (default: false)
  20862. */
  20863. constructor(name: string, scene: Scene, direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, circleOfConfusion: PostProcess, imageToBlur?: Nullable<PostProcess>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  20864. }
  20865. }
  20866. declare module BABYLON {
  20867. /**
  20868. * Specifies the level of max blur that should be applied when using the depth of field effect
  20869. */
  20870. enum DepthOfFieldEffectBlurLevel {
  20871. /**
  20872. * Subtle blur
  20873. */
  20874. Low = 0,
  20875. /**
  20876. * Medium blur
  20877. */
  20878. Medium = 1,
  20879. /**
  20880. * Large blur
  20881. */
  20882. High = 2,
  20883. }
  20884. /**
  20885. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  20886. */
  20887. class DepthOfFieldEffect extends PostProcessRenderEffect {
  20888. private _circleOfConfusion;
  20889. /**
  20890. * Internal, blurs from high to low
  20891. */
  20892. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  20893. private _depthOfFieldBlurY;
  20894. private _dofMerge;
  20895. /**
  20896. * Internal post processes in depth of field effect
  20897. */
  20898. _effects: Array<PostProcess>;
  20899. /**
  20900. * The focal the length of the camera used in the effect
  20901. */
  20902. focalLength: number;
  20903. /**
  20904. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  20905. */
  20906. fStop: number;
  20907. /**
  20908. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  20909. */
  20910. focusDistance: number;
  20911. /**
  20912. * 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.
  20913. */
  20914. lensSize: number;
  20915. /**
  20916. * Creates a new instance DepthOfFieldEffect
  20917. * @param scene The scene the effect belongs to.
  20918. * @param depthTexture The depth texture of the scene to compute the circle of confusion.This must be set in order for this to function but may be set after initialization if needed.
  20919. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  20920. * @param blockCompilation If compilation of the shader should not be done in the constructor. The updateEffect method can be used to compile the shader at a later time. (default: false)
  20921. */
  20922. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  20923. /**
  20924. * Depth texture to be used to compute the circle of confusion. This must be set here or in the constructor in order for the post process to function.
  20925. */
  20926. depthTexture: RenderTargetTexture;
  20927. /**
  20928. * Disposes each of the internal effects for a given camera.
  20929. * @param camera The camera to dispose the effect on.
  20930. */
  20931. disposeEffects(camera: Camera): void;
  20932. /**
  20933. * Internal
  20934. */
  20935. _updateEffects(): void;
  20936. /**
  20937. * Internal
  20938. * @returns if all the contained post processes are ready.
  20939. */
  20940. _isReady(): boolean;
  20941. }
  20942. }
  20943. declare module BABYLON {
  20944. /**
  20945. * Options to be set when merging outputs from the default pipeline.
  20946. */
  20947. class DepthOfFieldMergePostProcessOptions {
  20948. /**
  20949. * The original image to merge on top of
  20950. */
  20951. originalFromInput: PostProcess;
  20952. /**
  20953. * Parameters to perform the merge of the depth of field effect
  20954. */
  20955. depthOfField?: {
  20956. circleOfConfusion: PostProcess;
  20957. blurSteps: Array<PostProcess>;
  20958. };
  20959. /**
  20960. * Parameters to perform the merge of bloom effect
  20961. */
  20962. bloom?: {
  20963. blurred: PostProcess;
  20964. weight: number;
  20965. };
  20966. }
  20967. /**
  20968. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  20969. */
  20970. class DepthOfFieldMergePostProcess extends PostProcess {
  20971. private blurSteps;
  20972. /**
  20973. * Creates a new instance of DepthOfFieldMergePostProcess
  20974. * @param name The name of the effect.
  20975. * @param originalFromInput Post process which's input will be used for the merge.
  20976. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  20977. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  20978. * @param options The required width/height ratio to downsize to before computing the render pass.
  20979. * @param camera The camera to apply the render pass to.
  20980. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  20981. * @param engine The engine which the post process will be applied. (default: current engine)
  20982. * @param reusable If the post process can be reused on the same frame. (default: false)
  20983. * @param textureType Type of textures used when performing the post process. (default: 0)
  20984. * @param blockCompilation If compilation of the shader should not be done in the constructor. The updateEffect method can be used to compile the shader at a later time. (default: false)
  20985. */
  20986. constructor(name: string, originalFromInput: PostProcess, circleOfConfusion: PostProcess, blurSteps: Array<PostProcess>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  20987. /**
  20988. * Updates the effect with the current post process compile time values and recompiles the shader.
  20989. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  20990. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  20991. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  20992. * @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
  20993. * @param onCompiled Called when the shader has been compiled.
  20994. * @param onError Called if there is an error when compiling a shader.
  20995. */
  20996. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  20997. }
  20998. }
  20999. declare module BABYLON {
  21000. class DisplayPassPostProcess extends PostProcess {
  21001. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  21002. }
  21003. }
  21004. declare module BABYLON {
  21005. /**
  21006. * The extract highlights post process sets all pixels to black except pixels above the specified luminance threshold. Used as the first step for a bloom effect.
  21007. */
  21008. class ExtractHighlightsPostProcess extends PostProcess {
  21009. /**
  21010. * The luminance threshold, pixels below this value will be set to black.
  21011. */
  21012. threshold: number;
  21013. /**
  21014. * Internal
  21015. */
  21016. _exposure: number;
  21017. /**
  21018. * Post process which has the input texture to be used when performing highlight extraction
  21019. */
  21020. _inputPostProcess: Nullable<PostProcess>;
  21021. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  21022. }
  21023. }
  21024. declare module BABYLON {
  21025. class FilterPostProcess extends PostProcess {
  21026. kernelMatrix: Matrix;
  21027. constructor(name: string, kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  21028. }
  21029. }
  21030. declare module BABYLON {
  21031. class FxaaPostProcess extends PostProcess {
  21032. texelWidth: number;
  21033. texelHeight: number;
  21034. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  21035. }
  21036. }
  21037. declare module BABYLON {
  21038. /**
  21039. * The GrainPostProcess adds noise to the image at mid luminance levels
  21040. */
  21041. class GrainPostProcess extends PostProcess {
  21042. /**
  21043. * The intensity of the grain added (default: 30)
  21044. */
  21045. intensity: number;
  21046. /**
  21047. * If the grain should be randomized on every frame
  21048. */
  21049. animated: boolean;
  21050. /**
  21051. * Creates a new instance of @see GrainPostProcess
  21052. * @param name The name of the effect.
  21053. * @param options The required width/height ratio to downsize to before computing the render pass.
  21054. * @param camera The camera to apply the render pass to.
  21055. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  21056. * @param engine The engine which the post process will be applied. (default: current engine)
  21057. * @param reusable If the post process can be reused on the same frame. (default: false)
  21058. * @param textureType Type of textures used when performing the post process. (default: 0)
  21059. * @param blockCompilation If compilation of the shader should not be done in the constructor. The updateEffect method can be used to compile the shader at a later time. (default: false)
  21060. */
  21061. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  21062. }
  21063. }
  21064. declare module BABYLON {
  21065. class HighlightsPostProcess extends PostProcess {
  21066. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  21067. }
  21068. }
  21069. declare module BABYLON {
  21070. class ImageProcessingPostProcess extends PostProcess {
  21071. /**
  21072. * Default configuration related to image processing available in the PBR Material.
  21073. */
  21074. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  21075. /**
  21076. * Gets the image processing configuration used either in this material.
  21077. */
  21078. /**
  21079. * Sets the Default image processing configuration used either in the this material.
  21080. *
  21081. * If sets to null, the scene one is in use.
  21082. */
  21083. imageProcessingConfiguration: ImageProcessingConfiguration;
  21084. /**
  21085. * Keep track of the image processing observer to allow dispose and replace.
  21086. */
  21087. private _imageProcessingObserver;
  21088. /**
  21089. * Attaches a new image processing configuration to the PBR Material.
  21090. * @param configuration
  21091. */
  21092. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  21093. /**
  21094. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  21095. */
  21096. /**
  21097. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  21098. */
  21099. colorCurves: Nullable<ColorCurves>;
  21100. /**
  21101. * Gets wether the color curves effect is enabled.
  21102. */
  21103. /**
  21104. * Sets wether the color curves effect is enabled.
  21105. */
  21106. colorCurvesEnabled: boolean;
  21107. /**
  21108. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  21109. */
  21110. /**
  21111. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  21112. */
  21113. colorGradingTexture: Nullable<BaseTexture>;
  21114. /**
  21115. * Gets wether the color grading effect is enabled.
  21116. */
  21117. /**
  21118. * Gets wether the color grading effect is enabled.
  21119. */
  21120. colorGradingEnabled: boolean;
  21121. /**
  21122. * Gets exposure used in the effect.
  21123. */
  21124. /**
  21125. * Sets exposure used in the effect.
  21126. */
  21127. exposure: number;
  21128. /**
  21129. * Gets wether tonemapping is enabled or not.
  21130. */
  21131. /**
  21132. * Sets wether tonemapping is enabled or not
  21133. */
  21134. toneMappingEnabled: boolean;
  21135. /**
  21136. * Gets contrast used in the effect.
  21137. */
  21138. /**
  21139. * Sets contrast used in the effect.
  21140. */
  21141. contrast: number;
  21142. /**
  21143. * Gets Vignette stretch size.
  21144. */
  21145. /**
  21146. * Sets Vignette stretch size.
  21147. */
  21148. vignetteStretch: number;
  21149. /**
  21150. * Gets Vignette centre X Offset.
  21151. */
  21152. /**
  21153. * Sets Vignette centre X Offset.
  21154. */
  21155. vignetteCentreX: number;
  21156. /**
  21157. * Gets Vignette centre Y Offset.
  21158. */
  21159. /**
  21160. * Sets Vignette centre Y Offset.
  21161. */
  21162. vignetteCentreY: number;
  21163. /**
  21164. * Gets Vignette weight or intensity of the vignette effect.
  21165. */
  21166. /**
  21167. * Sets Vignette weight or intensity of the vignette effect.
  21168. */
  21169. vignetteWeight: number;
  21170. /**
  21171. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  21172. * if vignetteEnabled is set to true.
  21173. */
  21174. /**
  21175. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  21176. * if vignetteEnabled is set to true.
  21177. */
  21178. vignetteColor: Color4;
  21179. /**
  21180. * Gets Camera field of view used by the Vignette effect.
  21181. */
  21182. /**
  21183. * Sets Camera field of view used by the Vignette effect.
  21184. */
  21185. vignetteCameraFov: number;
  21186. /**
  21187. * Gets the vignette blend mode allowing different kind of effect.
  21188. */
  21189. /**
  21190. * Sets the vignette blend mode allowing different kind of effect.
  21191. */
  21192. vignetteBlendMode: number;
  21193. /**
  21194. * Gets wether the vignette effect is enabled.
  21195. */
  21196. /**
  21197. * Sets wether the vignette effect is enabled.
  21198. */
  21199. vignetteEnabled: boolean;
  21200. private _fromLinearSpace;
  21201. /**
  21202. * Gets wether the input of the processing is in Gamma or Linear Space.
  21203. */
  21204. /**
  21205. * Sets wether the input of the processing is in Gamma or Linear Space.
  21206. */
  21207. fromLinearSpace: boolean;
  21208. /**
  21209. * Defines cache preventing GC.
  21210. */
  21211. private _defines;
  21212. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  21213. getClassName(): string;
  21214. protected _updateParameters(): void;
  21215. dispose(camera?: Camera): void;
  21216. }
  21217. }
  21218. declare module BABYLON {
  21219. class PassPostProcess extends PostProcess {
  21220. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  21221. }
  21222. }
  21223. declare module BABYLON {
  21224. type PostProcessOptions = {
  21225. width: number;
  21226. height: number;
  21227. };
  21228. /**
  21229. * PostProcess can be used to apply a shader to a texture after it has been rendered
  21230. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  21231. */
  21232. class PostProcess {
  21233. /** Name of the PostProcess. */ name: string;
  21234. /**
  21235. * Width of the texture to apply the post process on
  21236. */
  21237. width: number;
  21238. /**
  21239. * Height of the texture to apply the post process on
  21240. */
  21241. height: number;
  21242. /**
  21243. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  21244. */
  21245. _outputTexture: Nullable<InternalTexture>;
  21246. /**
  21247. * Sampling mode used by the shader
  21248. * See https://doc.babylonjs.com/classes/3.1/texture
  21249. */
  21250. renderTargetSamplingMode: number;
  21251. /**
  21252. * Clear color to use when screen clearing
  21253. */
  21254. clearColor: Color4;
  21255. /**
  21256. * If the buffer needs to be cleared before applying the post process. (default: true)
  21257. * Should be set to false if shader will overwrite all previous pixels.
  21258. */
  21259. autoClear: boolean;
  21260. /**
  21261. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  21262. */
  21263. alphaMode: number;
  21264. /**
  21265. * Sets the setAlphaBlendConstants of the babylon engine
  21266. */
  21267. alphaConstants: Color4;
  21268. /**
  21269. * Animations to be used for the post processing
  21270. */
  21271. animations: Animation[];
  21272. /**
  21273. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  21274. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  21275. */
  21276. enablePixelPerfectMode: boolean;
  21277. /**
  21278. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  21279. */
  21280. scaleMode: number;
  21281. /**
  21282. * Force textures to be a power of two (default: false)
  21283. */
  21284. alwaysForcePOT: boolean;
  21285. /**
  21286. * Number of sample textures (default: 1)
  21287. */
  21288. samples: number;
  21289. /**
  21290. * Modify the scale of the post process to be the same as the viewport (default: false)
  21291. */
  21292. adaptScaleToCurrentViewport: boolean;
  21293. private _camera;
  21294. private _scene;
  21295. private _engine;
  21296. private _options;
  21297. private _reusable;
  21298. private _textureType;
  21299. /**
  21300. * Smart array of input and output textures for the post process.
  21301. */
  21302. _textures: SmartArray<InternalTexture>;
  21303. /**
  21304. * The index in _textures that corresponds to the output texture.
  21305. */
  21306. _currentRenderTextureInd: number;
  21307. private _effect;
  21308. private _samplers;
  21309. private _fragmentUrl;
  21310. private _vertexUrl;
  21311. private _parameters;
  21312. private _scaleRatio;
  21313. protected _indexParameters: any;
  21314. private _shareOutputWithPostProcess;
  21315. private _texelSize;
  21316. private _forcedOutputTexture;
  21317. /**
  21318. * An event triggered when the postprocess is activated.
  21319. */
  21320. onActivateObservable: Observable<Camera>;
  21321. private _onActivateObserver;
  21322. /**
  21323. * A function that is added to the onActivateObservable
  21324. */
  21325. onActivate: Nullable<(camera: Camera) => void>;
  21326. /**
  21327. * An event triggered when the postprocess changes its size.
  21328. */
  21329. onSizeChangedObservable: Observable<PostProcess>;
  21330. private _onSizeChangedObserver;
  21331. /**
  21332. * A function that is added to the onSizeChangedObservable
  21333. */
  21334. onSizeChanged: (postProcess: PostProcess) => void;
  21335. /**
  21336. * An event triggered when the postprocess applies its effect.
  21337. */
  21338. onApplyObservable: Observable<Effect>;
  21339. private _onApplyObserver;
  21340. /**
  21341. * A function that is added to the onApplyObservable
  21342. */
  21343. onApply: (effect: Effect) => void;
  21344. /**
  21345. * An event triggered before rendering the postprocess
  21346. */
  21347. onBeforeRenderObservable: Observable<Effect>;
  21348. private _onBeforeRenderObserver;
  21349. /**
  21350. * A function that is added to the onBeforeRenderObservable
  21351. */
  21352. onBeforeRender: (effect: Effect) => void;
  21353. /**
  21354. * An event triggered after rendering the postprocess
  21355. */
  21356. onAfterRenderObservable: Observable<Effect>;
  21357. private _onAfterRenderObserver;
  21358. /**
  21359. * A function that is added to the onAfterRenderObservable
  21360. */
  21361. onAfterRender: (efect: Effect) => void;
  21362. /**
  21363. * 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
  21364. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  21365. */
  21366. inputTexture: InternalTexture;
  21367. /**
  21368. * Gets the camera which post process is applied to.
  21369. * @returns The camera the post process is applied to.
  21370. */
  21371. getCamera(): Camera;
  21372. /**
  21373. * Gets the texel size of the postprocess.
  21374. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  21375. */
  21376. readonly texelSize: Vector2;
  21377. /**
  21378. * Creates a new instance PostProcess
  21379. * @param name The name of the PostProcess.
  21380. * @param fragmentUrl The url of the fragment shader to be used.
  21381. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  21382. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  21383. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  21384. * @param camera The camera to apply the render pass to.
  21385. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  21386. * @param engine The engine which the post process will be applied. (default: current engine)
  21387. * @param reusable If the post process can be reused on the same frame. (default: false)
  21388. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  21389. * @param textureType Type of textures used when performing the post process. (default: 0)
  21390. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  21391. * @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
  21392. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  21393. */
  21394. 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);
  21395. /**
  21396. * Gets the engine which this post process belongs to.
  21397. * @returns The engine the post process was enabled with.
  21398. */
  21399. getEngine(): Engine;
  21400. /**
  21401. * The effect that is created when initializing the post process.
  21402. * @returns The created effect corrisponding the the postprocess.
  21403. */
  21404. getEffect(): Effect;
  21405. /**
  21406. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  21407. * @param postProcess The post process to share the output with.
  21408. * @returns This post process.
  21409. */
  21410. shareOutputWith(postProcess: PostProcess): PostProcess;
  21411. /**
  21412. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  21413. * This should be called if the post process that shares output with this post process is disabled/disposed.
  21414. */
  21415. useOwnOutput(): void;
  21416. /**
  21417. * Updates the effect with the current post process compile time values and recompiles the shader.
  21418. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  21419. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  21420. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  21421. * @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
  21422. * @param onCompiled Called when the shader has been compiled.
  21423. * @param onError Called if there is an error when compiling a shader.
  21424. */
  21425. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  21426. /**
  21427. * The post process is reusable if it can be used multiple times within one frame.
  21428. * @returns If the post process is reusable
  21429. */
  21430. isReusable(): boolean;
  21431. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  21432. markTextureDirty(): void;
  21433. /**
  21434. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  21435. * 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.
  21436. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  21437. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  21438. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  21439. * @returns The target texture that was bound to be written to.
  21440. */
  21441. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  21442. /**
  21443. * If the post process is supported.
  21444. */
  21445. readonly isSupported: boolean;
  21446. /**
  21447. * The aspect ratio of the output texture.
  21448. */
  21449. readonly aspectRatio: number;
  21450. /**
  21451. * Get a value indicating if the post-process is ready to be used
  21452. * @returns true if the post-process is ready (shader is compiled)
  21453. */
  21454. isReady(): boolean;
  21455. /**
  21456. * Binds all textures and uniforms to the shader, this will be run on every pass.
  21457. * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
  21458. */
  21459. apply(): Nullable<Effect>;
  21460. private _disposeTextures();
  21461. /**
  21462. * Disposes the post process.
  21463. * @param camera The camera to dispose the post process on.
  21464. */
  21465. dispose(camera?: Camera): void;
  21466. }
  21467. }
  21468. declare module BABYLON {
  21469. /**
  21470. * PostProcessManager is used to manage one or more post processes or post process pipelines
  21471. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  21472. */
  21473. class PostProcessManager {
  21474. private _scene;
  21475. private _indexBuffer;
  21476. private _vertexBuffers;
  21477. /**
  21478. * Creates a new instance PostProcess
  21479. * @param scene The scene that the post process is associated with.
  21480. */
  21481. constructor(scene: Scene);
  21482. private _prepareBuffers();
  21483. private _buildIndexBuffer();
  21484. /**
  21485. * Rebuilds the vertex buffers of the manager.
  21486. */
  21487. _rebuild(): void;
  21488. /**
  21489. * Prepares a frame to be run through a post process.
  21490. * @param sourceTexture The input texture to the post procesess. (default: null)
  21491. * @param postProcesses An array of post processes to be run. (default: null)
  21492. * @returns True if the post processes were able to be run.
  21493. */
  21494. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  21495. /**
  21496. * Manually render a set of post processes to a texture.
  21497. * @param postProcesses An array of post processes to be run.
  21498. * @param targetTexture The target texture to render to.
  21499. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  21500. */
  21501. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean): void;
  21502. /**
  21503. * Finalize the result of the output of the postprocesses.
  21504. * @param doNotPresent If true the result will not be displayed to the screen.
  21505. * @param targetTexture The target texture to render to.
  21506. * @param faceIndex The index of the face to bind the target texture to.
  21507. * @param postProcesses The array of post processes to render.
  21508. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  21509. */
  21510. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  21511. /**
  21512. * Disposes of the post process manager.
  21513. */
  21514. dispose(): void;
  21515. }
  21516. }
  21517. declare module BABYLON {
  21518. class RefractionPostProcess extends PostProcess {
  21519. color: Color3;
  21520. depth: number;
  21521. colorLevel: number;
  21522. private _refTexture;
  21523. private _ownRefractionTexture;
  21524. /**
  21525. * Gets or sets the refraction texture
  21526. * Please note that you are responsible for disposing the texture if you set it manually
  21527. */
  21528. refractionTexture: Texture;
  21529. constructor(name: string, refractionTextureUrl: string, color: Color3, depth: number, colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  21530. dispose(camera: Camera): void;
  21531. }
  21532. }
  21533. declare module BABYLON {
  21534. /**
  21535. * The SharpenPostProcess applies a sharpen kernel to every pixel
  21536. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  21537. */
  21538. class SharpenPostProcess extends PostProcess {
  21539. /**
  21540. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  21541. */
  21542. colorAmount: number;
  21543. /**
  21544. * How much sharpness should be applied (default: 0.3)
  21545. */
  21546. edgeAmount: number;
  21547. /**
  21548. * Creates a new instance ConvolutionPostProcess
  21549. * @param name The name of the effect.
  21550. * @param options The required width/height ratio to downsize to before computing the render pass.
  21551. * @param camera The camera to apply the render pass to.
  21552. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  21553. * @param engine The engine which the post process will be applied. (default: current engine)
  21554. * @param reusable If the post process can be reused on the same frame. (default: false)
  21555. * @param textureType Type of textures used when performing the post process. (default: 0)
  21556. * @param blockCompilation If compilation of the shader should not be done in the constructor. The updateEffect method can be used to compile the shader at a later time. (default: false)
  21557. */
  21558. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  21559. }
  21560. }
  21561. declare module BABYLON {
  21562. class StereoscopicInterlacePostProcess extends PostProcess {
  21563. private _stepSize;
  21564. private _passedProcess;
  21565. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  21566. }
  21567. }
  21568. declare module BABYLON {
  21569. enum TonemappingOperator {
  21570. Hable = 0,
  21571. Reinhard = 1,
  21572. HejiDawson = 2,
  21573. Photographic = 3,
  21574. }
  21575. class TonemapPostProcess extends PostProcess {
  21576. private _operator;
  21577. exposureAdjustment: number;
  21578. constructor(name: string, _operator: TonemappingOperator, exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  21579. }
  21580. }
  21581. declare module BABYLON {
  21582. class VolumetricLightScatteringPostProcess extends PostProcess {
  21583. private _volumetricLightScatteringPass;
  21584. private _volumetricLightScatteringRTT;
  21585. private _viewPort;
  21586. private _screenCoordinates;
  21587. private _cachedDefines;
  21588. /**
  21589. * If not undefined, the mesh position is computed from the attached node position
  21590. */
  21591. attachedNode: {
  21592. position: Vector3;
  21593. };
  21594. /**
  21595. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  21596. */
  21597. customMeshPosition: Vector3;
  21598. /**
  21599. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  21600. */
  21601. useCustomMeshPosition: boolean;
  21602. /**
  21603. * If the post-process should inverse the light scattering direction
  21604. */
  21605. invert: boolean;
  21606. /**
  21607. * The internal mesh used by the post-process
  21608. */
  21609. mesh: Mesh;
  21610. useDiffuseColor: boolean;
  21611. /**
  21612. * Array containing the excluded meshes not rendered in the internal pass
  21613. */
  21614. excludedMeshes: AbstractMesh[];
  21615. /**
  21616. * Controls the overall intensity of the post-process
  21617. */
  21618. exposure: number;
  21619. /**
  21620. * Dissipates each sample's contribution in range [0, 1]
  21621. */
  21622. decay: number;
  21623. /**
  21624. * Controls the overall intensity of each sample
  21625. */
  21626. weight: number;
  21627. /**
  21628. * Controls the density of each sample
  21629. */
  21630. density: number;
  21631. /**
  21632. * @constructor
  21633. * @param {string} name - The post-process name
  21634. * @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)
  21635. * @param {BABYLON.Camera} camera - The camera that the post-process will be attached to
  21636. * @param {BABYLON.Mesh} mesh - The mesh used to create the light scattering
  21637. * @param {number} samples - The post-process quality, default 100
  21638. * @param {number} samplingMode - The post-process filtering mode
  21639. * @param {BABYLON.Engine} engine - The babylon engine
  21640. * @param {boolean} reusable - If the post-process is reusable
  21641. * @param {BABYLON.Scene} scene - The constructor needs a scene reference to initialize internal components. If "camera" is null (RenderPipelineà, "scene" must be provided
  21642. */
  21643. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  21644. getClassName(): string;
  21645. private _isReady(subMesh, useInstances);
  21646. /**
  21647. * Sets the new light position for light scattering effect
  21648. * @param {BABYLON.Vector3} The new custom light position
  21649. */
  21650. setCustomMeshPosition(position: Vector3): void;
  21651. /**
  21652. * Returns the light position for light scattering effect
  21653. * @return {BABYLON.Vector3} The custom light position
  21654. */
  21655. getCustomMeshPosition(): Vector3;
  21656. /**
  21657. * Disposes the internal assets and detaches the post-process from the camera
  21658. */
  21659. dispose(camera: Camera): void;
  21660. /**
  21661. * Returns the render target texture used by the post-process
  21662. * @return {BABYLON.RenderTargetTexture} The render target texture used by the post-process
  21663. */
  21664. getPass(): RenderTargetTexture;
  21665. private _meshExcluded(mesh);
  21666. private _createPass(scene, ratio);
  21667. private _updateMeshScreenCoordinates(scene);
  21668. /**
  21669. * Creates a default mesh for the Volumeric Light Scattering post-process
  21670. * @param {string} The mesh name
  21671. * @param {BABYLON.Scene} The scene where to create the mesh
  21672. * @return {BABYLON.Mesh} the default mesh
  21673. */
  21674. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  21675. }
  21676. }
  21677. declare module BABYLON {
  21678. class VRDistortionCorrectionPostProcess extends PostProcess {
  21679. private _isRightEye;
  21680. private _distortionFactors;
  21681. private _postProcessScaleFactor;
  21682. private _lensCenterOffset;
  21683. private _scaleIn;
  21684. private _scaleFactor;
  21685. private _lensCenter;
  21686. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  21687. }
  21688. }
  21689. declare module BABYLON {
  21690. class _AlphaState {
  21691. private _isAlphaBlendDirty;
  21692. private _isBlendFunctionParametersDirty;
  21693. private _isBlendEquationParametersDirty;
  21694. private _isBlendConstantsDirty;
  21695. private _alphaBlend;
  21696. private _blendFunctionParameters;
  21697. private _blendEquationParameters;
  21698. private _blendConstants;
  21699. /**
  21700. * Initializes the state.
  21701. */
  21702. constructor();
  21703. readonly isDirty: boolean;
  21704. alphaBlend: boolean;
  21705. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  21706. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  21707. setAlphaEquationParameters(rgb: number, alpha: number): void;
  21708. reset(): void;
  21709. apply(gl: WebGLRenderingContext): void;
  21710. }
  21711. }
  21712. declare module BABYLON {
  21713. class _DepthCullingState {
  21714. private _isDepthTestDirty;
  21715. private _isDepthMaskDirty;
  21716. private _isDepthFuncDirty;
  21717. private _isCullFaceDirty;
  21718. private _isCullDirty;
  21719. private _isZOffsetDirty;
  21720. private _isFrontFaceDirty;
  21721. private _depthTest;
  21722. private _depthMask;
  21723. private _depthFunc;
  21724. private _cull;
  21725. private _cullFace;
  21726. private _zOffset;
  21727. private _frontFace;
  21728. /**
  21729. * Initializes the state.
  21730. */
  21731. constructor();
  21732. readonly isDirty: boolean;
  21733. zOffset: number;
  21734. cullFace: Nullable<number>;
  21735. cull: Nullable<boolean>;
  21736. depthFunc: Nullable<number>;
  21737. depthMask: boolean;
  21738. depthTest: boolean;
  21739. frontFace: Nullable<number>;
  21740. reset(): void;
  21741. apply(gl: WebGLRenderingContext): void;
  21742. }
  21743. }
  21744. declare module BABYLON {
  21745. class _StencilState {
  21746. private _isStencilTestDirty;
  21747. private _isStencilMaskDirty;
  21748. private _isStencilFuncDirty;
  21749. private _isStencilOpDirty;
  21750. private _stencilTest;
  21751. private _stencilMask;
  21752. private _stencilFunc;
  21753. private _stencilFuncRef;
  21754. private _stencilFuncMask;
  21755. private _stencilOpStencilFail;
  21756. private _stencilOpDepthFail;
  21757. private _stencilOpStencilDepthPass;
  21758. readonly isDirty: boolean;
  21759. stencilFunc: number;
  21760. stencilFuncRef: number;
  21761. stencilFuncMask: number;
  21762. stencilOpStencilFail: number;
  21763. stencilOpDepthFail: number;
  21764. stencilOpStencilDepthPass: number;
  21765. stencilMask: number;
  21766. stencilTest: boolean;
  21767. constructor();
  21768. reset(): void;
  21769. apply(gl: WebGLRenderingContext): void;
  21770. }
  21771. }
  21772. declare module BABYLON {
  21773. class AndOrNotEvaluator {
  21774. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  21775. private static _HandleParenthesisContent(parenthesisContent, evaluateCallback);
  21776. private static _SimplifyNegation(booleanString);
  21777. }
  21778. }
  21779. declare module BABYLON {
  21780. /**
  21781. * Defines the list of states available for a task inside a {BABYLON.AssetsManager}
  21782. */
  21783. enum AssetTaskState {
  21784. /**
  21785. * Initialization
  21786. */
  21787. INIT = 0,
  21788. /**
  21789. * Running
  21790. */
  21791. RUNNING = 1,
  21792. /**
  21793. * Done
  21794. */
  21795. DONE = 2,
  21796. /**
  21797. * Error
  21798. */
  21799. ERROR = 3,
  21800. }
  21801. /**
  21802. * Define an abstract asset task used with a {BABYLON.AssetsManager} class to load assets into a scene
  21803. */
  21804. abstract class AbstractAssetTask {
  21805. /**
  21806. * Task name
  21807. */ name: string;
  21808. /**
  21809. * Callback called when the task is successful
  21810. */
  21811. onSuccess: (task: any) => void;
  21812. /**
  21813. * Callback called when the task is not successful
  21814. */
  21815. onError: (task: any, message?: string, exception?: any) => void;
  21816. /**
  21817. * Creates a new {BABYLON.AssetsManager}
  21818. * @param name defines the name of the task
  21819. */
  21820. constructor(
  21821. /**
  21822. * Task name
  21823. */ name: string);
  21824. private _isCompleted;
  21825. private _taskState;
  21826. private _errorObject;
  21827. /**
  21828. * Get if the task is completed
  21829. */
  21830. readonly isCompleted: boolean;
  21831. /**
  21832. * Gets the current state of the task
  21833. */
  21834. readonly taskState: AssetTaskState;
  21835. /**
  21836. * Gets the current error object (if task is in error)
  21837. */
  21838. readonly errorObject: {
  21839. message?: string;
  21840. exception?: any;
  21841. };
  21842. /**
  21843. * Internal only
  21844. * @ignore
  21845. */
  21846. _setErrorObject(message?: string, exception?: any): void;
  21847. /**
  21848. * Execute the current task
  21849. * @param scene defines the scene where you want your assets to be loaded
  21850. * @param onSuccess is a callback called when the task is successfully executed
  21851. * @param onError is a callback called if an error occurs
  21852. */
  21853. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  21854. /**
  21855. * Execute the current task
  21856. * @param scene defines the scene where you want your assets to be loaded
  21857. * @param onSuccess is a callback called when the task is successfully executed
  21858. * @param onError is a callback called if an error occurs
  21859. */
  21860. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  21861. private onErrorCallback(onError, message?, exception?);
  21862. private onDoneCallback(onSuccess, onError);
  21863. }
  21864. /**
  21865. * Define the interface used by progress events raised during assets loading
  21866. */
  21867. interface IAssetsProgressEvent {
  21868. /**
  21869. * Defines the number of remaining tasks to process
  21870. */
  21871. remainingCount: number;
  21872. /**
  21873. * Defines the total number of tasks
  21874. */
  21875. totalCount: number;
  21876. /**
  21877. * Defines the task that was just processed
  21878. */
  21879. task: AbstractAssetTask;
  21880. }
  21881. /**
  21882. * Class used to share progress information about assets loading
  21883. */
  21884. class AssetsProgressEvent implements IAssetsProgressEvent {
  21885. /**
  21886. * Defines the number of remaining tasks to process
  21887. */
  21888. remainingCount: number;
  21889. /**
  21890. * Defines the total number of tasks
  21891. */
  21892. totalCount: number;
  21893. /**
  21894. * Defines the task that was just processed
  21895. */
  21896. task: AbstractAssetTask;
  21897. /**
  21898. * Creates a {BABYLON.AssetsProgressEvent}
  21899. * @param remainingCount defines the number of remaining tasks to process
  21900. * @param totalCount defines the total number of tasks
  21901. * @param task defines the task that was just processed
  21902. */
  21903. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  21904. }
  21905. /**
  21906. * Define a task used by {BABYLON.AssetsManager} to load meshes
  21907. */
  21908. class MeshAssetTask extends AbstractAssetTask {
  21909. /**
  21910. * Defines the name of the task
  21911. */
  21912. name: string;
  21913. /**
  21914. * Defines the list of mesh's names you want to load
  21915. */
  21916. meshesNames: any;
  21917. /**
  21918. * Defines the root url to use as a base to load your meshes and associated resources
  21919. */
  21920. rootUrl: string;
  21921. /**
  21922. * Defines the filename of the scene to load from
  21923. */
  21924. sceneFilename: string;
  21925. /**
  21926. * Gets the list of loaded meshes
  21927. */
  21928. loadedMeshes: Array<AbstractMesh>;
  21929. /**
  21930. * Gets the list of loaded particle systems
  21931. */
  21932. loadedParticleSystems: Array<ParticleSystem>;
  21933. /**
  21934. * Gets the list of loaded skeletons
  21935. */
  21936. loadedSkeletons: Array<Skeleton>;
  21937. /**
  21938. * Callback called when the task is successful
  21939. */
  21940. onSuccess: (task: MeshAssetTask) => void;
  21941. /**
  21942. * Callback called when the task is successful
  21943. */
  21944. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  21945. /**
  21946. * Creates a new {BABYLON.MeshAssetTask}
  21947. * @param name defines the name of the task
  21948. * @param meshesNames defines the list of mesh's names you want to load
  21949. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  21950. * @param sceneFilename defines the filename of the scene to load from
  21951. */
  21952. constructor(
  21953. /**
  21954. * Defines the name of the task
  21955. */
  21956. name: string,
  21957. /**
  21958. * Defines the list of mesh's names you want to load
  21959. */
  21960. meshesNames: any,
  21961. /**
  21962. * Defines the root url to use as a base to load your meshes and associated resources
  21963. */
  21964. rootUrl: string,
  21965. /**
  21966. * Defines the filename of the scene to load from
  21967. */
  21968. sceneFilename: string);
  21969. /**
  21970. * Execute the current task
  21971. * @param scene defines the scene where you want your assets to be loaded
  21972. * @param onSuccess is a callback called when the task is successfully executed
  21973. * @param onError is a callback called if an error occurs
  21974. */
  21975. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  21976. }
  21977. /**
  21978. * Define a task used by {BABYLON.AssetsManager} to load text content
  21979. */
  21980. class TextFileAssetTask extends AbstractAssetTask {
  21981. /**
  21982. * Defines the name of the task
  21983. */
  21984. name: string;
  21985. /**
  21986. * Defines the location of the file to load
  21987. */
  21988. url: string;
  21989. /**
  21990. * Gets the loaded text string
  21991. */
  21992. text: string;
  21993. /**
  21994. * Callback called when the task is successful
  21995. */
  21996. onSuccess: (task: TextFileAssetTask) => void;
  21997. /**
  21998. * Callback called when the task is successful
  21999. */
  22000. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  22001. /**
  22002. * Creates a new TextFileAssetTask object
  22003. * @param name defines the name of the task
  22004. * @param url defines the location of the file to load
  22005. */
  22006. constructor(
  22007. /**
  22008. * Defines the name of the task
  22009. */
  22010. name: string,
  22011. /**
  22012. * Defines the location of the file to load
  22013. */
  22014. url: string);
  22015. /**
  22016. * Execute the current task
  22017. * @param scene defines the scene where you want your assets to be loaded
  22018. * @param onSuccess is a callback called when the task is successfully executed
  22019. * @param onError is a callback called if an error occurs
  22020. */
  22021. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  22022. }
  22023. /**
  22024. * Define a task used by {BABYLON.AssetsManager} to load binary data
  22025. */
  22026. class BinaryFileAssetTask extends AbstractAssetTask {
  22027. /**
  22028. * Defines the name of the task
  22029. */
  22030. name: string;
  22031. /**
  22032. * Defines the location of the file to load
  22033. */
  22034. url: string;
  22035. /**
  22036. * Gets the lodaded data (as an array buffer)
  22037. */
  22038. data: ArrayBuffer;
  22039. /**
  22040. * Callback called when the task is successful
  22041. */
  22042. onSuccess: (task: BinaryFileAssetTask) => void;
  22043. /**
  22044. * Callback called when the task is successful
  22045. */
  22046. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  22047. /**
  22048. * Creates a new BinaryFileAssetTask object
  22049. * @param name defines the name of the new task
  22050. * @param url defines the location of the file to load
  22051. */
  22052. constructor(
  22053. /**
  22054. * Defines the name of the task
  22055. */
  22056. name: string,
  22057. /**
  22058. * Defines the location of the file to load
  22059. */
  22060. url: string);
  22061. /**
  22062. * Execute the current task
  22063. * @param scene defines the scene where you want your assets to be loaded
  22064. * @param onSuccess is a callback called when the task is successfully executed
  22065. * @param onError is a callback called if an error occurs
  22066. */
  22067. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  22068. }
  22069. /**
  22070. * Define a task used by {BABYLON.AssetsManager} to load images
  22071. */
  22072. class ImageAssetTask extends AbstractAssetTask {
  22073. /**
  22074. * Defines the name of the task
  22075. */
  22076. name: string;
  22077. /**
  22078. * Defines the location of the image to load
  22079. */
  22080. url: string;
  22081. /**
  22082. * Gets the loaded images
  22083. */
  22084. image: HTMLImageElement;
  22085. /**
  22086. * Callback called when the task is successful
  22087. */
  22088. onSuccess: (task: ImageAssetTask) => void;
  22089. /**
  22090. * Callback called when the task is successful
  22091. */
  22092. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  22093. /**
  22094. * Creates a new ImageAssetTask
  22095. * @param name defines the name of the task
  22096. * @param url defines the location of the image to load
  22097. */
  22098. constructor(
  22099. /**
  22100. * Defines the name of the task
  22101. */
  22102. name: string,
  22103. /**
  22104. * Defines the location of the image to load
  22105. */
  22106. url: string);
  22107. /**
  22108. * Execute the current task
  22109. * @param scene defines the scene where you want your assets to be loaded
  22110. * @param onSuccess is a callback called when the task is successfully executed
  22111. * @param onError is a callback called if an error occurs
  22112. */
  22113. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  22114. }
  22115. /**
  22116. * Defines the interface used by texture loading tasks
  22117. */
  22118. interface ITextureAssetTask<TEX extends BaseTexture> {
  22119. /**
  22120. * Gets the loaded texture
  22121. */
  22122. texture: TEX;
  22123. }
  22124. /**
  22125. * Define a task used by {BABYLON.AssetsManager} to load 2D textures
  22126. */
  22127. class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  22128. /**
  22129. * Defines the name of the task
  22130. */
  22131. name: string;
  22132. /**
  22133. * Defines the location of the file to load
  22134. */
  22135. url: string;
  22136. /**
  22137. * Defines if mipmap should not be generated (default is false)
  22138. */
  22139. noMipmap: boolean | undefined;
  22140. /**
  22141. * Defines if texture must be inverted on Y axis (default is false)
  22142. */
  22143. invertY: boolean | undefined;
  22144. /**
  22145. * Defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  22146. */
  22147. samplingMode: number;
  22148. /**
  22149. * Gets the loaded texture
  22150. */
  22151. texture: Texture;
  22152. /**
  22153. * Callback called when the task is successful
  22154. */
  22155. onSuccess: (task: TextureAssetTask) => void;
  22156. /**
  22157. * Callback called when the task is successful
  22158. */
  22159. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  22160. /**
  22161. * Creates a new TextureAssetTask object
  22162. * @param name defines the name of the task
  22163. * @param url defines the location of the file to load
  22164. * @param noMipmap defines if mipmap should not be generated (default is false)
  22165. * @param invertY defines if texture must be inverted on Y axis (default is false)
  22166. * @param samplingMode defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  22167. */
  22168. constructor(
  22169. /**
  22170. * Defines the name of the task
  22171. */
  22172. name: string,
  22173. /**
  22174. * Defines the location of the file to load
  22175. */
  22176. url: string,
  22177. /**
  22178. * Defines if mipmap should not be generated (default is false)
  22179. */
  22180. noMipmap?: boolean | undefined,
  22181. /**
  22182. * Defines if texture must be inverted on Y axis (default is false)
  22183. */
  22184. invertY?: boolean | undefined,
  22185. /**
  22186. * Defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  22187. */
  22188. samplingMode?: number);
  22189. /**
  22190. * Execute the current task
  22191. * @param scene defines the scene where you want your assets to be loaded
  22192. * @param onSuccess is a callback called when the task is successfully executed
  22193. * @param onError is a callback called if an error occurs
  22194. */
  22195. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  22196. }
  22197. /**
  22198. * Define a task used by {BABYLON.AssetsManager} to load cube textures
  22199. */
  22200. class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  22201. /**
  22202. * Defines the name of the task
  22203. */
  22204. name: string;
  22205. /**
  22206. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  22207. */
  22208. url: string;
  22209. /**
  22210. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  22211. */
  22212. extensions: string[] | undefined;
  22213. /**
  22214. * Defines if mipmaps should not be generated (default is false)
  22215. */
  22216. noMipmap: boolean | undefined;
  22217. /**
  22218. * Defines the explicit list of files (undefined by default)
  22219. */
  22220. files: string[] | undefined;
  22221. /**
  22222. * Gets the loaded texture
  22223. */
  22224. texture: CubeTexture;
  22225. /**
  22226. * Callback called when the task is successful
  22227. */
  22228. onSuccess: (task: CubeTextureAssetTask) => void;
  22229. /**
  22230. * Callback called when the task is successful
  22231. */
  22232. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  22233. /**
  22234. * Creates a new CubeTextureAssetTask
  22235. * @param name defines the name of the task
  22236. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  22237. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  22238. * @param noMipmap defines if mipmaps should not be generated (default is false)
  22239. * @param files defines the explicit list of files (undefined by default)
  22240. */
  22241. constructor(
  22242. /**
  22243. * Defines the name of the task
  22244. */
  22245. name: string,
  22246. /**
  22247. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  22248. */
  22249. url: string,
  22250. /**
  22251. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  22252. */
  22253. extensions?: string[] | undefined,
  22254. /**
  22255. * Defines if mipmaps should not be generated (default is false)
  22256. */
  22257. noMipmap?: boolean | undefined,
  22258. /**
  22259. * Defines the explicit list of files (undefined by default)
  22260. */
  22261. files?: string[] | undefined);
  22262. /**
  22263. * Execute the current task
  22264. * @param scene defines the scene where you want your assets to be loaded
  22265. * @param onSuccess is a callback called when the task is successfully executed
  22266. * @param onError is a callback called if an error occurs
  22267. */
  22268. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  22269. }
  22270. /**
  22271. * Define a task used by {BABYLON.AssetsManager} to load HDR cube textures
  22272. */
  22273. class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  22274. /**
  22275. * Defines the name of the task
  22276. */
  22277. name: string;
  22278. /**
  22279. * Defines the location of the file to load
  22280. */
  22281. url: string;
  22282. /**
  22283. * 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.
  22284. */
  22285. size: number | undefined;
  22286. /**
  22287. * Defines if mipmaps should not be generated (default is false)
  22288. */
  22289. noMipmap: boolean;
  22290. /**
  22291. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  22292. */
  22293. generateHarmonics: boolean;
  22294. /**
  22295. * 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)
  22296. */
  22297. useInGammaSpace: boolean;
  22298. /**
  22299. * Specifies whether or not to generate the CubeMap through CubeMapGen to avoid seams issue at run time (default is false)
  22300. */
  22301. usePMREMGenerator: boolean;
  22302. /**
  22303. * Gets the loaded texture
  22304. */
  22305. texture: HDRCubeTexture;
  22306. /**
  22307. * Callback called when the task is successful
  22308. */
  22309. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  22310. /**
  22311. * Callback called when the task is successful
  22312. */
  22313. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  22314. /**
  22315. * Creates a new HDRCubeTextureAssetTask object
  22316. * @param name defines the name of the task
  22317. * @param url defines the location of the file to load
  22318. * @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.
  22319. * @param noMipmap defines if mipmaps should not be generated (default is false)
  22320. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  22321. * @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)
  22322. * @param usePMREMGenerator specifies whether or not to generate the CubeMap through CubeMapGen to avoid seams issue at run time (default is false)
  22323. */
  22324. constructor(
  22325. /**
  22326. * Defines the name of the task
  22327. */
  22328. name: string,
  22329. /**
  22330. * Defines the location of the file to load
  22331. */
  22332. url: string,
  22333. /**
  22334. * 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.
  22335. */
  22336. size?: number | undefined,
  22337. /**
  22338. * Defines if mipmaps should not be generated (default is false)
  22339. */
  22340. noMipmap?: boolean,
  22341. /**
  22342. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  22343. */
  22344. generateHarmonics?: boolean,
  22345. /**
  22346. * 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)
  22347. */
  22348. useInGammaSpace?: boolean,
  22349. /**
  22350. * Specifies whether or not to generate the CubeMap through CubeMapGen to avoid seams issue at run time (default is false)
  22351. */
  22352. usePMREMGenerator?: boolean);
  22353. /**
  22354. * Execute the current task
  22355. * @param scene defines the scene where you want your assets to be loaded
  22356. * @param onSuccess is a callback called when the task is successfully executed
  22357. * @param onError is a callback called if an error occurs
  22358. */
  22359. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  22360. }
  22361. /**
  22362. * This class can be used to easily import assets into a scene
  22363. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  22364. */
  22365. class AssetsManager {
  22366. private _scene;
  22367. private _isLoading;
  22368. protected _tasks: AbstractAssetTask[];
  22369. protected _waitingTasksCount: number;
  22370. protected _totalTasksCount: number;
  22371. /**
  22372. * Callback called when all tasks are processed
  22373. */
  22374. onFinish: (tasks: AbstractAssetTask[]) => void;
  22375. /**
  22376. * Callback called when a task is successful
  22377. */
  22378. onTaskSuccess: (task: AbstractAssetTask) => void;
  22379. /**
  22380. * Callback called when a task had an error
  22381. */
  22382. onTaskError: (task: AbstractAssetTask) => void;
  22383. /**
  22384. * Callback called when a task is done (whatever the result is)
  22385. */
  22386. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  22387. /**
  22388. * Observable called when all tasks are processed
  22389. */
  22390. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  22391. /**
  22392. * Observable called when a task had an error
  22393. */
  22394. onTaskErrorObservable: Observable<AbstractAssetTask>;
  22395. /**
  22396. * Observable called when a task is successful
  22397. */
  22398. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  22399. /**
  22400. * Observable called when a task is done (whatever the result is)
  22401. */
  22402. onProgressObservable: Observable<IAssetsProgressEvent>;
  22403. /**
  22404. * Gets or sets a boolean defining if the {BABYLON.AssetsManager} should use the default loading screen
  22405. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  22406. */
  22407. useDefaultLoadingScreen: boolean;
  22408. /**
  22409. * Creates a new AssetsManager
  22410. * @param scene defines the scene to work on
  22411. */
  22412. constructor(scene: Scene);
  22413. /**
  22414. * Add a {BABYLON.MeshAssetTask} to the list of active tasks
  22415. * @param taskName defines the name of the new task
  22416. * @param meshesNames defines the name of meshes to load
  22417. * @param rootUrl defines the root url to use to locate files
  22418. * @param sceneFilename defines the filename of the scene file
  22419. * @returns a new {BABYLON.MeshAssetTask} object
  22420. */
  22421. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  22422. /**
  22423. * Add a {BABYLON.TextFileAssetTask} to the list of active tasks
  22424. * @param taskName defines the name of the new task
  22425. * @param url defines the url of the file to load
  22426. * @returns a new {BABYLON.TextFileAssetTask} object
  22427. */
  22428. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  22429. /**
  22430. * Add a {BABYLON.BinaryFileAssetTask} to the list of active tasks
  22431. * @param taskName defines the name of the new task
  22432. * @param url defines the url of the file to load
  22433. * @returns a new {BABYLON.BinaryFileAssetTask} object
  22434. */
  22435. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  22436. /**
  22437. * Add a {BABYLON.ImageAssetTask} to the list of active tasks
  22438. * @param taskName defines the name of the new task
  22439. * @param url defines the url of the file to load
  22440. * @returns a new {BABYLON.ImageAssetTask} object
  22441. */
  22442. addImageTask(taskName: string, url: string): ImageAssetTask;
  22443. /**
  22444. * Add a {BABYLON.TextureAssetTask} to the list of active tasks
  22445. * @param taskName defines the name of the new task
  22446. * @param url defines the url of the file to load
  22447. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  22448. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  22449. * @param samplingMode defines the sampling mode to use (BABYLON.Texture.TRILINEAR_SAMPLINGMODE by default)
  22450. * @returns a new {BABYLON.TextureAssetTask} object
  22451. */
  22452. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  22453. /**
  22454. * Add a {BABYLON.CubeTextureAssetTask} to the list of active tasks
  22455. * @param taskName defines the name of the new task
  22456. * @param url defines the url of the file to load
  22457. * @param extensions defines the extension to use to load the cube map (can be null)
  22458. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  22459. * @param files defines the list of files to load (can be null)
  22460. * @returns a new {BABYLON.CubeTextureAssetTask} object
  22461. */
  22462. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  22463. /**
  22464. *
  22465. * Add a {BABYLON.HDRCubeTextureAssetTask} to the list of active tasks
  22466. * @param taskName defines the name of the new task
  22467. * @param url defines the url of the file to load
  22468. * @param size defines the size you want for the cubemap (can be null)
  22469. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  22470. * @param generateHarmonics defines if you want to automatically generate (true by default)
  22471. * @param useInGammaSpace defines if the texture must be considered in gamma space (false by default)
  22472. * @param usePMREMGenerator is a reserved parameter and must be set to false or ignored
  22473. * @returns a new {BABYLON.HDRCubeTextureAssetTask} object
  22474. */
  22475. addHDRCubeTextureTask(taskName: string, url: string, size?: number, noMipmap?: boolean, generateHarmonics?: boolean, useInGammaSpace?: boolean, usePMREMGenerator?: boolean): HDRCubeTextureAssetTask;
  22476. private _decreaseWaitingTasksCount(task);
  22477. private _runTask(task);
  22478. /**
  22479. * Reset the {BABYLON.AssetsManager} and remove all tasks
  22480. * @return the current instance of the {BABYLON.AssetsManager}
  22481. */
  22482. reset(): AssetsManager;
  22483. /**
  22484. * Start the loading process
  22485. * @return the current instance of the {BABYLON.AssetsManager}
  22486. */
  22487. load(): AssetsManager;
  22488. }
  22489. }
  22490. declare module BABYLON {
  22491. class Database {
  22492. private callbackManifestChecked;
  22493. private currentSceneUrl;
  22494. private db;
  22495. private _enableSceneOffline;
  22496. private _enableTexturesOffline;
  22497. private manifestVersionFound;
  22498. private mustUpdateRessources;
  22499. private hasReachedQuota;
  22500. private isSupported;
  22501. private idbFactory;
  22502. static IsUASupportingBlobStorage: boolean;
  22503. static IDBStorageEnabled: boolean;
  22504. readonly enableSceneOffline: boolean;
  22505. readonly enableTexturesOffline: boolean;
  22506. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any);
  22507. static parseURL: (url: string) => string;
  22508. static ReturnFullUrlLocation: (url: string) => string;
  22509. checkManifestFile(): void;
  22510. openAsync(successCallback: () => void, errorCallback: () => void): void;
  22511. loadImageFromDB(url: string, image: HTMLImageElement): void;
  22512. private _loadImageFromDBAsync(url, image, notInDBCallback);
  22513. private _saveImageIntoDBAsync(url, image);
  22514. private _checkVersionFromDB(url, versionLoaded);
  22515. private _loadVersionFromDBAsync(url, callback, updateInDBCallback);
  22516. private _saveVersionIntoDBAsync(url, callback);
  22517. loadFileFromDB(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  22518. private _loadFileFromDBAsync(url, callback, notInDBCallback, useArrayBuffer?);
  22519. private _saveFileIntoDBAsync(url, callback, progressCallback?, useArrayBuffer?);
  22520. }
  22521. }
  22522. declare module BABYLON {
  22523. interface DDSInfo {
  22524. width: number;
  22525. height: number;
  22526. mipmapCount: number;
  22527. isFourCC: boolean;
  22528. isRGB: boolean;
  22529. isLuminance: boolean;
  22530. isCube: boolean;
  22531. isCompressed: boolean;
  22532. dxgiFormat: number;
  22533. textureType: number;
  22534. }
  22535. class DDSTools {
  22536. static StoreLODInAlphaChannel: boolean;
  22537. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  22538. private static _FloatView;
  22539. private static _Int32View;
  22540. private static _ToHalfFloat(value);
  22541. private static _FromHalfFloat(value);
  22542. private static _GetHalfFloatAsFloatRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, lod);
  22543. private static _GetHalfFloatRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, lod);
  22544. private static _GetFloatRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, lod);
  22545. private static _GetFloatAsUIntRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, lod);
  22546. private static _GetHalfFloatAsUIntRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, lod);
  22547. private static _GetRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, rOffset, gOffset, bOffset, aOffset);
  22548. private static _ExtractLongWordOrder(value);
  22549. private static _GetRGBArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, rOffset, gOffset, bOffset);
  22550. private static _GetLuminanceArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer);
  22551. static UploadDDSLevels(engine: Engine, gl: WebGLRenderingContext, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  22552. }
  22553. }
  22554. declare module BABYLON {
  22555. function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  22556. function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  22557. function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  22558. function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  22559. function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  22560. function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  22561. function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  22562. function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  22563. function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  22564. function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  22565. function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  22566. function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  22567. class SerializationHelper {
  22568. static Serialize<T>(entity: T, serializationObject?: any): any;
  22569. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  22570. static Clone<T>(creationFunction: () => T, source: T): T;
  22571. static Instanciate<T>(creationFunction: () => T, source: T): T;
  22572. }
  22573. }
  22574. declare module BABYLON {
  22575. /**
  22576. * Wrapper class for promise with external resolve and reject.
  22577. */
  22578. class Deferred<T> {
  22579. /**
  22580. * The promise associated with this deferred object.
  22581. */
  22582. readonly promise: Promise<T>;
  22583. private _resolve;
  22584. private _reject;
  22585. /**
  22586. * The resolve method of the promise associated with this deferred object.
  22587. */
  22588. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  22589. /**
  22590. * The reject method of the promise associated with this deferred object.
  22591. */
  22592. readonly reject: (reason?: any) => void;
  22593. /**
  22594. * Constructor for this deferred object.
  22595. */
  22596. constructor();
  22597. }
  22598. }
  22599. declare module BABYLON {
  22600. class FilesInput {
  22601. static FilesToLoad: {
  22602. [key: string]: File;
  22603. };
  22604. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  22605. private _engine;
  22606. private _currentScene;
  22607. private _sceneLoadedCallback;
  22608. private _progressCallback;
  22609. private _additionalRenderLoopLogicCallback;
  22610. private _textureLoadingCallback;
  22611. private _startingProcessingFilesCallback;
  22612. private _onReloadCallback;
  22613. private _errorCallback;
  22614. private _elementToMonitor;
  22615. private _sceneFileToLoad;
  22616. private _filesToLoad;
  22617. 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);
  22618. private _dragEnterHandler;
  22619. private _dragOverHandler;
  22620. private _dropHandler;
  22621. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  22622. dispose(): void;
  22623. private renderFunction();
  22624. private drag(e);
  22625. private drop(eventDrop);
  22626. private _traverseFolder(folder, files, remaining, callback);
  22627. private _processFiles(files);
  22628. loadFiles(event: any): void;
  22629. private _processReload();
  22630. reload(): void;
  22631. }
  22632. }
  22633. declare module BABYLON {
  22634. /**
  22635. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  22636. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  22637. */
  22638. class KhronosTextureContainer {
  22639. arrayBuffer: any;
  22640. static HEADER_LEN: number;
  22641. static COMPRESSED_2D: number;
  22642. static COMPRESSED_3D: number;
  22643. static TEX_2D: number;
  22644. static TEX_3D: number;
  22645. glType: number;
  22646. glTypeSize: number;
  22647. glFormat: number;
  22648. glInternalFormat: number;
  22649. glBaseInternalFormat: number;
  22650. pixelWidth: number;
  22651. pixelHeight: number;
  22652. pixelDepth: number;
  22653. numberOfArrayElements: number;
  22654. numberOfFaces: number;
  22655. numberOfMipmapLevels: number;
  22656. bytesOfKeyValueData: number;
  22657. loadType: number;
  22658. /**
  22659. * @param {ArrayBuffer} arrayBuffer- contents of the KTX container file
  22660. * @param {number} facesExpected- should be either 1 or 6, based whether a cube texture or or
  22661. * @param {boolean} threeDExpected- provision for indicating that data should be a 3D texture, not implemented
  22662. * @param {boolean} textureArrayExpected- provision for indicating that data should be a texture array, not implemented
  22663. */
  22664. constructor(arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  22665. switchEndainness(val: number): number;
  22666. /**
  22667. * It is assumed that the texture has already been created & is currently bound
  22668. */
  22669. uploadLevels(gl: WebGLRenderingContext, loadMipmaps: boolean): void;
  22670. private _upload2DCompressedLevels(gl, loadMipmaps);
  22671. }
  22672. }
  22673. declare module BABYLON {
  22674. /**
  22675. * A class serves as a medium between the observable and its observers
  22676. */
  22677. class EventState {
  22678. /**
  22679. * Create a new EventState
  22680. * @param mask defines the mask associated with this state
  22681. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  22682. * @param target defines the original target of the state
  22683. * @param currentTarget defines the current target of the state
  22684. */
  22685. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  22686. /**
  22687. * Initialize the current event state
  22688. * @param mask defines the mask associated with this state
  22689. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  22690. * @param target defines the original target of the state
  22691. * @param currentTarget defines the current target of the state
  22692. * @returns the current event state
  22693. */
  22694. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  22695. /**
  22696. * An Observer can set this property to true to prevent subsequent observers of being notified
  22697. */
  22698. skipNextObservers: boolean;
  22699. /**
  22700. * Get the mask value that were used to trigger the event corresponding to this EventState object
  22701. */
  22702. mask: number;
  22703. /**
  22704. * The object that originally notified the event
  22705. */
  22706. target?: any;
  22707. /**
  22708. * The current object in the bubbling phase
  22709. */
  22710. currentTarget?: any;
  22711. /**
  22712. * This will be populated with the return value of the last function that was executed.
  22713. * If it is the first function in the callback chain it will be the event data.
  22714. */
  22715. lastReturnValue?: any;
  22716. }
  22717. /**
  22718. * Represent an Observer registered to a given Observable object.
  22719. */
  22720. class Observer<T> {
  22721. /**
  22722. * Defines the callback to call when the observer is notified
  22723. */
  22724. callback: (eventData: T, eventState: EventState) => void;
  22725. /**
  22726. * Defines the mask of the observer (used to filter notifications)
  22727. */
  22728. mask: number;
  22729. /**
  22730. * Defines the current scope used to restore the JS context
  22731. */
  22732. scope: any;
  22733. /** @ignore */
  22734. _willBeUnregistered: boolean;
  22735. /**
  22736. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  22737. */
  22738. unregisterOnNextCall: boolean;
  22739. /**
  22740. * Creates a new observer
  22741. * @param callback defines the callback to call when the observer is notified
  22742. * @param mask defines the mask of the observer (used to filter notifications)
  22743. * @param scope defines the current scope used to restore the JS context
  22744. */
  22745. constructor(
  22746. /**
  22747. * Defines the callback to call when the observer is notified
  22748. */
  22749. callback: (eventData: T, eventState: EventState) => void,
  22750. /**
  22751. * Defines the mask of the observer (used to filter notifications)
  22752. */
  22753. mask: number,
  22754. /**
  22755. * Defines the current scope used to restore the JS context
  22756. */
  22757. scope?: any);
  22758. }
  22759. /**
  22760. * Represent a list of observers registered to multiple Observables object.
  22761. */
  22762. class MultiObserver<T> {
  22763. private _observers;
  22764. private _observables;
  22765. /**
  22766. * Release associated resources
  22767. */
  22768. dispose(): void;
  22769. /**
  22770. * Raise a callback when one of the observable will notify
  22771. * @param observables defines a list of observables to watch
  22772. * @param callback defines the callback to call on notification
  22773. * @param mask defines the mask used to filter notifications
  22774. * @param scope defines the current scope used to restore the JS context
  22775. * @returns the new MultiObserver
  22776. */
  22777. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  22778. }
  22779. /**
  22780. * The Observable class is a simple implementation of the Observable pattern.
  22781. *
  22782. * 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.
  22783. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  22784. * 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).
  22785. * 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.
  22786. */
  22787. class Observable<T> {
  22788. private _observers;
  22789. private _eventState;
  22790. private _onObserverAdded;
  22791. /**
  22792. * Creates a new observable
  22793. * @param onObserverAdded defines a callback to call when a new observer is added
  22794. */
  22795. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  22796. /**
  22797. * Create a new Observer with the specified callback
  22798. * @param callback the callback that will be executed for that Observer
  22799. * @param mask the mask used to filter observers
  22800. * @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.
  22801. * @param scope optional scope for the callback to be called from
  22802. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  22803. * @returns the new observer created for the callback
  22804. */
  22805. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  22806. /**
  22807. * Remove an Observer from the Observable object
  22808. * @param observer the instance of the Observer to remove
  22809. * @returns false if it doesn't belong to this Observable
  22810. */
  22811. remove(observer: Nullable<Observer<T>>): boolean;
  22812. /**
  22813. * Remove a callback from the Observable object
  22814. * @param callback the callback to remove
  22815. * @param scope optional scope. If used only the callbacks with this scope will be removed
  22816. * @returns false if it doesn't belong to this Observable
  22817. */
  22818. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  22819. private _deferUnregister(observer);
  22820. /**
  22821. * Notify all Observers by calling their respective callback with the given data
  22822. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  22823. * @param eventData defines the data to send to all observers
  22824. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  22825. * @param target defines the original target of the state
  22826. * @param currentTarget defines the current target of the state
  22827. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  22828. */
  22829. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  22830. /**
  22831. * Calling this will execute each callback, expecting it to be a promise or return a value.
  22832. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  22833. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  22834. * and it is crucial that all callbacks will be executed.
  22835. * The order of the callbacks is kept, callbacks are not executed parallel.
  22836. *
  22837. * @param eventData The data to be sent to each callback
  22838. * @param mask is used to filter observers defaults to -1
  22839. * @param target defines the callback target (see EventState)
  22840. * @param currentTarget defines he current object in the bubbling phase
  22841. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  22842. */
  22843. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  22844. /**
  22845. * Notify a specific observer
  22846. * @param observer defines the observer to notify
  22847. * @param eventData defines the data to be sent to each callback
  22848. * @param mask is used to filter observers defaults to -1
  22849. */
  22850. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  22851. /**
  22852. * Gets a boolean indicating if the observable has at least one observer
  22853. * @returns true is the Observable has at least one Observer registered
  22854. */
  22855. hasObservers(): boolean;
  22856. /**
  22857. * Clear the list of observers
  22858. */
  22859. clear(): void;
  22860. /**
  22861. * Clone the current observable
  22862. * @returns a new observable
  22863. */
  22864. clone(): Observable<T>;
  22865. /**
  22866. * Does this observable handles observer registered with a given mask
  22867. * @param mask defines the mask to be tested
  22868. * @return whether or not one observer registered with the given mask is handeled
  22869. **/
  22870. hasSpecificMask(mask?: number): boolean;
  22871. }
  22872. }
  22873. declare module BABYLON {
  22874. /**
  22875. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  22876. */
  22877. class PerformanceMonitor {
  22878. private _enabled;
  22879. private _rollingFrameTime;
  22880. private _lastFrameTimeMs;
  22881. /**
  22882. * constructor
  22883. * @param frameSampleSize The number of samples required to saturate the sliding window
  22884. */
  22885. constructor(frameSampleSize?: number);
  22886. /**
  22887. * Samples current frame
  22888. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  22889. */
  22890. sampleFrame(timeMs?: number): void;
  22891. /**
  22892. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  22893. * @return Average frame time in milliseconds
  22894. */
  22895. readonly averageFrameTime: number;
  22896. /**
  22897. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  22898. * @return Frame time variance in milliseconds squared
  22899. */
  22900. readonly averageFrameTimeVariance: number;
  22901. /**
  22902. * Returns the frame time of the most recent frame
  22903. * @return Frame time in milliseconds
  22904. */
  22905. readonly instantaneousFrameTime: number;
  22906. /**
  22907. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  22908. * @return Framerate in frames per second
  22909. */
  22910. readonly averageFPS: number;
  22911. /**
  22912. * Returns the average framerate in frames per second using the most recent frame time
  22913. * @return Framerate in frames per second
  22914. */
  22915. readonly instantaneousFPS: number;
  22916. /**
  22917. * Returns true if enough samples have been taken to completely fill the sliding window
  22918. * @return true if saturated
  22919. */
  22920. readonly isSaturated: boolean;
  22921. /**
  22922. * Enables contributions to the sliding window sample set
  22923. */
  22924. enable(): void;
  22925. /**
  22926. * Disables contributions to the sliding window sample set
  22927. * Samples will not be interpolated over the disabled period
  22928. */
  22929. disable(): void;
  22930. /**
  22931. * Returns true if sampling is enabled
  22932. * @return true if enabled
  22933. */
  22934. readonly isEnabled: boolean;
  22935. /**
  22936. * Resets performance monitor
  22937. */
  22938. reset(): void;
  22939. }
  22940. /**
  22941. * RollingAverage
  22942. *
  22943. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  22944. */
  22945. class RollingAverage {
  22946. /**
  22947. * Current average
  22948. */
  22949. average: number;
  22950. /**
  22951. * Current variance
  22952. */
  22953. variance: number;
  22954. protected _samples: Array<number>;
  22955. protected _sampleCount: number;
  22956. protected _pos: number;
  22957. protected _m2: number;
  22958. /**
  22959. * constructor
  22960. * @param length The number of samples required to saturate the sliding window
  22961. */
  22962. constructor(length: number);
  22963. /**
  22964. * Adds a sample to the sample set
  22965. * @param v The sample value
  22966. */
  22967. add(v: number): void;
  22968. /**
  22969. * Returns previously added values or null if outside of history or outside the sliding window domain
  22970. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  22971. * @return Value previously recorded with add() or null if outside of range
  22972. */
  22973. history(i: number): number;
  22974. /**
  22975. * Returns true if enough samples have been taken to completely fill the sliding window
  22976. * @return true if sample-set saturated
  22977. */
  22978. isSaturated(): boolean;
  22979. /**
  22980. * Resets the rolling average (equivalent to 0 samples taken so far)
  22981. */
  22982. reset(): void;
  22983. /**
  22984. * Wraps a value around the sample range boundaries
  22985. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  22986. * @return Wrapped position in sample range
  22987. */
  22988. protected _wrapPosition(i: number): number;
  22989. }
  22990. }
  22991. declare module BABYLON {
  22992. /**
  22993. * Helper class that provides a small promise polyfill
  22994. */
  22995. class PromisePolyfill {
  22996. /**
  22997. * Static function used to check if the polyfill is required
  22998. * If this is the case then the function will inject the polyfill to window.Promise
  22999. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  23000. */
  23001. static Apply(force?: boolean): void;
  23002. }
  23003. }
  23004. declare module BABYLON {
  23005. /**
  23006. * Defines the root class used to create scene optimization to use with SceneOptimizer
  23007. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  23008. */
  23009. class SceneOptimization {
  23010. /**
  23011. * Defines the priority of this optimization (0 by default which means first in the list)
  23012. */
  23013. priority: number;
  23014. /**
  23015. * Gets a string describing the action executed by the current optimization
  23016. * @returns description string
  23017. */
  23018. getDescription(): string;
  23019. /**
  23020. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  23021. * @param scene defines the current scene where to apply this optimization
  23022. * @param optimizer defines the current optimizer
  23023. * @returns true if everything that can be done was applied
  23024. */
  23025. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  23026. /**
  23027. * Creates the SceneOptimization object
  23028. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  23029. * @param desc defines the description associated with the optimization
  23030. */
  23031. constructor(
  23032. /**
  23033. * Defines the priority of this optimization (0 by default which means first in the list)
  23034. */
  23035. priority?: number);
  23036. }
  23037. /**
  23038. * Defines an optimization used to reduce the size of render target textures
  23039. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  23040. */
  23041. class TextureOptimization extends SceneOptimization {
  23042. /**
  23043. * Defines the priority of this optimization (0 by default which means first in the list)
  23044. */
  23045. priority: number;
  23046. /**
  23047. * 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
  23048. */
  23049. maximumSize: number;
  23050. /**
  23051. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  23052. */
  23053. step: number;
  23054. /**
  23055. * Gets a string describing the action executed by the current optimization
  23056. * @returns description string
  23057. */
  23058. getDescription(): string;
  23059. /**
  23060. * Creates the TextureOptimization object
  23061. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  23062. * @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
  23063. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  23064. */
  23065. constructor(
  23066. /**
  23067. * Defines the priority of this optimization (0 by default which means first in the list)
  23068. */
  23069. priority?: number,
  23070. /**
  23071. * 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
  23072. */
  23073. maximumSize?: number,
  23074. /**
  23075. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  23076. */
  23077. step?: number);
  23078. /**
  23079. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  23080. * @param scene defines the current scene where to apply this optimization
  23081. * @param optimizer defines the current optimizer
  23082. * @returns true if everything that can be done was applied
  23083. */
  23084. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  23085. }
  23086. /**
  23087. * Defines an optimization used to increase or decrease the rendering resolution
  23088. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  23089. */
  23090. class HardwareScalingOptimization extends SceneOptimization {
  23091. /**
  23092. * Defines the priority of this optimization (0 by default which means first in the list)
  23093. */
  23094. priority: number;
  23095. /**
  23096. * Defines the maximum scale to use (2 by default)
  23097. */
  23098. maximumScale: number;
  23099. /**
  23100. * Defines the step to use between two passes (0.5 by default)
  23101. */
  23102. step: number;
  23103. private _currentScale;
  23104. private _directionOffset;
  23105. /**
  23106. * Gets a string describing the action executed by the current optimization
  23107. * @return description string
  23108. */
  23109. getDescription(): string;
  23110. /**
  23111. * Creates the HardwareScalingOptimization object
  23112. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  23113. * @param maximumScale defines the maximum scale to use (2 by default)
  23114. * @param step defines the step to use between two passes (0.5 by default)
  23115. */
  23116. constructor(
  23117. /**
  23118. * Defines the priority of this optimization (0 by default which means first in the list)
  23119. */
  23120. priority?: number,
  23121. /**
  23122. * Defines the maximum scale to use (2 by default)
  23123. */
  23124. maximumScale?: number,
  23125. /**
  23126. * Defines the step to use between two passes (0.5 by default)
  23127. */
  23128. step?: number);
  23129. /**
  23130. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  23131. * @param scene defines the current scene where to apply this optimization
  23132. * @param optimizer defines the current optimizer
  23133. * @returns true if everything that can be done was applied
  23134. */
  23135. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  23136. }
  23137. /**
  23138. * Defines an optimization used to remove shadows
  23139. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  23140. */
  23141. class ShadowsOptimization extends SceneOptimization {
  23142. /**
  23143. * Gets a string describing the action executed by the current optimization
  23144. * @return description string
  23145. */
  23146. getDescription(): string;
  23147. /**
  23148. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  23149. * @param scene defines the current scene where to apply this optimization
  23150. * @param optimizer defines the current optimizer
  23151. * @returns true if everything that can be done was applied
  23152. */
  23153. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  23154. }
  23155. /**
  23156. * Defines an optimization used to turn post-processes off
  23157. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  23158. */
  23159. class PostProcessesOptimization extends SceneOptimization {
  23160. /**
  23161. * Gets a string describing the action executed by the current optimization
  23162. * @return description string
  23163. */
  23164. getDescription(): string;
  23165. /**
  23166. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  23167. * @param scene defines the current scene where to apply this optimization
  23168. * @param optimizer defines the current optimizer
  23169. * @returns true if everything that can be done was applied
  23170. */
  23171. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  23172. }
  23173. /**
  23174. * Defines an optimization used to turn lens flares off
  23175. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  23176. */
  23177. class LensFlaresOptimization extends SceneOptimization {
  23178. /**
  23179. * Gets a string describing the action executed by the current optimization
  23180. * @return description string
  23181. */
  23182. getDescription(): string;
  23183. /**
  23184. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  23185. * @param scene defines the current scene where to apply this optimization
  23186. * @param optimizer defines the current optimizer
  23187. * @returns true if everything that can be done was applied
  23188. */
  23189. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  23190. }
  23191. /**
  23192. * Defines an optimization based on user defined callback.
  23193. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  23194. */
  23195. class CustomOptimization extends SceneOptimization {
  23196. /**
  23197. * Callback called to apply the custom optimization.
  23198. */
  23199. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  23200. /**
  23201. * Callback called to get custom description
  23202. */
  23203. onGetDescription: () => string;
  23204. /**
  23205. * Gets a string describing the action executed by the current optimization
  23206. * @returns description string
  23207. */
  23208. getDescription(): string;
  23209. /**
  23210. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  23211. * @param scene defines the current scene where to apply this optimization
  23212. * @param optimizer defines the current optimizer
  23213. * @returns true if everything that can be done was applied
  23214. */
  23215. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  23216. }
  23217. /**
  23218. * Defines an optimization used to turn particles off
  23219. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  23220. */
  23221. class ParticlesOptimization extends SceneOptimization {
  23222. /**
  23223. * Gets a string describing the action executed by the current optimization
  23224. * @return description string
  23225. */
  23226. getDescription(): string;
  23227. /**
  23228. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  23229. * @param scene defines the current scene where to apply this optimization
  23230. * @param optimizer defines the current optimizer
  23231. * @returns true if everything that can be done was applied
  23232. */
  23233. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  23234. }
  23235. /**
  23236. * Defines an optimization used to turn render targets off
  23237. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  23238. */
  23239. class RenderTargetsOptimization extends SceneOptimization {
  23240. /**
  23241. * Gets a string describing the action executed by the current optimization
  23242. * @return description string
  23243. */
  23244. getDescription(): string;
  23245. /**
  23246. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  23247. * @param scene defines the current scene where to apply this optimization
  23248. * @param optimizer defines the current optimizer
  23249. * @returns true if everything that can be done was applied
  23250. */
  23251. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  23252. }
  23253. /**
  23254. * Defines an optimization used to merge meshes with compatible materials
  23255. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  23256. */
  23257. class MergeMeshesOptimization extends SceneOptimization {
  23258. private static _UpdateSelectionTree;
  23259. /**
  23260. * Gets or sets a boolean which defines if optimization octree has to be updated
  23261. */
  23262. /**
  23263. * Gets or sets a boolean which defines if optimization octree has to be updated
  23264. */
  23265. static UpdateSelectionTree: boolean;
  23266. /**
  23267. * Gets a string describing the action executed by the current optimization
  23268. * @return description string
  23269. */
  23270. getDescription(): string;
  23271. private _canBeMerged;
  23272. /**
  23273. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  23274. * @param scene defines the current scene where to apply this optimization
  23275. * @param optimizer defines the current optimizer
  23276. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  23277. * @returns true if everything that can be done was applied
  23278. */
  23279. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  23280. }
  23281. /**
  23282. * Defines a list of options used by SceneOptimizer
  23283. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  23284. */
  23285. class SceneOptimizerOptions {
  23286. /**
  23287. * Defines the target frame rate to reach (60 by default)
  23288. */
  23289. targetFrameRate: number;
  23290. /**
  23291. * Defines the interval between two checkes (2000ms by default)
  23292. */
  23293. trackerDuration: number;
  23294. /**
  23295. * Gets the list of optimizations to apply
  23296. */
  23297. optimizations: SceneOptimization[];
  23298. /**
  23299. * Creates a new list of options used by SceneOptimizer
  23300. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  23301. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  23302. */
  23303. constructor(
  23304. /**
  23305. * Defines the target frame rate to reach (60 by default)
  23306. */
  23307. targetFrameRate?: number,
  23308. /**
  23309. * Defines the interval between two checkes (2000ms by default)
  23310. */
  23311. trackerDuration?: number);
  23312. /**
  23313. * Add a new optimization
  23314. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  23315. * @returns the current SceneOptimizerOptions
  23316. */
  23317. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  23318. /**
  23319. * Add a new custom optimization
  23320. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  23321. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  23322. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  23323. * @returns the current SceneOptimizerOptions
  23324. */
  23325. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  23326. /**
  23327. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  23328. * @param targetFrameRate defines the target frame rate (60 by default)
  23329. * @returns a SceneOptimizerOptions object
  23330. */
  23331. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  23332. /**
  23333. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  23334. * @param targetFrameRate defines the target frame rate (60 by default)
  23335. * @returns a SceneOptimizerOptions object
  23336. */
  23337. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  23338. /**
  23339. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  23340. * @param targetFrameRate defines the target frame rate (60 by default)
  23341. * @returns a SceneOptimizerOptions object
  23342. */
  23343. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  23344. }
  23345. /**
  23346. * Class used to run optimizations in order to reach a target frame rate
  23347. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  23348. */
  23349. class SceneOptimizer implements IDisposable {
  23350. private _isRunning;
  23351. private _options;
  23352. private _scene;
  23353. private _currentPriorityLevel;
  23354. private _targetFrameRate;
  23355. private _trackerDuration;
  23356. private _currentFrameRate;
  23357. private _sceneDisposeObserver;
  23358. private _improvementMode;
  23359. /**
  23360. * Defines an observable called when the optimizer reaches the target frame rate
  23361. */
  23362. onSuccessObservable: Observable<SceneOptimizer>;
  23363. /**
  23364. * Defines an observable called when the optimizer enables an optimization
  23365. */
  23366. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  23367. /**
  23368. * Defines an observable called when the optimizer is not able to reach the target frame rate
  23369. */
  23370. onFailureObservable: Observable<SceneOptimizer>;
  23371. /**
  23372. * Gets a boolean indicating if the optimizer is in improvement mode
  23373. */
  23374. readonly isInImprovementMode: boolean;
  23375. /**
  23376. * Gets the current priority level (0 at start)
  23377. */
  23378. readonly currentPriorityLevel: number;
  23379. /**
  23380. * Gets the current frame rate checked by the SceneOptimizer
  23381. */
  23382. readonly currentFrameRate: number;
  23383. /**
  23384. * Gets or sets the current target frame rate (60 by default)
  23385. */
  23386. /**
  23387. * Gets or sets the current target frame rate (60 by default)
  23388. */
  23389. targetFrameRate: number;
  23390. /**
  23391. * Gets or sets the current interval between two checks (every 2000ms by default)
  23392. */
  23393. /**
  23394. * Gets or sets the current interval between two checks (every 2000ms by default)
  23395. */
  23396. trackerDuration: number;
  23397. /**
  23398. * Gets the list of active optimizations
  23399. */
  23400. readonly optimizations: SceneOptimization[];
  23401. /**
  23402. * Creates a new SceneOptimizer
  23403. * @param scene defines the scene to work on
  23404. * @param options defines the options to use with the SceneOptimizer
  23405. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  23406. * @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)
  23407. */
  23408. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  23409. /**
  23410. * Stops the current optimizer
  23411. */
  23412. stop(): void;
  23413. /**
  23414. * Reset the optimizer to initial step (current priority level = 0)
  23415. */
  23416. reset(): void;
  23417. /**
  23418. * Start the optimizer. By default it will try to reach a specific framerate
  23419. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  23420. */
  23421. start(): void;
  23422. private _checkCurrentState();
  23423. /**
  23424. * Release all resources
  23425. */
  23426. dispose(): void;
  23427. /**
  23428. * Helper function to create a SceneOptimizer with one single line of code
  23429. * @param scene defines the scene to work on
  23430. * @param options defines the options to use with the SceneOptimizer
  23431. * @param onSuccess defines a callback to call on success
  23432. * @param onFailure defines a callback to call on failure
  23433. * @returns the new SceneOptimizer object
  23434. */
  23435. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  23436. }
  23437. }
  23438. declare module BABYLON {
  23439. class SceneSerializer {
  23440. static ClearCache(): void;
  23441. static Serialize(scene: Scene): any;
  23442. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  23443. }
  23444. }
  23445. declare module BABYLON {
  23446. class SmartArray<T> {
  23447. data: Array<T>;
  23448. length: number;
  23449. protected _id: number;
  23450. [index: number]: T;
  23451. constructor(capacity: number);
  23452. push(value: T): void;
  23453. forEach(func: (content: T) => void): void;
  23454. sort(compareFn: (a: T, b: T) => number): void;
  23455. reset(): void;
  23456. dispose(): void;
  23457. concat(array: any): void;
  23458. indexOf(value: T): number;
  23459. contains(value: T): boolean;
  23460. private static _GlobalId;
  23461. }
  23462. class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  23463. private _duplicateId;
  23464. [index: number]: T;
  23465. push(value: T): void;
  23466. pushNoDuplicate(value: T): boolean;
  23467. reset(): void;
  23468. concatWithNoDuplicate(array: any): void;
  23469. }
  23470. }
  23471. declare module BABYLON {
  23472. /**
  23473. * This class implement a typical dictionary using a string as key and the generic type T as value.
  23474. * The underlying implementation relies on an associative array to ensure the best performances.
  23475. * The value can be anything including 'null' but except 'undefined'
  23476. */
  23477. class StringDictionary<T> {
  23478. /**
  23479. * This will clear this dictionary and copy the content from the 'source' one.
  23480. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  23481. * @param source the dictionary to take the content from and copy to this dictionary
  23482. */
  23483. copyFrom(source: StringDictionary<T>): void;
  23484. /**
  23485. * Get a value based from its key
  23486. * @param key the given key to get the matching value from
  23487. * @return the value if found, otherwise undefined is returned
  23488. */
  23489. get(key: string): T | undefined;
  23490. /**
  23491. * Get a value from its key or add it if it doesn't exist.
  23492. * This method will ensure you that a given key/data will be present in the dictionary.
  23493. * @param key the given key to get the matching value from
  23494. * @param factory the factory that will create the value if the key is not present in the dictionary.
  23495. * The factory will only be invoked if there's no data for the given key.
  23496. * @return the value corresponding to the key.
  23497. */
  23498. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  23499. /**
  23500. * Get a value from its key if present in the dictionary otherwise add it
  23501. * @param key the key to get the value from
  23502. * @param val if there's no such key/value pair in the dictionary add it with this value
  23503. * @return the value corresponding to the key
  23504. */
  23505. getOrAdd(key: string, val: T): T;
  23506. /**
  23507. * Check if there's a given key in the dictionary
  23508. * @param key the key to check for
  23509. * @return true if the key is present, false otherwise
  23510. */
  23511. contains(key: string): boolean;
  23512. /**
  23513. * Add a new key and its corresponding value
  23514. * @param key the key to add
  23515. * @param value the value corresponding to the key
  23516. * @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
  23517. */
  23518. add(key: string, value: T): boolean;
  23519. set(key: string, value: T): boolean;
  23520. /**
  23521. * Get the element of the given key and remove it from the dictionary
  23522. * @param key
  23523. */
  23524. getAndRemove(key: string): Nullable<T>;
  23525. /**
  23526. * Remove a key/value from the dictionary.
  23527. * @param key the key to remove
  23528. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  23529. */
  23530. remove(key: string): boolean;
  23531. /**
  23532. * Clear the whole content of the dictionary
  23533. */
  23534. clear(): void;
  23535. readonly count: number;
  23536. /**
  23537. * Execute a callback on each key/val of the dictionary.
  23538. * Note that you can remove any element in this dictionary in the callback implementation
  23539. * @param callback the callback to execute on a given key/value pair
  23540. */
  23541. forEach(callback: (key: string, val: T) => void): void;
  23542. /**
  23543. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  23544. * If the callback returns null or undefined the method will iterate to the next key/value pair
  23545. * Note that you can remove any element in this dictionary in the callback implementation
  23546. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  23547. */
  23548. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  23549. private _count;
  23550. private _data;
  23551. }
  23552. }
  23553. declare module BABYLON {
  23554. class Tags {
  23555. static EnableFor(obj: any): void;
  23556. static DisableFor(obj: any): void;
  23557. static HasTags(obj: any): boolean;
  23558. static GetTags(obj: any, asString?: boolean): any;
  23559. static AddTagsTo(obj: any, tagsString: string): void;
  23560. static _AddTagTo(obj: any, tag: string): void;
  23561. static RemoveTagsFrom(obj: any, tagsString: string): void;
  23562. static _RemoveTagFrom(obj: any, tag: string): void;
  23563. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  23564. }
  23565. }
  23566. declare module BABYLON {
  23567. class TextureTools {
  23568. /**
  23569. * Uses the GPU to create a copy texture rescaled at a given size
  23570. * @param texture Texture to copy from
  23571. * @param width Desired width
  23572. * @param height Desired height
  23573. * @return Generated texture
  23574. */
  23575. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  23576. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  23577. private static _environmentBRDFBase64Texture;
  23578. }
  23579. }
  23580. declare module BABYLON {
  23581. class TGATools {
  23582. private static _TYPE_INDEXED;
  23583. private static _TYPE_RGB;
  23584. private static _TYPE_GREY;
  23585. private static _TYPE_RLE_INDEXED;
  23586. private static _TYPE_RLE_RGB;
  23587. private static _TYPE_RLE_GREY;
  23588. private static _ORIGIN_MASK;
  23589. private static _ORIGIN_SHIFT;
  23590. private static _ORIGIN_BL;
  23591. private static _ORIGIN_BR;
  23592. private static _ORIGIN_UL;
  23593. private static _ORIGIN_UR;
  23594. static GetTGAHeader(data: Uint8Array): any;
  23595. static UploadContent(gl: WebGLRenderingContext, data: Uint8Array): void;
  23596. 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;
  23597. 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;
  23598. 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;
  23599. 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;
  23600. 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;
  23601. 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;
  23602. }
  23603. }
  23604. declare module BABYLON {
  23605. interface IAnimatable {
  23606. animations: Array<Animation>;
  23607. }
  23608. class LoadFileError extends Error {
  23609. request: XMLHttpRequest | undefined;
  23610. private static _setPrototypeOf;
  23611. constructor(message: string, request?: XMLHttpRequest | undefined);
  23612. }
  23613. class RetryStrategy {
  23614. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: XMLHttpRequest, retryIndex: number) => number;
  23615. }
  23616. interface IFileRequest {
  23617. /**
  23618. * Raised when the request is complete (success or error).
  23619. */
  23620. onCompleteObservable: Observable<IFileRequest>;
  23621. /**
  23622. * Aborts the request for a file.
  23623. */
  23624. abort: () => void;
  23625. }
  23626. class Tools {
  23627. static BaseUrl: string;
  23628. static DefaultRetryStrategy: (url: string, request: XMLHttpRequest, retryIndex: number) => number;
  23629. /**
  23630. * Default behaviour for cors in the application.
  23631. * It can be a string if the expected behavior is identical in the entire app.
  23632. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  23633. */
  23634. static CorsBehavior: string | ((url: string | string[]) => string);
  23635. static UseFallbackTexture: boolean;
  23636. /**
  23637. * Use this object to register external classes like custom textures or material
  23638. * to allow the laoders to instantiate them
  23639. */
  23640. static RegisteredExternalClasses: {
  23641. [key: string]: Object;
  23642. };
  23643. static fallbackTexture: string;
  23644. /**
  23645. * Interpolates between a and b via alpha
  23646. * @param a The lower value (returned when alpha = 0)
  23647. * @param b The upper value (returned when alpha = 1)
  23648. * @param alpha The interpolation-factor
  23649. * @return The mixed value
  23650. */
  23651. static Mix(a: number, b: number, alpha: number): number;
  23652. static Instantiate(className: string): any;
  23653. /**
  23654. * Provides a slice function that will work even on IE
  23655. * @param data defines the array to slice
  23656. * @returns the new sliced array
  23657. */
  23658. static Slice(data: FloatArray): FloatArray;
  23659. static SetImmediate(action: () => void): void;
  23660. static IsExponentOfTwo(value: number): boolean;
  23661. /**
  23662. * Find the next highest power of two.
  23663. * @param x Number to start search from.
  23664. * @return Next highest power of two.
  23665. */
  23666. static CeilingPOT(x: number): number;
  23667. /**
  23668. * Find the next lowest power of two.
  23669. * @param x Number to start search from.
  23670. * @return Next lowest power of two.
  23671. */
  23672. static FloorPOT(x: number): number;
  23673. /**
  23674. * Find the nearest power of two.
  23675. * @param x Number to start search from.
  23676. * @return Next nearest power of two.
  23677. */
  23678. static NearestPOT(x: number): number;
  23679. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  23680. static GetFilename(path: string): string;
  23681. /**
  23682. * Extracts the "folder" part of a path (everything before the filename).
  23683. * @param uri The URI to extract the info from
  23684. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  23685. * @returns The "folder" part of the path
  23686. */
  23687. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  23688. static GetDOMTextContent(element: HTMLElement): string;
  23689. static ToDegrees(angle: number): number;
  23690. static ToRadians(angle: number): number;
  23691. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  23692. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  23693. minimum: Vector3;
  23694. maximum: Vector3;
  23695. };
  23696. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  23697. minimum: Vector3;
  23698. maximum: Vector3;
  23699. };
  23700. static Vector2ArrayFeeder(array: Array<Vector2> | Float32Array): (i: number) => Nullable<Vector2>;
  23701. static ExtractMinAndMaxVector2(feeder: (index: number) => Vector2, bias?: Nullable<Vector2>): {
  23702. minimum: Vector2;
  23703. maximum: Vector2;
  23704. };
  23705. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  23706. static GetPointerPrefix(): string;
  23707. /**
  23708. * @param func - the function to be called
  23709. * @param requester - the object that will request the next frame. Falls back to window.
  23710. */
  23711. static QueueNewFrame(func: () => void, requester?: any): number;
  23712. static RequestFullscreen(element: HTMLElement): void;
  23713. static ExitFullscreen(): void;
  23714. static SetCorsBehavior(url: string | string[], element: {
  23715. crossOrigin: string | null;
  23716. }): void;
  23717. static CleanUrl(url: string): string;
  23718. static PreprocessUrl: (url: string) => string;
  23719. static LoadImage(url: any, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, database: Nullable<Database>): HTMLImageElement;
  23720. 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;
  23721. /**
  23722. * Load a script (identified by an url). When the url returns, the
  23723. * content of this file is added into a new script element, attached to the DOM (body element)
  23724. */
  23725. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void): void;
  23726. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (this: MSBaseReader, ev: ProgressEvent) => any): IFileRequest;
  23727. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (this: MSBaseReader, ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  23728. static FileAsURL(content: string): string;
  23729. static Format(value: number, decimals?: number): string;
  23730. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  23731. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  23732. static IsEmpty(obj: any): boolean;
  23733. static RegisterTopRootEvents(events: {
  23734. name: string;
  23735. handler: Nullable<(e: FocusEvent) => any>;
  23736. }[]): void;
  23737. static UnregisterTopRootEvents(events: {
  23738. name: string;
  23739. handler: Nullable<(e: FocusEvent) => any>;
  23740. }[]): void;
  23741. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  23742. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  23743. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  23744. /**
  23745. * Generates an image screenshot from the specified camera.
  23746. *
  23747. * @param engine The engine to use for rendering
  23748. * @param camera The camera to use for rendering
  23749. * @param size This parameter can be set to a single number or to an object with the
  23750. * following (optional) properties: precision, width, height. If a single number is passed,
  23751. * it will be used for both width and height. If an object is passed, the screenshot size
  23752. * will be derived from the parameters. The precision property is a multiplier allowing
  23753. * rendering at a higher or lower resolution.
  23754. * @param successCallback The callback receives a single parameter which contains the
  23755. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  23756. * src parameter of an <img> to display it.
  23757. * @param mimeType The MIME type of the screenshot image (default: image/png).
  23758. * Check your browser for supported MIME types.
  23759. * @param samples Texture samples (default: 1)
  23760. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  23761. * @param fileName A name for for the downloaded file.
  23762. * @constructor
  23763. */
  23764. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  23765. static ValidateXHRData(xhr: XMLHttpRequest, dataType?: number): boolean;
  23766. /**
  23767. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  23768. * Be aware Math.random() could cause collisions, but:
  23769. * "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"
  23770. */
  23771. static RandomId(): string;
  23772. /**
  23773. * Test if the given uri is a base64 string.
  23774. * @param uri The uri to test
  23775. * @return True if the uri is a base64 string or false otherwise.
  23776. */
  23777. static IsBase64(uri: string): boolean;
  23778. /**
  23779. * Decode the given base64 uri.
  23780. * @param uri The uri to decode
  23781. * @return The decoded base64 data.
  23782. */
  23783. static DecodeBase64(uri: string): ArrayBuffer;
  23784. private static _NoneLogLevel;
  23785. private static _MessageLogLevel;
  23786. private static _WarningLogLevel;
  23787. private static _ErrorLogLevel;
  23788. private static _LogCache;
  23789. static errorsCount: number;
  23790. static OnNewCacheEntry: (entry: string) => void;
  23791. static readonly NoneLogLevel: number;
  23792. static readonly MessageLogLevel: number;
  23793. static readonly WarningLogLevel: number;
  23794. static readonly ErrorLogLevel: number;
  23795. static readonly AllLogLevel: number;
  23796. private static _AddLogEntry(entry);
  23797. private static _FormatMessage(message);
  23798. private static _LogDisabled(message);
  23799. private static _LogEnabled(message);
  23800. private static _WarnDisabled(message);
  23801. private static _WarnEnabled(message);
  23802. private static _ErrorDisabled(message);
  23803. private static _ErrorEnabled(message);
  23804. static Log: (message: string) => void;
  23805. static Warn: (message: string) => void;
  23806. static Error: (message: string) => void;
  23807. static readonly LogCache: string;
  23808. static ClearLogCache(): void;
  23809. static LogLevels: number;
  23810. static IsWindowObjectExist(): boolean;
  23811. private static _PerformanceNoneLogLevel;
  23812. private static _PerformanceUserMarkLogLevel;
  23813. private static _PerformanceConsoleLogLevel;
  23814. private static _performance;
  23815. static readonly PerformanceNoneLogLevel: number;
  23816. static readonly PerformanceUserMarkLogLevel: number;
  23817. static readonly PerformanceConsoleLogLevel: number;
  23818. static PerformanceLogLevel: number;
  23819. static _StartPerformanceCounterDisabled(counterName: string, condition?: boolean): void;
  23820. static _EndPerformanceCounterDisabled(counterName: string, condition?: boolean): void;
  23821. static _StartUserMark(counterName: string, condition?: boolean): void;
  23822. static _EndUserMark(counterName: string, condition?: boolean): void;
  23823. static _StartPerformanceConsole(counterName: string, condition?: boolean): void;
  23824. static _EndPerformanceConsole(counterName: string, condition?: boolean): void;
  23825. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  23826. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  23827. static readonly Now: number;
  23828. /**
  23829. * This method will return the name of the class used to create the instance of the given object.
  23830. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  23831. * @param object the object to get the class name from
  23832. * @return the name of the class, will be "object" for a custom data type not using the @className decorator
  23833. */
  23834. static GetClassName(object: any, isType?: boolean): string;
  23835. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  23836. /**
  23837. * This method will return the name of the full name of the class, including its owning module (if any).
  23838. * 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).
  23839. * @param object the object to get the class name from
  23840. * @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.
  23841. */
  23842. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  23843. /**
  23844. * 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.
  23845. * @param array
  23846. */
  23847. static arrayOrStringFeeder(array: any): (i: number) => number;
  23848. /**
  23849. * Compute the hashCode of a stream of number
  23850. * To compute the HashCode on a string or an Array of data types implementing the getHashCode() method, use the arrayOrStringFeeder method.
  23851. * @param feeder a callback that will be called until it returns null, each valid returned values will be used to compute the hash code.
  23852. * @return the hash code computed
  23853. */
  23854. static hashCodeFromStream(feeder: (index: number) => number): number;
  23855. /**
  23856. * Returns a promise that resolves after the given amount of time.
  23857. * @param delay Number of milliseconds to delay
  23858. * @returns Promise that resolves after the given amount of time
  23859. */
  23860. static DelayAsync(delay: number): Promise<void>;
  23861. }
  23862. /**
  23863. * This class is used to track a performance counter which is number based.
  23864. * The user has access to many properties which give statistics of different nature
  23865. *
  23866. * The implementer can track two kinds of Performance Counter: time and count
  23867. * 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.
  23868. * 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.
  23869. */
  23870. class PerfCounter {
  23871. static Enabled: boolean;
  23872. /**
  23873. * Returns the smallest value ever
  23874. */
  23875. readonly min: number;
  23876. /**
  23877. * Returns the biggest value ever
  23878. */
  23879. readonly max: number;
  23880. /**
  23881. * Returns the average value since the performance counter is running
  23882. */
  23883. readonly average: number;
  23884. /**
  23885. * Returns the average value of the last second the counter was monitored
  23886. */
  23887. readonly lastSecAverage: number;
  23888. /**
  23889. * Returns the current value
  23890. */
  23891. readonly current: number;
  23892. readonly total: number;
  23893. readonly count: number;
  23894. constructor();
  23895. /**
  23896. * Call this method to start monitoring a new frame.
  23897. * 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.
  23898. */
  23899. fetchNewFrame(): void;
  23900. /**
  23901. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  23902. * @param newCount the count value to add to the monitored count
  23903. * @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.
  23904. */
  23905. addCount(newCount: number, fetchResult: boolean): void;
  23906. /**
  23907. * Start monitoring this performance counter
  23908. */
  23909. beginMonitoring(): void;
  23910. /**
  23911. * Compute the time lapsed since the previous beginMonitoring() call.
  23912. * @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
  23913. */
  23914. endMonitoring(newFrame?: boolean): void;
  23915. private _fetchResult();
  23916. private _startMonitoringTime;
  23917. private _min;
  23918. private _max;
  23919. private _average;
  23920. private _current;
  23921. private _totalValueCount;
  23922. private _totalAccumulated;
  23923. private _lastSecAverage;
  23924. private _lastSecAccumulated;
  23925. private _lastSecTime;
  23926. private _lastSecValueCount;
  23927. }
  23928. /**
  23929. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  23930. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  23931. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  23932. * @param name The name of the class, case should be preserved
  23933. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  23934. */
  23935. function className(name: string, module?: string): (target: Object) => void;
  23936. /**
  23937. * An implementation of a loop for asynchronous functions.
  23938. */
  23939. class AsyncLoop {
  23940. iterations: number;
  23941. private _fn;
  23942. private _successCallback;
  23943. index: number;
  23944. private _done;
  23945. /**
  23946. * Constroctor.
  23947. * @param iterations the number of iterations.
  23948. * @param _fn the function to run each iteration
  23949. * @param _successCallback the callback that will be called upon succesful execution
  23950. * @param offset starting offset.
  23951. */
  23952. constructor(iterations: number, _fn: (asyncLoop: AsyncLoop) => void, _successCallback: () => void, offset?: number);
  23953. /**
  23954. * Execute the next iteration. Must be called after the last iteration was finished.
  23955. */
  23956. executeNext(): void;
  23957. /**
  23958. * Break the loop and run the success callback.
  23959. */
  23960. breakLoop(): void;
  23961. /**
  23962. * Helper function
  23963. */
  23964. static Run(iterations: number, _fn: (asyncLoop: AsyncLoop) => void, _successCallback: () => void, offset?: number): AsyncLoop;
  23965. /**
  23966. * A for-loop that will run a given number of iterations synchronous and the rest async.
  23967. * @param iterations total number of iterations
  23968. * @param syncedIterations number of synchronous iterations in each async iteration.
  23969. * @param fn the function to call each iteration.
  23970. * @param callback a success call back that will be called when iterating stops.
  23971. * @param breakFunction a break condition (optional)
  23972. * @param timeout timeout settings for the setTimeout function. default - 0.
  23973. * @constructor
  23974. */
  23975. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): void;
  23976. }
  23977. }
  23978. declare module BABYLON {
  23979. enum JoystickAxis {
  23980. X = 0,
  23981. Y = 1,
  23982. Z = 2,
  23983. }
  23984. class VirtualJoystick {
  23985. reverseLeftRight: boolean;
  23986. reverseUpDown: boolean;
  23987. deltaPosition: Vector3;
  23988. pressed: boolean;
  23989. private static _globalJoystickIndex;
  23990. private static vjCanvas;
  23991. private static vjCanvasContext;
  23992. private static vjCanvasWidth;
  23993. private static vjCanvasHeight;
  23994. private static halfWidth;
  23995. private _action;
  23996. private _axisTargetedByLeftAndRight;
  23997. private _axisTargetedByUpAndDown;
  23998. private _joystickSensibility;
  23999. private _inversedSensibility;
  24000. private _joystickPointerID;
  24001. private _joystickColor;
  24002. private _joystickPointerPos;
  24003. private _joystickPreviousPointerPos;
  24004. private _joystickPointerStartPos;
  24005. private _deltaJoystickVector;
  24006. private _leftJoystick;
  24007. private _touches;
  24008. private _onPointerDownHandlerRef;
  24009. private _onPointerMoveHandlerRef;
  24010. private _onPointerUpHandlerRef;
  24011. private _onResize;
  24012. constructor(leftJoystick?: boolean);
  24013. setJoystickSensibility(newJoystickSensibility: number): void;
  24014. private _onPointerDown(e);
  24015. private _onPointerMove(e);
  24016. private _onPointerUp(e);
  24017. /**
  24018. * Change the color of the virtual joystick
  24019. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  24020. */
  24021. setJoystickColor(newColor: string): void;
  24022. setActionOnTouch(action: () => any): void;
  24023. setAxisForLeftRight(axis: JoystickAxis): void;
  24024. setAxisForUpDown(axis: JoystickAxis): void;
  24025. private _drawVirtualJoystick();
  24026. releaseCanvas(): void;
  24027. }
  24028. }
  24029. declare module BABYLON {
  24030. /**
  24031. * Helper class to push actions to a pool of workers.
  24032. */
  24033. class WorkerPool implements IDisposable {
  24034. private _workerInfos;
  24035. private _pendingActions;
  24036. /**
  24037. * Constructor
  24038. * @param workers Array of workers to use for actions
  24039. */
  24040. constructor(workers: Array<Worker>);
  24041. /**
  24042. * Terminates all workers and clears any pending actions.
  24043. */
  24044. dispose(): void;
  24045. /**
  24046. * Pushes an action to the worker pool. If all the workers are active, the action will be
  24047. * pended until a worker has completed its action.
  24048. * @param action The action to perform. Call onComplete when the action is complete.
  24049. */
  24050. push(action: (worker: Worker, onComplete: () => void) => void): void;
  24051. private _execute(workerInfo, action);
  24052. }
  24053. }
  24054. declare module BABYLON {
  24055. class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  24056. readonly name: string;
  24057. private _zoomStopsAnimation;
  24058. private _idleRotationSpeed;
  24059. private _idleRotationWaitTime;
  24060. private _idleRotationSpinupTime;
  24061. /**
  24062. * Gets the flag that indicates if user zooming should stop animation.
  24063. */
  24064. /**
  24065. * Sets the flag that indicates if user zooming should stop animation.
  24066. */
  24067. zoomStopsAnimation: boolean;
  24068. /**
  24069. * Gets the default speed at which the camera rotates around the model.
  24070. */
  24071. /**
  24072. * Sets the default speed at which the camera rotates around the model.
  24073. */
  24074. idleRotationSpeed: number;
  24075. /**
  24076. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  24077. */
  24078. /**
  24079. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  24080. */
  24081. idleRotationWaitTime: number;
  24082. /**
  24083. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  24084. */
  24085. /**
  24086. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  24087. */
  24088. idleRotationSpinupTime: number;
  24089. /**
  24090. * Gets a value indicating if the camera is currently rotating because of this behavior
  24091. */
  24092. readonly rotationInProgress: boolean;
  24093. private _onPrePointerObservableObserver;
  24094. private _onAfterCheckInputsObserver;
  24095. private _attachedCamera;
  24096. private _isPointerDown;
  24097. private _lastFrameTime;
  24098. private _lastInteractionTime;
  24099. private _cameraRotationSpeed;
  24100. init(): void;
  24101. attach(camera: ArcRotateCamera): void;
  24102. detach(): void;
  24103. /**
  24104. * Returns true if user is scrolling.
  24105. * @return true if user is scrolling.
  24106. */
  24107. private _userIsZooming();
  24108. private _lastFrameRadius;
  24109. private _shouldAnimationStopForInteraction();
  24110. /**
  24111. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  24112. */
  24113. private _applyUserInteraction();
  24114. private _userIsMoving();
  24115. }
  24116. }
  24117. declare module BABYLON {
  24118. /**
  24119. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  24120. */
  24121. class BouncingBehavior implements Behavior<ArcRotateCamera> {
  24122. readonly name: string;
  24123. /**
  24124. * The easing function used by animations
  24125. */
  24126. static EasingFunction: BackEase;
  24127. /**
  24128. * The easing mode used by animations
  24129. */
  24130. static EasingMode: number;
  24131. /**
  24132. * The duration of the animation, in milliseconds
  24133. */
  24134. transitionDuration: number;
  24135. /**
  24136. * Length of the distance animated by the transition when lower radius is reached
  24137. */
  24138. lowerRadiusTransitionRange: number;
  24139. /**
  24140. * Length of the distance animated by the transition when upper radius is reached
  24141. */
  24142. upperRadiusTransitionRange: number;
  24143. private _autoTransitionRange;
  24144. /**
  24145. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  24146. */
  24147. /**
  24148. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  24149. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  24150. */
  24151. autoTransitionRange: boolean;
  24152. private _attachedCamera;
  24153. private _onAfterCheckInputsObserver;
  24154. private _onMeshTargetChangedObserver;
  24155. init(): void;
  24156. attach(camera: ArcRotateCamera): void;
  24157. detach(): void;
  24158. private _radiusIsAnimating;
  24159. private _radiusBounceTransition;
  24160. private _animatables;
  24161. private _cachedWheelPrecision;
  24162. /**
  24163. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  24164. * @param radiusLimit The limit to check against.
  24165. * @return Bool to indicate if at limit.
  24166. */
  24167. private _isRadiusAtLimit(radiusLimit);
  24168. /**
  24169. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  24170. * @param radiusDelta The delta by which to animate to. Can be negative.
  24171. */
  24172. private _applyBoundRadiusAnimation(radiusDelta);
  24173. /**
  24174. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  24175. */
  24176. protected _clearAnimationLocks(): void;
  24177. /**
  24178. * Stops and removes all animations that have been applied to the camera
  24179. */
  24180. stopAllAnimations(): void;
  24181. }
  24182. }
  24183. declare module BABYLON {
  24184. class FramingBehavior implements Behavior<ArcRotateCamera> {
  24185. readonly name: string;
  24186. private _mode;
  24187. private _radiusScale;
  24188. private _positionScale;
  24189. private _defaultElevation;
  24190. private _elevationReturnTime;
  24191. private _elevationReturnWaitTime;
  24192. private _zoomStopsAnimation;
  24193. private _framingTime;
  24194. /**
  24195. * The easing function used by animations
  24196. */
  24197. static EasingFunction: ExponentialEase;
  24198. /**
  24199. * The easing mode used by animations
  24200. */
  24201. static EasingMode: number;
  24202. /**
  24203. * Gets current mode used by the behavior.
  24204. */
  24205. /**
  24206. * Sets the current mode used by the behavior
  24207. */
  24208. mode: number;
  24209. /**
  24210. * Gets the scale applied to the radius
  24211. */
  24212. /**
  24213. * Sets the scale applied to the radius (1 by default)
  24214. */
  24215. radiusScale: number;
  24216. /**
  24217. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  24218. */
  24219. /**
  24220. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  24221. */
  24222. positionScale: number;
  24223. /**
  24224. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  24225. * behaviour is triggered, in radians.
  24226. */
  24227. /**
  24228. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  24229. * behaviour is triggered, in radians.
  24230. */
  24231. defaultElevation: number;
  24232. /**
  24233. * Gets the time (in milliseconds) taken to return to the default beta position.
  24234. * Negative value indicates camera should not return to default.
  24235. */
  24236. /**
  24237. * Sets the time (in milliseconds) taken to return to the default beta position.
  24238. * Negative value indicates camera should not return to default.
  24239. */
  24240. elevationReturnTime: number;
  24241. /**
  24242. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  24243. */
  24244. /**
  24245. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  24246. */
  24247. elevationReturnWaitTime: number;
  24248. /**
  24249. * Gets the flag that indicates if user zooming should stop animation.
  24250. */
  24251. /**
  24252. * Sets the flag that indicates if user zooming should stop animation.
  24253. */
  24254. zoomStopsAnimation: boolean;
  24255. /**
  24256. * Gets the transition time when framing the mesh, in milliseconds
  24257. */
  24258. /**
  24259. * Sets the transition time when framing the mesh, in milliseconds
  24260. */
  24261. framingTime: number;
  24262. private _onPrePointerObservableObserver;
  24263. private _onAfterCheckInputsObserver;
  24264. private _onMeshTargetChangedObserver;
  24265. private _attachedCamera;
  24266. private _isPointerDown;
  24267. private _lastInteractionTime;
  24268. init(): void;
  24269. attach(camera: ArcRotateCamera): void;
  24270. detach(): void;
  24271. private _animatables;
  24272. private _betaIsAnimating;
  24273. private _betaTransition;
  24274. private _radiusTransition;
  24275. private _vectorTransition;
  24276. /**
  24277. * Targets the given mesh and updates zoom level accordingly.
  24278. * @param mesh The mesh to target.
  24279. * @param radius Optional. If a cached radius position already exists, overrides default.
  24280. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  24281. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  24282. * @param onAnimationEnd Callback triggered at the end of the framing animation
  24283. */
  24284. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  24285. /**
  24286. * Targets the given mesh with its children and updates zoom level accordingly.
  24287. * @param mesh The mesh to target.
  24288. * @param radius Optional. If a cached radius position already exists, overrides default.
  24289. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  24290. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  24291. * @param onAnimationEnd Callback triggered at the end of the framing animation
  24292. */
  24293. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  24294. /**
  24295. * Targets the given meshes with their children and updates zoom level accordingly.
  24296. * @param meshes The mesh to target.
  24297. * @param radius Optional. If a cached radius position already exists, overrides default.
  24298. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  24299. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  24300. * @param onAnimationEnd Callback triggered at the end of the framing animation
  24301. */
  24302. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  24303. /**
  24304. * Targets the given mesh and updates zoom level accordingly.
  24305. * @param mesh The mesh to target.
  24306. * @param radius Optional. If a cached radius position already exists, overrides default.
  24307. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  24308. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  24309. * @param onAnimationEnd Callback triggered at the end of the framing animation
  24310. */
  24311. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  24312. /**
  24313. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  24314. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  24315. * frustum width.
  24316. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  24317. * to fully enclose the mesh in the viewing frustum.
  24318. */
  24319. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  24320. /**
  24321. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  24322. * is automatically returned to its default position (expected to be above ground plane).
  24323. */
  24324. private _maintainCameraAboveGround();
  24325. /**
  24326. * Returns the frustum slope based on the canvas ratio and camera FOV
  24327. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  24328. */
  24329. private _getFrustumSlope();
  24330. /**
  24331. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  24332. */
  24333. private _clearAnimationLocks();
  24334. /**
  24335. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  24336. */
  24337. private _applyUserInteraction();
  24338. /**
  24339. * Stops and removes all animations that have been applied to the camera
  24340. */
  24341. stopAllAnimations(): void;
  24342. /**
  24343. * Gets a value indicating if the user is moving the camera
  24344. */
  24345. readonly isUserIsMoving: boolean;
  24346. /**
  24347. * The camera can move all the way towards the mesh.
  24348. */
  24349. static IgnoreBoundsSizeMode: number;
  24350. /**
  24351. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  24352. */
  24353. static FitFrustumSidesMode: number;
  24354. }
  24355. }
  24356. declare module BABYLON {
  24357. class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  24358. camera: ArcRotateCamera;
  24359. gamepad: Nullable<Gamepad>;
  24360. private _onGamepadConnectedObserver;
  24361. private _onGamepadDisconnectedObserver;
  24362. gamepadRotationSensibility: number;
  24363. gamepadMoveSensibility: number;
  24364. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  24365. detachControl(element: Nullable<HTMLElement>): void;
  24366. checkInputs(): void;
  24367. getClassName(): string;
  24368. getSimpleName(): string;
  24369. }
  24370. }
  24371. declare module BABYLON {
  24372. class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  24373. camera: ArcRotateCamera;
  24374. private _keys;
  24375. keysUp: number[];
  24376. keysDown: number[];
  24377. keysLeft: number[];
  24378. keysRight: number[];
  24379. keysReset: number[];
  24380. panningSensibility: number;
  24381. zoomingSensibility: number;
  24382. useAltToZoom: boolean;
  24383. private _ctrlPressed;
  24384. private _altPressed;
  24385. private _onCanvasBlurObserver;
  24386. private _onKeyboardObserver;
  24387. private _engine;
  24388. private _scene;
  24389. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  24390. detachControl(element: Nullable<HTMLElement>): void;
  24391. checkInputs(): void;
  24392. getClassName(): string;
  24393. getSimpleName(): string;
  24394. }
  24395. }
  24396. declare module BABYLON {
  24397. class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  24398. camera: ArcRotateCamera;
  24399. private _wheel;
  24400. private _observer;
  24401. wheelPrecision: number;
  24402. /**
  24403. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  24404. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  24405. */
  24406. wheelDeltaPercentage: number;
  24407. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  24408. detachControl(element: Nullable<HTMLElement>): void;
  24409. getClassName(): string;
  24410. getSimpleName(): string;
  24411. }
  24412. }
  24413. declare module BABYLON {
  24414. class ArcRotateCameraPointersInput implements ICameraInput<ArcRotateCamera> {
  24415. camera: ArcRotateCamera;
  24416. buttons: number[];
  24417. angularSensibilityX: number;
  24418. angularSensibilityY: number;
  24419. pinchPrecision: number;
  24420. /**
  24421. * pinchDeltaPercentage will be used instead of pinchPrecision if different from 0.
  24422. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  24423. */
  24424. pinchDeltaPercentage: number;
  24425. panningSensibility: number;
  24426. multiTouchPanning: boolean;
  24427. multiTouchPanAndZoom: boolean;
  24428. private _isPanClick;
  24429. pinchInwards: boolean;
  24430. private _pointerInput;
  24431. private _observer;
  24432. private _onMouseMove;
  24433. private _onGestureStart;
  24434. private _onGesture;
  24435. private _MSGestureHandler;
  24436. private _onLostFocus;
  24437. private _onContextMenu;
  24438. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  24439. detachControl(element: Nullable<HTMLElement>): void;
  24440. getClassName(): string;
  24441. getSimpleName(): string;
  24442. }
  24443. }
  24444. declare module BABYLON {
  24445. class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  24446. camera: ArcRotateCamera;
  24447. alphaCorrection: number;
  24448. betaCorrection: number;
  24449. gammaCorrection: number;
  24450. private _alpha;
  24451. private _gamma;
  24452. private _dirty;
  24453. private _deviceOrientationHandler;
  24454. constructor();
  24455. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  24456. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  24457. checkInputs(): void;
  24458. detachControl(element: Nullable<HTMLElement>): void;
  24459. getClassName(): string;
  24460. getSimpleName(): string;
  24461. }
  24462. }
  24463. declare module BABYLON {
  24464. /**
  24465. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  24466. * Screen rotation is taken into account.
  24467. */
  24468. class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  24469. private _camera;
  24470. private _screenOrientationAngle;
  24471. private _constantTranform;
  24472. private _screenQuaternion;
  24473. private _alpha;
  24474. private _beta;
  24475. private _gamma;
  24476. constructor();
  24477. camera: FreeCamera;
  24478. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  24479. private _orientationChanged;
  24480. private _deviceOrientation;
  24481. detachControl(element: Nullable<HTMLElement>): void;
  24482. checkInputs(): void;
  24483. getClassName(): string;
  24484. getSimpleName(): string;
  24485. }
  24486. }
  24487. declare module BABYLON {
  24488. class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  24489. camera: FreeCamera;
  24490. gamepad: Nullable<Gamepad>;
  24491. private _onGamepadConnectedObserver;
  24492. private _onGamepadDisconnectedObserver;
  24493. gamepadAngularSensibility: number;
  24494. gamepadMoveSensibility: number;
  24495. private _cameraTransform;
  24496. private _deltaTransform;
  24497. private _vector3;
  24498. private _vector2;
  24499. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  24500. detachControl(element: Nullable<HTMLElement>): void;
  24501. checkInputs(): void;
  24502. getClassName(): string;
  24503. getSimpleName(): string;
  24504. }
  24505. }
  24506. declare module BABYLON {
  24507. class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  24508. camera: FreeCamera;
  24509. private _keys;
  24510. private _onCanvasBlurObserver;
  24511. private _onKeyboardObserver;
  24512. private _engine;
  24513. private _scene;
  24514. keysUp: number[];
  24515. keysDown: number[];
  24516. keysLeft: number[];
  24517. keysRight: number[];
  24518. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  24519. detachControl(element: Nullable<HTMLElement>): void;
  24520. checkInputs(): void;
  24521. getClassName(): string;
  24522. _onLostFocus(e: FocusEvent): void;
  24523. getSimpleName(): string;
  24524. }
  24525. }
  24526. declare module BABYLON {
  24527. class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  24528. touchEnabled: boolean;
  24529. camera: FreeCamera;
  24530. buttons: number[];
  24531. angularSensibility: number;
  24532. private _pointerInput;
  24533. private _onMouseMove;
  24534. private _observer;
  24535. private previousPosition;
  24536. constructor(touchEnabled?: boolean);
  24537. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  24538. detachControl(element: Nullable<HTMLElement>): void;
  24539. getClassName(): string;
  24540. getSimpleName(): string;
  24541. }
  24542. }
  24543. declare module BABYLON {
  24544. class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  24545. camera: FreeCamera;
  24546. private _offsetX;
  24547. private _offsetY;
  24548. private _pointerPressed;
  24549. private _pointerInput;
  24550. private _observer;
  24551. private _onLostFocus;
  24552. touchAngularSensibility: number;
  24553. touchMoveSensibility: number;
  24554. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  24555. detachControl(element: Nullable<HTMLElement>): void;
  24556. checkInputs(): void;
  24557. getClassName(): string;
  24558. getSimpleName(): string;
  24559. }
  24560. }
  24561. declare module BABYLON {
  24562. class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  24563. camera: FreeCamera;
  24564. private _leftjoystick;
  24565. private _rightjoystick;
  24566. getLeftJoystick(): VirtualJoystick;
  24567. getRightJoystick(): VirtualJoystick;
  24568. checkInputs(): void;
  24569. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  24570. detachControl(element: Nullable<HTMLElement>): void;
  24571. getClassName(): string;
  24572. getSimpleName(): string;
  24573. }
  24574. }
  24575. declare module BABYLON {
  24576. class VRCameraMetrics {
  24577. hResolution: number;
  24578. vResolution: number;
  24579. hScreenSize: number;
  24580. vScreenSize: number;
  24581. vScreenCenter: number;
  24582. eyeToScreenDistance: number;
  24583. lensSeparationDistance: number;
  24584. interpupillaryDistance: number;
  24585. distortionK: number[];
  24586. chromaAbCorrection: number[];
  24587. postProcessScaleFactor: number;
  24588. lensCenterOffset: number;
  24589. compensateDistortion: boolean;
  24590. readonly aspectRatio: number;
  24591. readonly aspectRatioFov: number;
  24592. readonly leftHMatrix: Matrix;
  24593. readonly rightHMatrix: Matrix;
  24594. readonly leftPreViewMatrix: Matrix;
  24595. readonly rightPreViewMatrix: Matrix;
  24596. static GetDefault(): VRCameraMetrics;
  24597. }
  24598. }
  24599. declare module BABYLON {
  24600. class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  24601. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  24602. getClassName(): string;
  24603. }
  24604. class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  24605. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  24606. getClassName(): string;
  24607. }
  24608. class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  24609. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  24610. getClassName(): string;
  24611. }
  24612. }
  24613. declare module BABYLON {
  24614. /**
  24615. * Options to modify the vr teleportation behavior.
  24616. */
  24617. interface VRTeleportationOptions {
  24618. /**
  24619. * The name of the mesh which should be used as the teleportation floor. (default: null)
  24620. */
  24621. floorMeshName?: string;
  24622. /**
  24623. * A list of meshes to be used as the teleportation floor. (default: empty)
  24624. */
  24625. floorMeshes?: Mesh[];
  24626. }
  24627. /**
  24628. * Options to modify the vr experience helper's behavior.
  24629. */
  24630. interface VRExperienceHelperOptions extends WebVROptions {
  24631. /**
  24632. * Create a DeviceOrientationCamera to be used as your out of vr camera.
  24633. */
  24634. createDeviceOrientationCamera?: boolean;
  24635. /**
  24636. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found.
  24637. */
  24638. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  24639. }
  24640. /**
  24641. * Helps to quickly add VR support to an existing scene.
  24642. * See http://doc.babylonjs.com/how_to/webvr_helper
  24643. */
  24644. class VRExperienceHelper {
  24645. /** Options to modify the vr experience helper's behavior. */ webVROptions: VRExperienceHelperOptions;
  24646. private _scene;
  24647. private _position;
  24648. private _btnVR;
  24649. private _btnVRDisplayed;
  24650. private _webVRsupported;
  24651. private _webVRready;
  24652. private _webVRrequesting;
  24653. private _webVRpresenting;
  24654. private _fullscreenVRpresenting;
  24655. private _canvas;
  24656. private _webVRCamera;
  24657. private _vrDeviceOrientationCamera;
  24658. private _deviceOrientationCamera;
  24659. private _existingCamera;
  24660. private _onKeyDown;
  24661. private _onVrDisplayPresentChange;
  24662. private _onVRDisplayChanged;
  24663. private _onVRRequestPresentStart;
  24664. private _onVRRequestPresentComplete;
  24665. /**
  24666. * Observable raised when entering VR.
  24667. */
  24668. onEnteringVRObservable: Observable<VRExperienceHelper>;
  24669. /**
  24670. * Observable raised when exiting VR.
  24671. */
  24672. onExitingVRObservable: Observable<VRExperienceHelper>;
  24673. /**
  24674. * Observable raised when controller mesh is loaded.
  24675. */
  24676. onControllerMeshLoadedObservable: Observable<WebVRController>;
  24677. /** Return this.onEnteringVRObservable
  24678. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  24679. */
  24680. readonly onEnteringVR: Observable<VRExperienceHelper>;
  24681. /** Return this.onExitingVRObservable
  24682. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  24683. */
  24684. readonly onExitingVR: Observable<VRExperienceHelper>;
  24685. /** Return this.onControllerMeshLoadedObservable
  24686. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  24687. */
  24688. readonly onControllerMeshLoaded: Observable<WebVRController>;
  24689. private _rayLength;
  24690. private _useCustomVRButton;
  24691. private _teleportationRequested;
  24692. private _teleportActive;
  24693. private _floorMeshName;
  24694. private _floorMeshesCollection;
  24695. private _rotationAllowed;
  24696. private _teleportBackwardsVector;
  24697. private _rotationRightAsked;
  24698. private _rotationLeftAsked;
  24699. private _teleportationTarget;
  24700. private _isDefaultTeleportationTarget;
  24701. private _postProcessMove;
  24702. private _teleportationFillColor;
  24703. private _teleportationBorderColor;
  24704. private _rotationAngle;
  24705. private _haloCenter;
  24706. private _cameraGazer;
  24707. private _padSensibilityUp;
  24708. private _padSensibilityDown;
  24709. private leftController;
  24710. private rightController;
  24711. /**
  24712. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  24713. */
  24714. onNewMeshSelected: Observable<AbstractMesh>;
  24715. /**
  24716. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  24717. */
  24718. onNewMeshPicked: Observable<PickingInfo>;
  24719. private _circleEase;
  24720. /**
  24721. * Observable raised before camera teleportation
  24722. */
  24723. onBeforeCameraTeleport: Observable<Vector3>;
  24724. /**
  24725. * Observable raised after camera teleportation
  24726. */
  24727. onAfterCameraTeleport: Observable<Vector3>;
  24728. /**
  24729. * Observable raised when current selected mesh gets unselected
  24730. */
  24731. onSelectedMeshUnselected: Observable<AbstractMesh>;
  24732. private _raySelectionPredicate;
  24733. /**
  24734. * To be optionaly changed by user to define custom ray selection
  24735. */
  24736. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  24737. /**
  24738. * To be optionaly changed by user to define custom selection logic (after ray selection)
  24739. */
  24740. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  24741. /**
  24742. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  24743. */
  24744. teleportationEnabled: boolean;
  24745. private _defaultHeight;
  24746. private _teleportationInitialized;
  24747. private _interactionsEnabled;
  24748. private _interactionsRequested;
  24749. private _displayGaze;
  24750. private _displayLaserPointer;
  24751. /**
  24752. * The mesh used to display where the user is going to teleport.
  24753. */
  24754. /**
  24755. * Sets the mesh to be used to display where the user is going to teleport.
  24756. */
  24757. teleportationTarget: Mesh;
  24758. /**
  24759. * The mesh used to display where the user is selecting,
  24760. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  24761. * See http://doc.babylonjs.com/resources/baking_transformations
  24762. */
  24763. gazeTrackerMesh: Mesh;
  24764. /**
  24765. * If the ray of the gaze should be displayed.
  24766. */
  24767. /**
  24768. * Sets if the ray of the gaze should be displayed.
  24769. */
  24770. displayGaze: boolean;
  24771. /**
  24772. * If the ray of the LaserPointer should be displayed.
  24773. */
  24774. /**
  24775. * Sets if the ray of the LaserPointer should be displayed.
  24776. */
  24777. displayLaserPointer: boolean;
  24778. /**
  24779. * The deviceOrientationCamera used as the camera when not in VR.
  24780. */
  24781. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  24782. /**
  24783. * Based on the current WebVR support, returns the current VR camera used.
  24784. */
  24785. readonly currentVRCamera: Nullable<Camera>;
  24786. /**
  24787. * The webVRCamera which is used when in VR.
  24788. */
  24789. readonly webVRCamera: WebVRFreeCamera;
  24790. /**
  24791. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  24792. */
  24793. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  24794. private readonly _teleportationRequestInitiated;
  24795. /**
  24796. * Instantiates a VRExperienceHelper.
  24797. * Helps to quickly add VR support to an existing scene.
  24798. * @param scene The scene the VRExperienceHelper belongs to.
  24799. * @param webVROptions Options to modify the vr experience helper's behavior.
  24800. */
  24801. constructor(scene: Scene, /** Options to modify the vr experience helper's behavior. */ webVROptions?: VRExperienceHelperOptions);
  24802. private _onDefaultMeshLoaded(webVRController);
  24803. private _onResize;
  24804. private _onFullscreenChange;
  24805. /**
  24806. * Gets a value indicating if we are currently in VR mode.
  24807. */
  24808. readonly isInVRMode: boolean;
  24809. private onVrDisplayPresentChange();
  24810. private onVRDisplayChanged(eventArgs);
  24811. private moveButtonToBottomRight();
  24812. private displayVRButton();
  24813. private updateButtonVisibility();
  24814. /**
  24815. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  24816. * Otherwise, will use the fullscreen API.
  24817. */
  24818. enterVR(): void;
  24819. /**
  24820. * Attempt to exit VR, or fullscreen.
  24821. */
  24822. exitVR(): void;
  24823. /**
  24824. * The position of the vr experience helper.
  24825. */
  24826. /**
  24827. * Sets the position of the vr experience helper.
  24828. */
  24829. position: Vector3;
  24830. /**
  24831. * Enables controllers and user interactions suck as selecting and object or clicking on an object.
  24832. */
  24833. enableInteractions(): void;
  24834. private beforeRender;
  24835. private _isTeleportationFloor(mesh);
  24836. /**
  24837. * Adds a floor mesh to be used for teleportation.
  24838. * @param floorMesh the mesh to be used for teleportation.
  24839. */
  24840. addFloorMesh(floorMesh: Mesh): void;
  24841. /**
  24842. * Removes a floor mesh from being used for teleportation.
  24843. * @param floorMesh the mesh to be removed.
  24844. */
  24845. removeFloorMesh(floorMesh: Mesh): void;
  24846. /**
  24847. * Enables interactions and teleportation using the VR controllers and gaze.
  24848. * @param vrTeleportationOptions options to modify teleportation behavior.
  24849. */
  24850. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  24851. private _onNewGamepadConnected;
  24852. private _tryEnableInteractionOnController;
  24853. private _onNewGamepadDisconnected;
  24854. private _enableInteractionOnController(controller);
  24855. private _checkTeleportWithRay(stateObject, gazer);
  24856. private _checkRotate(stateObject, gazer);
  24857. private _checkTeleportBackwards(stateObject, gazer);
  24858. private _enableTeleportationOnController(controller);
  24859. private _createTeleportationCircles();
  24860. private _displayTeleportationTarget();
  24861. private _hideTeleportationTarget();
  24862. private _rotateCamera(right);
  24863. private _moveTeleportationSelectorTo(hit, gazer);
  24864. private _workingVector;
  24865. private _workingQuaternion;
  24866. private _workingMatrix;
  24867. private _teleportCamera(location);
  24868. private _castRayAndSelectObject(gazer);
  24869. private _notifySelectedMeshUnselected(mesh);
  24870. /**
  24871. * Sets the color of the laser ray from the vr controllers.
  24872. * @param color new color for the ray.
  24873. */
  24874. changeLaserColor(color: Color3): void;
  24875. /**
  24876. * Sets the color of the ray from the vr headsets gaze.
  24877. * @param color new color for the ray.
  24878. */
  24879. changeGazeColor(color: Color3): void;
  24880. /**
  24881. * Exits VR and disposes of the vr experience helper
  24882. */
  24883. dispose(): void;
  24884. /**
  24885. * Gets the name of the VRExperienceHelper class
  24886. * @returns "VRExperienceHelper"
  24887. */
  24888. getClassName(): string;
  24889. }
  24890. }
  24891. declare var VRFrameData: any;
  24892. declare module BABYLON {
  24893. /**
  24894. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  24895. * IMPORTANT!! The data is right-hand data.
  24896. * @export
  24897. * @interface DevicePose
  24898. */
  24899. interface DevicePose {
  24900. /**
  24901. * The position of the device, values in array are [x,y,z].
  24902. */
  24903. readonly position?: Float32Array;
  24904. /**
  24905. * The linearVelocity of the device, values in array are [x,y,z].
  24906. */
  24907. readonly linearVelocity?: Float32Array;
  24908. /**
  24909. * The linearAcceleration of the device, values in array are [x,y,z].
  24910. */
  24911. readonly linearAcceleration?: Float32Array;
  24912. /**
  24913. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  24914. */
  24915. readonly orientation?: Float32Array;
  24916. /**
  24917. * The angularVelocity of the device, values in array are [x,y,z].
  24918. */
  24919. readonly angularVelocity?: Float32Array;
  24920. /**
  24921. * The angularAcceleration of the device, values in array are [x,y,z].
  24922. */
  24923. readonly angularAcceleration?: Float32Array;
  24924. }
  24925. /**
  24926. * Interface representing a pose controlled object in Babylon.
  24927. * A pose controlled object has both regular pose values as well as pose values
  24928. * from an external device such as a VR head mounted display
  24929. */
  24930. interface PoseControlled {
  24931. /**
  24932. * The position of the object in babylon space.
  24933. */
  24934. position: Vector3;
  24935. /**
  24936. * The rotation quaternion of the object in babylon space.
  24937. */
  24938. rotationQuaternion: Quaternion;
  24939. /**
  24940. * The position of the device in babylon space.
  24941. */
  24942. devicePosition?: Vector3;
  24943. /**
  24944. * The rotation quaternion of the device in babylon space.
  24945. */
  24946. deviceRotationQuaternion: Quaternion;
  24947. /**
  24948. * The raw pose coming from the device.
  24949. */
  24950. rawPose: Nullable<DevicePose>;
  24951. /**
  24952. * The scale of the device to be used when translating from device space to babylon space.
  24953. */
  24954. deviceScaleFactor: number;
  24955. /**
  24956. * Updates the poseControlled values based on the input device pose.
  24957. * @param poseData the pose data to update the object with
  24958. */
  24959. updateFromDevice(poseData: DevicePose): void;
  24960. }
  24961. /**
  24962. * Set of options to customize the webVRCamera
  24963. */
  24964. interface WebVROptions {
  24965. /**
  24966. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  24967. */
  24968. trackPosition?: boolean;
  24969. /**
  24970. * Sets the scale of the vrDevice in babylon space. (default: 1)
  24971. */
  24972. positionScale?: number;
  24973. /**
  24974. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  24975. */
  24976. displayName?: string;
  24977. /**
  24978. * Should the native controller meshes be initialized. (default: true)
  24979. */
  24980. controllerMeshes?: boolean;
  24981. /**
  24982. * Creating a default HemiLight only on controllers. (default: true)
  24983. */
  24984. defaultLightingOnControllers?: boolean;
  24985. /**
  24986. * If you don't want to use the default VR button of the helper. (default: false)
  24987. */
  24988. useCustomVRButton?: boolean;
  24989. /**
  24990. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  24991. */
  24992. customVRButton?: HTMLButtonElement;
  24993. /**
  24994. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  24995. */
  24996. rayLength?: number;
  24997. /**
  24998. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  24999. */
  25000. defaultHeight?: number;
  25001. }
  25002. /**
  25003. * This represents a WebVR camera.
  25004. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  25005. * @example http://doc.babylonjs.com/how_to/webvr_camera
  25006. */
  25007. class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  25008. private webVROptions;
  25009. /**
  25010. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  25011. */
  25012. _vrDevice: any;
  25013. /**
  25014. * The rawPose of the vrDevice.
  25015. */
  25016. rawPose: Nullable<DevicePose>;
  25017. private _onVREnabled;
  25018. private _specsVersion;
  25019. private _attached;
  25020. private _frameData;
  25021. protected _descendants: Array<Node>;
  25022. private _deviceRoomPosition;
  25023. private _deviceRoomRotationQuaternion;
  25024. private _standingMatrix;
  25025. /**
  25026. * Represents device position in babylon space.
  25027. */
  25028. devicePosition: Vector3;
  25029. /**
  25030. * Represents device rotation in babylon space.
  25031. */
  25032. deviceRotationQuaternion: Quaternion;
  25033. /**
  25034. * The scale of the device to be used when translating from device space to babylon space.
  25035. */
  25036. deviceScaleFactor: number;
  25037. private _deviceToWorld;
  25038. private _worldToDevice;
  25039. /**
  25040. * References to the webVR controllers for the vrDevice.
  25041. */
  25042. controllers: Array<WebVRController>;
  25043. /**
  25044. * Emits an event when a controller is attached.
  25045. */
  25046. onControllersAttachedObservable: Observable<WebVRController[]>;
  25047. /**
  25048. * Emits an event when a controller's mesh has been loaded;
  25049. */
  25050. onControllerMeshLoadedObservable: Observable<WebVRController>;
  25051. /**
  25052. * If the rig cameras be used as parent instead of this camera.
  25053. */
  25054. rigParenting: boolean;
  25055. private _lightOnControllers;
  25056. private _defaultHeight?;
  25057. /**
  25058. * Instantiates a WebVRFreeCamera.
  25059. * @param name The name of the WebVRFreeCamera
  25060. * @param position The starting anchor position for the camera
  25061. * @param scene The scene the camera belongs to
  25062. * @param webVROptions a set of customizable options for the webVRCamera
  25063. */
  25064. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  25065. /**
  25066. * Gets the device distance from the ground in meters.
  25067. * @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.
  25068. */
  25069. deviceDistanceToRoomGround(): number;
  25070. /**
  25071. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  25072. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  25073. */
  25074. useStandingMatrix(callback?: (bool: boolean) => void): void;
  25075. /**
  25076. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  25077. * @returns A promise with a boolean set to if the standing matrix is supported.
  25078. */
  25079. useStandingMatrixAsync(): Promise<boolean>;
  25080. /**
  25081. * Disposes the camera
  25082. */
  25083. dispose(): void;
  25084. /**
  25085. * Gets a vrController by name.
  25086. * @param name The name of the controller to retreive
  25087. * @returns the controller matching the name specified or null if not found
  25088. */
  25089. getControllerByName(name: string): Nullable<WebVRController>;
  25090. private _leftController;
  25091. /**
  25092. * The controller corrisponding to the users left hand.
  25093. */
  25094. readonly leftController: Nullable<WebVRController>;
  25095. private _rightController;
  25096. /**
  25097. * The controller corrisponding to the users right hand.
  25098. */
  25099. readonly rightController: Nullable<WebVRController>;
  25100. /**
  25101. * Casts a ray forward from the vrCamera's gaze.
  25102. * @param length Length of the ray (default: 100)
  25103. * @returns the ray corrisponding to the gaze
  25104. */
  25105. getForwardRay(length?: number): Ray;
  25106. /**
  25107. * Updates the camera based on device's frame data
  25108. */
  25109. _checkInputs(): void;
  25110. /**
  25111. * Updates the poseControlled values based on the input device pose.
  25112. * @param poseData Pose coming from the device
  25113. */
  25114. updateFromDevice(poseData: DevicePose): void;
  25115. /**
  25116. * WebVR's attach control will start broadcasting frames to the device.
  25117. * Note that in certain browsers (chrome for example) this function must be called
  25118. * within a user-interaction callback. Example:
  25119. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  25120. *
  25121. * @param element html element to attach the vrDevice to
  25122. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  25123. */
  25124. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  25125. /**
  25126. * Detaches the camera from the html element and disables VR
  25127. *
  25128. * @param element html element to detach from
  25129. */
  25130. detachControl(element: HTMLElement): void;
  25131. /**
  25132. * @returns the name of this class
  25133. */
  25134. getClassName(): string;
  25135. /**
  25136. * Calls resetPose on the vrDisplay
  25137. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  25138. */
  25139. resetToCurrentRotation(): void;
  25140. /**
  25141. * Updates the rig cameras (left and right eye)
  25142. */
  25143. _updateRigCameras(): void;
  25144. private _workingVector;
  25145. private _oneVector;
  25146. private _workingMatrix;
  25147. private updateCacheCalled;
  25148. /**
  25149. * Updates the cached values of the camera
  25150. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  25151. */
  25152. _updateCache(ignoreParentClass?: boolean): void;
  25153. /**
  25154. * Updates the current device position and rotation in the babylon world
  25155. */
  25156. update(): void;
  25157. /**
  25158. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  25159. * @returns an identity matrix
  25160. */
  25161. _getViewMatrix(): Matrix;
  25162. /**
  25163. * This function is called by the two RIG cameras.
  25164. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  25165. */
  25166. protected _getWebVRViewMatrix(): Matrix;
  25167. protected _getWebVRProjectionMatrix(): Matrix;
  25168. private _onGamepadConnectedObserver;
  25169. private _onGamepadDisconnectedObserver;
  25170. /**
  25171. * Initializes the controllers and their meshes
  25172. */
  25173. initControllers(): void;
  25174. }
  25175. }
  25176. declare module BABYLON {
  25177. interface IOctreeContainer<T> {
  25178. blocks: Array<OctreeBlock<T>>;
  25179. }
  25180. class Octree<T> {
  25181. maxDepth: number;
  25182. blocks: Array<OctreeBlock<T>>;
  25183. dynamicContent: T[];
  25184. private _maxBlockCapacity;
  25185. private _selectionContent;
  25186. private _creationFunc;
  25187. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number, maxDepth?: number);
  25188. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  25189. addMesh(entry: T): void;
  25190. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  25191. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  25192. intersectsRay(ray: Ray): SmartArray<T>;
  25193. 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;
  25194. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  25195. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  25196. }
  25197. }
  25198. declare module BABYLON {
  25199. class OctreeBlock<T> {
  25200. entries: T[];
  25201. blocks: Array<OctreeBlock<T>>;
  25202. private _depth;
  25203. private _maxDepth;
  25204. private _capacity;
  25205. private _minPoint;
  25206. private _maxPoint;
  25207. private _boundingVectors;
  25208. private _creationFunc;
  25209. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  25210. readonly capacity: number;
  25211. readonly minPoint: Vector3;
  25212. readonly maxPoint: Vector3;
  25213. addEntry(entry: T): void;
  25214. addEntries(entries: T[]): void;
  25215. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  25216. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  25217. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  25218. createInnerBlocks(): void;
  25219. }
  25220. }
  25221. declare module BABYLON {
  25222. /**
  25223. * Google Daydream controller
  25224. */
  25225. class DaydreamController extends WebVRController {
  25226. /**
  25227. * Base Url for the controller model.
  25228. */
  25229. static MODEL_BASE_URL: string;
  25230. /**
  25231. * File name for the controller model.
  25232. */
  25233. static MODEL_FILENAME: string;
  25234. /**
  25235. * Gamepad Id prefix used to identify Daydream Controller.
  25236. */
  25237. static readonly GAMEPAD_ID_PREFIX: string;
  25238. constructor(vrGamepad: any);
  25239. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  25240. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  25241. }
  25242. }
  25243. declare module BABYLON {
  25244. class GearVRController extends WebVRController {
  25245. static MODEL_BASE_URL: string;
  25246. static MODEL_FILENAME: string;
  25247. static readonly GAMEPAD_ID_PREFIX: string;
  25248. private readonly _buttonIndexToObservableNameMap;
  25249. constructor(vrGamepad: any);
  25250. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  25251. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  25252. }
  25253. }
  25254. declare module BABYLON {
  25255. class GenericController extends WebVRController {
  25256. static readonly MODEL_BASE_URL: string;
  25257. static readonly MODEL_FILENAME: string;
  25258. constructor(vrGamepad: any);
  25259. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  25260. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  25261. }
  25262. }
  25263. declare module BABYLON {
  25264. class OculusTouchController extends WebVRController {
  25265. static MODEL_BASE_URL: string;
  25266. static MODEL_LEFT_FILENAME: string;
  25267. static MODEL_RIGHT_FILENAME: string;
  25268. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  25269. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  25270. constructor(vrGamepad: any);
  25271. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  25272. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  25273. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  25274. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  25275. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  25276. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  25277. }
  25278. }
  25279. declare module BABYLON {
  25280. enum PoseEnabledControllerType {
  25281. VIVE = 0,
  25282. OCULUS = 1,
  25283. WINDOWS = 2,
  25284. GEAR_VR = 3,
  25285. /**
  25286. * Google Daydream
  25287. */
  25288. DAYDREAM = 4,
  25289. GENERIC = 5,
  25290. }
  25291. interface MutableGamepadButton {
  25292. value: number;
  25293. touched: boolean;
  25294. pressed: boolean;
  25295. }
  25296. interface ExtendedGamepadButton extends GamepadButton {
  25297. readonly pressed: boolean;
  25298. readonly touched: boolean;
  25299. readonly value: number;
  25300. }
  25301. class PoseEnabledControllerHelper {
  25302. static InitiateController(vrGamepad: any): OculusTouchController | WindowsMotionController | ViveController | GearVRController | DaydreamController | GenericController;
  25303. }
  25304. class PoseEnabledController extends Gamepad implements PoseControlled {
  25305. private _deviceRoomPosition;
  25306. private _deviceRoomRotationQuaternion;
  25307. devicePosition: Vector3;
  25308. deviceRotationQuaternion: Quaternion;
  25309. deviceScaleFactor: number;
  25310. position: Vector3;
  25311. rotationQuaternion: Quaternion;
  25312. controllerType: PoseEnabledControllerType;
  25313. private _calculatedPosition;
  25314. private _calculatedRotation;
  25315. rawPose: DevicePose;
  25316. _mesh: Nullable<AbstractMesh>;
  25317. private _poseControlledCamera;
  25318. private _leftHandSystemQuaternion;
  25319. _deviceToWorld: Matrix;
  25320. /**
  25321. * Node to be used when casting a ray from the controller
  25322. */
  25323. _pointingPoseNode: Nullable<AbstractMesh>;
  25324. /**
  25325. * Name of the child mesh that can be used to cast a ray from the controller
  25326. */
  25327. static readonly POINTING_POSE: string;
  25328. constructor(browserGamepad: any);
  25329. private _workingMatrix;
  25330. update(): void;
  25331. updateFromDevice(poseData: DevicePose): void;
  25332. attachToMesh(mesh: AbstractMesh): void;
  25333. attachToPoseControlledCamera(camera: TargetCamera): void;
  25334. dispose(): void;
  25335. readonly mesh: Nullable<AbstractMesh>;
  25336. getForwardRay(length?: number): Ray;
  25337. }
  25338. }
  25339. declare module BABYLON {
  25340. class ViveController extends WebVRController {
  25341. static MODEL_BASE_URL: string;
  25342. static MODEL_FILENAME: string;
  25343. constructor(vrGamepad: any);
  25344. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  25345. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  25346. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  25347. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  25348. /**
  25349. * Vive mapping:
  25350. * 0: touchpad
  25351. * 1: trigger
  25352. * 2: left AND right buttons
  25353. * 3: menu button
  25354. */
  25355. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  25356. }
  25357. }
  25358. declare module BABYLON {
  25359. abstract class WebVRController extends PoseEnabledController {
  25360. protected _defaultModel: AbstractMesh;
  25361. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  25362. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  25363. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  25364. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  25365. onPadValuesChangedObservable: Observable<StickValues>;
  25366. protected _buttons: Array<MutableGamepadButton>;
  25367. private _onButtonStateChange;
  25368. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  25369. pad: StickValues;
  25370. hand: string;
  25371. readonly defaultModel: AbstractMesh;
  25372. constructor(vrGamepad: any);
  25373. update(): void;
  25374. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  25375. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  25376. private _setButtonValue(newState, currentState, buttonIndex);
  25377. private _changes;
  25378. private _checkChanges(newState, currentState);
  25379. dispose(): void;
  25380. }
  25381. }
  25382. declare module BABYLON {
  25383. class WindowsMotionController extends WebVRController {
  25384. static MODEL_BASE_URL: string;
  25385. static MODEL_LEFT_FILENAME: string;
  25386. static MODEL_RIGHT_FILENAME: string;
  25387. static readonly GAMEPAD_ID_PREFIX: string;
  25388. private static readonly GAMEPAD_ID_PATTERN;
  25389. private _loadedMeshInfo;
  25390. private readonly _mapping;
  25391. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  25392. onTrackpadValuesChangedObservable: Observable<StickValues>;
  25393. trackpad: StickValues;
  25394. constructor(vrGamepad: any);
  25395. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  25396. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  25397. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  25398. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  25399. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  25400. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  25401. /**
  25402. * Called once per frame by the engine.
  25403. */
  25404. update(): void;
  25405. /**
  25406. * Called once for each button that changed state since the last frame
  25407. * @param buttonIdx Which button index changed
  25408. * @param state New state of the button
  25409. * @param changes Which properties on the state changed since last frame
  25410. */
  25411. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  25412. protected lerpButtonTransform(buttonName: string, buttonValue: number): void;
  25413. protected lerpAxisTransform(axis: number, axisValue: number): void;
  25414. /**
  25415. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  25416. * @param scene scene in which to add meshes
  25417. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  25418. */
  25419. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  25420. /**
  25421. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  25422. * can be transformed by button presses and axes values, based on this._mapping.
  25423. *
  25424. * @param scene scene in which the meshes exist
  25425. * @param meshes list of meshes that make up the controller model to process
  25426. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  25427. */
  25428. private processModel(scene, meshes);
  25429. private createMeshInfo(rootNode);
  25430. getForwardRay(length?: number): Ray;
  25431. dispose(): void;
  25432. }
  25433. }
  25434. declare module BABYLON {
  25435. /**
  25436. * Interface to implement to create a shadow generator compatible with BJS.
  25437. */
  25438. interface IShadowGenerator {
  25439. /**
  25440. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  25441. * @returns The render target texture if present otherwise, null
  25442. */
  25443. getShadowMap(): Nullable<RenderTargetTexture>;
  25444. /**
  25445. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  25446. * @returns The render target texture if the shadow map is present otherwise, null
  25447. */
  25448. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  25449. /**
  25450. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  25451. * @param subMesh The submesh we want to render in the shadow map
  25452. * @param useInstances Defines wether will draw in the map using instances
  25453. * @returns true if ready otherwise, false
  25454. */
  25455. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  25456. /**
  25457. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  25458. * @param defines Defines of the material we want to update
  25459. * @param lightIndex Index of the light in the enabled light list of the material
  25460. */
  25461. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  25462. /**
  25463. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  25464. * defined in the generator but impacting the effect).
  25465. * It implies the unifroms available on the materials are the standard BJS ones.
  25466. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  25467. * @param effect The effect we are binfing the information for
  25468. */
  25469. bindShadowLight(lightIndex: string, effect: Effect): void;
  25470. /**
  25471. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  25472. * (eq to shadow prjection matrix * light transform matrix)
  25473. * @returns The transform matrix used to create the shadow map
  25474. */
  25475. getTransformMatrix(): Matrix;
  25476. /**
  25477. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  25478. * Cube and 2D textures for instance.
  25479. */
  25480. recreateShadowMap(): void;
  25481. /**
  25482. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  25483. * @param onCompiled Callback triggered at the and of the effects compilation
  25484. * @param options Sets of optional options forcing the compilation with different modes
  25485. */
  25486. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  25487. useInstances: boolean;
  25488. }>): void;
  25489. /**
  25490. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  25491. * @param options Sets of optional options forcing the compilation with different modes
  25492. * @returns A promise that resolves when the compilation completes
  25493. */
  25494. forceCompilationAsync(options?: Partial<{
  25495. useInstances: boolean;
  25496. }>): Promise<void>;
  25497. /**
  25498. * Serializes the shadow generator setup to a json object.
  25499. * @returns The serialized JSON object
  25500. */
  25501. serialize(): any;
  25502. /**
  25503. * Disposes the Shadow map and related Textures and effects.
  25504. */
  25505. dispose(): void;
  25506. }
  25507. /**
  25508. * Default implementation IShadowGenerator.
  25509. * This is the main object responsible of generating shadows in the framework.
  25510. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  25511. */
  25512. class ShadowGenerator implements IShadowGenerator {
  25513. /**
  25514. * Shadow generator mode None: no filtering applied.
  25515. */
  25516. static readonly FILTER_NONE: number;
  25517. /**
  25518. * Shadow generator mode ESM: Exponential Shadow Mapping.
  25519. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  25520. */
  25521. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  25522. /**
  25523. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  25524. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  25525. */
  25526. static readonly FILTER_POISSONSAMPLING: number;
  25527. /**
  25528. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  25529. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  25530. */
  25531. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  25532. /**
  25533. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  25534. * edge artifacts on steep falloff.
  25535. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  25536. */
  25537. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  25538. /**
  25539. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  25540. * edge artifacts on steep falloff.
  25541. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  25542. */
  25543. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  25544. /**
  25545. * Shadow generator mode PCF: Percentage Closer Filtering
  25546. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  25547. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  25548. */
  25549. static readonly FILTER_PCF: number;
  25550. /**
  25551. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  25552. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  25553. * Contact Hardening
  25554. */
  25555. static readonly FILTER_PCSS: number;
  25556. /**
  25557. * Reserved for PCF and PCSS
  25558. * Highest Quality.
  25559. *
  25560. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  25561. *
  25562. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  25563. */
  25564. static readonly QUALITY_HIGH: number;
  25565. /**
  25566. * Reserved for PCF and PCSS
  25567. * Good tradeoff for quality/perf cross devices
  25568. *
  25569. * Execute PCF on a 3*3 kernel.
  25570. *
  25571. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  25572. */
  25573. static readonly QUALITY_MEDIUM: number;
  25574. /**
  25575. * Reserved for PCF and PCSS
  25576. * The lowest quality but the fastest.
  25577. *
  25578. * Execute PCF on a 1*1 kernel.
  25579. *
  25580. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  25581. */
  25582. static readonly QUALITY_LOW: number;
  25583. private _bias;
  25584. /**
  25585. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  25586. */
  25587. /**
  25588. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  25589. */
  25590. bias: number;
  25591. private _normalBias;
  25592. /**
  25593. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  25594. */
  25595. /**
  25596. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  25597. */
  25598. normalBias: number;
  25599. private _blurBoxOffset;
  25600. /**
  25601. * Gets the blur box offset: offset applied during the blur pass.
  25602. * Only usefull if useKernelBlur = false
  25603. */
  25604. /**
  25605. * Sets the blur box offset: offset applied during the blur pass.
  25606. * Only usefull if useKernelBlur = false
  25607. */
  25608. blurBoxOffset: number;
  25609. private _blurScale;
  25610. /**
  25611. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  25612. * 2 means half of the size.
  25613. */
  25614. /**
  25615. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  25616. * 2 means half of the size.
  25617. */
  25618. blurScale: number;
  25619. private _blurKernel;
  25620. /**
  25621. * Gets the blur kernel: kernel size of the blur pass.
  25622. * Only usefull if useKernelBlur = true
  25623. */
  25624. /**
  25625. * Sets the blur kernel: kernel size of the blur pass.
  25626. * Only usefull if useKernelBlur = true
  25627. */
  25628. blurKernel: number;
  25629. private _useKernelBlur;
  25630. /**
  25631. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  25632. * Only usefull in filtered mode (useBlurExponentialShadowMap...)
  25633. */
  25634. /**
  25635. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  25636. * Only usefull in filtered mode (useBlurExponentialShadowMap...)
  25637. */
  25638. useKernelBlur: boolean;
  25639. private _depthScale;
  25640. /**
  25641. * Gets the depth scale used in ESM mode.
  25642. */
  25643. /**
  25644. * Sets the depth scale used in ESM mode.
  25645. * This can override the scale stored on the light.
  25646. */
  25647. depthScale: number;
  25648. private _filter;
  25649. /**
  25650. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  25651. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  25652. */
  25653. /**
  25654. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  25655. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  25656. */
  25657. filter: number;
  25658. /**
  25659. * Gets if the current filter is set to Poisson Sampling.
  25660. */
  25661. /**
  25662. * Sets the current filter to Poisson Sampling.
  25663. */
  25664. usePoissonSampling: boolean;
  25665. /**
  25666. * Gets if the current filter is set to VSM.
  25667. * DEPRECATED. Should use useExponentialShadowMap instead.
  25668. */
  25669. /**
  25670. * Sets the current filter is to VSM.
  25671. * DEPRECATED. Should use useExponentialShadowMap instead.
  25672. */
  25673. useVarianceShadowMap: boolean;
  25674. /**
  25675. * Gets if the current filter is set to blurred VSM.
  25676. * DEPRECATED. Should use useBlurExponentialShadowMap instead.
  25677. */
  25678. /**
  25679. * Sets the current filter is to blurred VSM.
  25680. * DEPRECATED. Should use useBlurExponentialShadowMap instead.
  25681. */
  25682. useBlurVarianceShadowMap: boolean;
  25683. /**
  25684. * Gets if the current filter is set to ESM.
  25685. */
  25686. /**
  25687. * Sets the current filter is to ESM.
  25688. */
  25689. useExponentialShadowMap: boolean;
  25690. /**
  25691. * Gets if the current filter is set to filtered ESM.
  25692. */
  25693. /**
  25694. * Gets if the current filter is set to filtered ESM.
  25695. */
  25696. useBlurExponentialShadowMap: boolean;
  25697. /**
  25698. * Gets if the current filter is set to "close ESM" (using the inverse of the
  25699. * exponential to prevent steep falloff artifacts).
  25700. */
  25701. /**
  25702. * Sets the current filter to "close ESM" (using the inverse of the
  25703. * exponential to prevent steep falloff artifacts).
  25704. */
  25705. useCloseExponentialShadowMap: boolean;
  25706. /**
  25707. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  25708. * exponential to prevent steep falloff artifacts).
  25709. */
  25710. /**
  25711. * Sets the current filter to filtered "close ESM" (using the inverse of the
  25712. * exponential to prevent steep falloff artifacts).
  25713. */
  25714. useBlurCloseExponentialShadowMap: boolean;
  25715. /**
  25716. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  25717. */
  25718. /**
  25719. * Sets the current filter to "PCF" (percentage closer filtering).
  25720. */
  25721. usePercentageCloserFiltering: boolean;
  25722. private _filteringQuality;
  25723. /**
  25724. * Gets the PCF or PCSS Quality.
  25725. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  25726. */
  25727. /**
  25728. * Sets the PCF or PCSS Quality.
  25729. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  25730. */
  25731. filteringQuality: number;
  25732. /**
  25733. * Gets if the current filter is set to "PCSS" (contact hardening).
  25734. */
  25735. /**
  25736. * Sets the current filter to "PCSS" (contact hardening).
  25737. */
  25738. useContactHardeningShadow: boolean;
  25739. private _contactHardeningLightSizeUVRatio;
  25740. /**
  25741. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  25742. * Using a ratio helps keeping shape stability independently of the map size.
  25743. *
  25744. * It does not account for the light projection as it was having too much
  25745. * instability during the light setup or during light position changes.
  25746. *
  25747. * Only valid if useContactHardeningShadow is true.
  25748. */
  25749. /**
  25750. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  25751. * Using a ratio helps keeping shape stability independently of the map size.
  25752. *
  25753. * It does not account for the light projection as it was having too much
  25754. * instability during the light setup or during light position changes.
  25755. *
  25756. * Only valid if useContactHardeningShadow is true.
  25757. */
  25758. contactHardeningLightSizeUVRatio: number;
  25759. private _darkness;
  25760. /**
  25761. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  25762. * 0 means strongest and 1 would means no shadow.
  25763. * @returns the darkness.
  25764. */
  25765. getDarkness(): number;
  25766. /**
  25767. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  25768. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  25769. * @returns the shadow generator allowing fluent coding.
  25770. */
  25771. setDarkness(darkness: number): ShadowGenerator;
  25772. private _transparencyShadow;
  25773. /**
  25774. * Sets the ability to have transparent shadow (boolean).
  25775. * @param transparent True if transparent else False
  25776. * @returns the shadow generator allowing fluent coding
  25777. */
  25778. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  25779. private _shadowMap;
  25780. private _shadowMap2;
  25781. /**
  25782. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  25783. * @returns The render target texture if present otherwise, null
  25784. */
  25785. getShadowMap(): Nullable<RenderTargetTexture>;
  25786. /**
  25787. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  25788. * @returns The render target texture if the shadow map is present otherwise, null
  25789. */
  25790. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  25791. /**
  25792. * Helper function to add a mesh and its descendants to the list of shadow casters.
  25793. * @param mesh Mesh to add
  25794. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  25795. * @returns the Shadow Generator itself
  25796. */
  25797. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  25798. /**
  25799. * Helper function to remove a mesh and its descendants from the list of shadow casters
  25800. * @param mesh Mesh to remove
  25801. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  25802. * @returns the Shadow Generator itself
  25803. */
  25804. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  25805. /**
  25806. * Controls the extent to which the shadows fade out at the edge of the frustum
  25807. * Used only by directionals and spots
  25808. */
  25809. frustumEdgeFalloff: number;
  25810. private _light;
  25811. /**
  25812. * Returns the associated light object.
  25813. * @returns the light generating the shadow
  25814. */
  25815. getLight(): IShadowLight;
  25816. /**
  25817. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  25818. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  25819. * It might on the other hand introduce peter panning.
  25820. */
  25821. forceBackFacesOnly: boolean;
  25822. private _scene;
  25823. private _lightDirection;
  25824. private _effect;
  25825. private _viewMatrix;
  25826. private _projectionMatrix;
  25827. private _transformMatrix;
  25828. private _cachedPosition;
  25829. private _cachedDirection;
  25830. private _cachedDefines;
  25831. private _currentRenderID;
  25832. private _boxBlurPostprocess;
  25833. private _kernelBlurXPostprocess;
  25834. private _kernelBlurYPostprocess;
  25835. private _blurPostProcesses;
  25836. private _mapSize;
  25837. private _currentFaceIndex;
  25838. private _currentFaceIndexCache;
  25839. private _textureType;
  25840. private _defaultTextureMatrix;
  25841. /**
  25842. * Creates a ShadowGenerator object.
  25843. * A ShadowGenerator is the required tool to use the shadows.
  25844. * Each light casting shadows needs to use its own ShadowGenerator.
  25845. * Documentation : http://doc.babylonjs.com/tutorials/shadows
  25846. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  25847. * @param light The light object generating the shadows.
  25848. * @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.
  25849. */
  25850. constructor(mapSize: number, light: IShadowLight, useFullFloatFirst?: boolean);
  25851. private _initializeGenerator();
  25852. private _initializeShadowMap();
  25853. private _initializeBlurRTTAndPostProcesses();
  25854. private _renderForShadowMap(opaqueSubMeshes, alphaTestSubMeshes, transparentSubMeshes, depthOnlySubMeshes);
  25855. private _renderSubMeshForShadowMap(subMesh);
  25856. private _applyFilterValues();
  25857. /**
  25858. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  25859. * @param onCompiled Callback triggered at the and of the effects compilation
  25860. * @param options Sets of optional options forcing the compilation with different modes
  25861. */
  25862. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  25863. useInstances: boolean;
  25864. }>): void;
  25865. /**
  25866. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  25867. * @param options Sets of optional options forcing the compilation with different modes
  25868. * @returns A promise that resolves when the compilation completes
  25869. */
  25870. forceCompilationAsync(options?: Partial<{
  25871. useInstances: boolean;
  25872. }>): Promise<void>;
  25873. /**
  25874. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  25875. * @param subMesh The submesh we want to render in the shadow map
  25876. * @param useInstances Defines wether will draw in the map using instances
  25877. * @returns true if ready otherwise, false
  25878. */
  25879. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  25880. /**
  25881. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  25882. * @param defines Defines of the material we want to update
  25883. * @param lightIndex Index of the light in the enabled light list of the material
  25884. */
  25885. prepareDefines(defines: any, lightIndex: number): void;
  25886. /**
  25887. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  25888. * defined in the generator but impacting the effect).
  25889. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  25890. * @param effect The effect we are binfing the information for
  25891. */
  25892. bindShadowLight(lightIndex: string, effect: Effect): void;
  25893. /**
  25894. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  25895. * (eq to shadow prjection matrix * light transform matrix)
  25896. * @returns The transform matrix used to create the shadow map
  25897. */
  25898. getTransformMatrix(): Matrix;
  25899. /**
  25900. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  25901. * Cube and 2D textures for instance.
  25902. */
  25903. recreateShadowMap(): void;
  25904. private _disposeBlurPostProcesses();
  25905. private _disposeRTTandPostProcesses();
  25906. /**
  25907. * Disposes the ShadowGenerator.
  25908. * Returns nothing.
  25909. */
  25910. dispose(): void;
  25911. /**
  25912. * Serializes the shadow generator setup to a json object.
  25913. * @returns The serialized JSON object
  25914. */
  25915. serialize(): any;
  25916. /**
  25917. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  25918. * @param parsedShadowGenerator The JSON object to parse
  25919. * @param scene The scene to create the shadow map for
  25920. * @returns The parsed shadow generator
  25921. */
  25922. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  25923. }
  25924. }
  25925. declare module BABYLON {
  25926. }
  25927. declare module BABYLON {
  25928. /**
  25929. * Background material used to create an efficient environement around your scene.
  25930. */
  25931. class BackgroundMaterial extends PushMaterial {
  25932. /**
  25933. * Standard reflectance value at parallel view angle.
  25934. */
  25935. static StandardReflectance0: number;
  25936. /**
  25937. * Standard reflectance value at grazing angle.
  25938. */
  25939. static StandardReflectance90: number;
  25940. protected _primaryColor: Color3;
  25941. /**
  25942. * Key light Color (multiply against the R channel of the environement texture)
  25943. */
  25944. primaryColor: Color3;
  25945. protected _primaryLevel: float;
  25946. /**
  25947. * Key light Level (allowing HDR output of the background)
  25948. */
  25949. primaryLevel: float;
  25950. protected _secondaryColor: Color3;
  25951. /**
  25952. * Secondary light Color (multiply against the G channel of the environement texture)
  25953. */
  25954. secondaryColor: Color3;
  25955. protected _secondaryLevel: float;
  25956. /**
  25957. * Secondary light Level (allowing HDR output of the background)
  25958. */
  25959. secondaryLevel: float;
  25960. protected _tertiaryColor: Color3;
  25961. /**
  25962. * Tertiary light Color (multiply against the B channel of the environement texture)
  25963. */
  25964. tertiaryColor: Color3;
  25965. protected _tertiaryLevel: float;
  25966. /**
  25967. * Tertiary light Level (allowing HDR output of the background)
  25968. */
  25969. tertiaryLevel: float;
  25970. protected _reflectionTexture: Nullable<BaseTexture>;
  25971. /**
  25972. * Reflection Texture used in the material.
  25973. * Should be author in a specific way for the best result (refer to the documentation).
  25974. */
  25975. reflectionTexture: Nullable<BaseTexture>;
  25976. protected _reflectionBlur: float;
  25977. /**
  25978. * Reflection Texture level of blur.
  25979. *
  25980. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  25981. * texture twice.
  25982. */
  25983. reflectionBlur: float;
  25984. protected _diffuseTexture: Nullable<BaseTexture>;
  25985. /**
  25986. * Diffuse Texture used in the material.
  25987. * Should be author in a specific way for the best result (refer to the documentation).
  25988. */
  25989. diffuseTexture: Nullable<BaseTexture>;
  25990. protected _shadowLights: Nullable<IShadowLight[]>;
  25991. /**
  25992. * Specify the list of lights casting shadow on the material.
  25993. * All scene shadow lights will be included if null.
  25994. */
  25995. shadowLights: Nullable<IShadowLight[]>;
  25996. protected _shadowBlurScale: int;
  25997. /**
  25998. * For the lights having a blurred shadow generator, this can add a second blur pass in order to reach
  25999. * soft lighting on the background.
  26000. */
  26001. shadowBlurScale: int;
  26002. protected _shadowLevel: float;
  26003. /**
  26004. * Helps adjusting the shadow to a softer level if required.
  26005. * 0 means black shadows and 1 means no shadows.
  26006. */
  26007. shadowLevel: float;
  26008. protected _sceneCenter: Vector3;
  26009. /**
  26010. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  26011. * It is usually zero but might be interesting to modify according to your setup.
  26012. */
  26013. sceneCenter: Vector3;
  26014. protected _opacityFresnel: boolean;
  26015. /**
  26016. * This helps specifying that the material is falling off to the sky box at grazing angle.
  26017. * This helps ensuring a nice transition when the camera goes under the ground.
  26018. */
  26019. opacityFresnel: boolean;
  26020. protected _reflectionFresnel: boolean;
  26021. /**
  26022. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  26023. * This helps adding a mirror texture on the ground.
  26024. */
  26025. reflectionFresnel: boolean;
  26026. protected _reflectionFalloffDistance: number;
  26027. /**
  26028. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  26029. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  26030. */
  26031. reflectionFalloffDistance: number;
  26032. protected _reflectionAmount: number;
  26033. /**
  26034. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  26035. */
  26036. reflectionAmount: number;
  26037. protected _reflectionReflectance0: number;
  26038. /**
  26039. * This specifies the weight of the reflection at grazing angle.
  26040. */
  26041. reflectionReflectance0: number;
  26042. protected _reflectionReflectance90: number;
  26043. /**
  26044. * This specifies the weight of the reflection at a perpendicular point of view.
  26045. */
  26046. reflectionReflectance90: number;
  26047. /**
  26048. * Sets the reflection reflectance fresnel values according to the default standard
  26049. * empirically know to work well :-)
  26050. */
  26051. reflectionStandardFresnelWeight: number;
  26052. protected _useRGBColor: boolean;
  26053. /**
  26054. * Helps to directly use the maps channels instead of their level.
  26055. */
  26056. useRGBColor: boolean;
  26057. protected _enableNoise: boolean;
  26058. /**
  26059. * This helps reducing the banding effect that could occur on the background.
  26060. */
  26061. enableNoise: boolean;
  26062. /**
  26063. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  26064. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  26065. * Recommended to be keep at 1.0 except for special cases.
  26066. */
  26067. fovMultiplier: number;
  26068. private _fovMultiplier;
  26069. /**
  26070. * Enable the FOV adjustment feature controlled by fovMultiplier.
  26071. */
  26072. useEquirectangularFOV: boolean;
  26073. private _maxSimultaneousLights;
  26074. /**
  26075. * Number of Simultaneous lights allowed on the material.
  26076. */
  26077. maxSimultaneousLights: int;
  26078. /**
  26079. * Default configuration related to image processing available in the Background Material.
  26080. */
  26081. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  26082. /**
  26083. * Keep track of the image processing observer to allow dispose and replace.
  26084. */
  26085. private _imageProcessingObserver;
  26086. /**
  26087. * Attaches a new image processing configuration to the PBR Material.
  26088. * @param configuration (if null the scene configuration will be use)
  26089. */
  26090. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  26091. /**
  26092. * Gets the image processing configuration used either in this material.
  26093. */
  26094. /**
  26095. * Sets the Default image processing configuration used either in the this material.
  26096. *
  26097. * If sets to null, the scene one is in use.
  26098. */
  26099. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  26100. /**
  26101. * Gets wether the color curves effect is enabled.
  26102. */
  26103. /**
  26104. * Sets wether the color curves effect is enabled.
  26105. */
  26106. cameraColorCurvesEnabled: boolean;
  26107. /**
  26108. * Gets wether the color grading effect is enabled.
  26109. */
  26110. /**
  26111. * Gets wether the color grading effect is enabled.
  26112. */
  26113. cameraColorGradingEnabled: boolean;
  26114. /**
  26115. * Gets wether tonemapping is enabled or not.
  26116. */
  26117. /**
  26118. * Sets wether tonemapping is enabled or not
  26119. */
  26120. cameraToneMappingEnabled: boolean;
  26121. /**
  26122. * The camera exposure used on this material.
  26123. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  26124. * This corresponds to a photographic exposure.
  26125. */
  26126. /**
  26127. * The camera exposure used on this material.
  26128. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  26129. * This corresponds to a photographic exposure.
  26130. */
  26131. cameraExposure: float;
  26132. /**
  26133. * Gets The camera contrast used on this material.
  26134. */
  26135. /**
  26136. * Sets The camera contrast used on this material.
  26137. */
  26138. cameraContrast: float;
  26139. /**
  26140. * Gets the Color Grading 2D Lookup Texture.
  26141. */
  26142. /**
  26143. * Sets the Color Grading 2D Lookup Texture.
  26144. */
  26145. cameraColorGradingTexture: Nullable<BaseTexture>;
  26146. /**
  26147. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  26148. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  26149. * 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;
  26150. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  26151. */
  26152. /**
  26153. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  26154. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  26155. * 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;
  26156. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  26157. */
  26158. cameraColorCurves: Nullable<ColorCurves>;
  26159. /**
  26160. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  26161. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  26162. */
  26163. switchToBGR: boolean;
  26164. private _renderTargets;
  26165. private _reflectionControls;
  26166. /**
  26167. * Instantiates a Background Material in the given scene
  26168. * @param name The friendly name of the material
  26169. * @param scene The scene to add the material to
  26170. */
  26171. constructor(name: string, scene: Scene);
  26172. /**
  26173. * The entire material has been created in order to prevent overdraw.
  26174. * @returns false
  26175. */
  26176. needAlphaTesting(): boolean;
  26177. /**
  26178. * The entire material has been created in order to prevent overdraw.
  26179. * @returns true if blending is enable
  26180. */
  26181. needAlphaBlending(): boolean;
  26182. /**
  26183. * Checks wether the material is ready to be rendered for a given mesh.
  26184. * @param mesh The mesh to render
  26185. * @param subMesh The submesh to check against
  26186. * @param useInstances Specify wether or not the material is used with instances
  26187. * @returns true if all the dependencies are ready (Textures, Effects...)
  26188. */
  26189. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  26190. /**
  26191. * Build the uniform buffer used in the material.
  26192. */
  26193. buildUniformLayout(): void;
  26194. /**
  26195. * Unbind the material.
  26196. */
  26197. unbind(): void;
  26198. /**
  26199. * Bind only the world matrix to the material.
  26200. * @param world The world matrix to bind.
  26201. */
  26202. bindOnlyWorldMatrix(world: Matrix): void;
  26203. /**
  26204. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  26205. * @param world The world matrix to bind.
  26206. * @param subMesh The submesh to bind for.
  26207. */
  26208. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  26209. /**
  26210. * Dispose the material.
  26211. * @param forceDisposeEffect Force disposal of the associated effect.
  26212. * @param forceDisposeTextures Force disposal of the associated textures.
  26213. */
  26214. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  26215. /**
  26216. * Clones the material.
  26217. * @param name The cloned name.
  26218. * @returns The cloned material.
  26219. */
  26220. clone(name: string): BackgroundMaterial;
  26221. /**
  26222. * Serializes the current material to its JSON representation.
  26223. * @returns The JSON representation.
  26224. */
  26225. serialize(): any;
  26226. /**
  26227. * Gets the class name of the material
  26228. * @returns "BackgroundMaterial"
  26229. */
  26230. getClassName(): string;
  26231. /**
  26232. * Parse a JSON input to create back a background material.
  26233. * @param source The JSON data to parse
  26234. * @param scene The scene to create the parsed material in
  26235. * @param rootUrl The root url of the assets the material depends upon
  26236. * @returns the instantiated BackgroundMaterial.
  26237. */
  26238. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  26239. }
  26240. }
  26241. declare module BABYLON {
  26242. class BaseTexture {
  26243. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  26244. name: string;
  26245. private _hasAlpha;
  26246. hasAlpha: boolean;
  26247. getAlphaFromRGB: boolean;
  26248. level: number;
  26249. coordinatesIndex: number;
  26250. private _coordinatesMode;
  26251. /**
  26252. * How a texture is mapped.
  26253. *
  26254. * | Value | Type | Description |
  26255. * | ----- | ----------------------------------- | ----------- |
  26256. * | 0 | EXPLICIT_MODE | |
  26257. * | 1 | SPHERICAL_MODE | |
  26258. * | 2 | PLANAR_MODE | |
  26259. * | 3 | CUBIC_MODE | |
  26260. * | 4 | PROJECTION_MODE | |
  26261. * | 5 | SKYBOX_MODE | |
  26262. * | 6 | INVCUBIC_MODE | |
  26263. * | 7 | EQUIRECTANGULAR_MODE | |
  26264. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  26265. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  26266. */
  26267. coordinatesMode: number;
  26268. /**
  26269. * | Value | Type | Description |
  26270. * | ----- | ------------------ | ----------- |
  26271. * | 0 | CLAMP_ADDRESSMODE | |
  26272. * | 1 | WRAP_ADDRESSMODE | |
  26273. * | 2 | MIRROR_ADDRESSMODE | |
  26274. */
  26275. wrapU: number;
  26276. /**
  26277. * | Value | Type | Description |
  26278. * | ----- | ------------------ | ----------- |
  26279. * | 0 | CLAMP_ADDRESSMODE | |
  26280. * | 1 | WRAP_ADDRESSMODE | |
  26281. * | 2 | MIRROR_ADDRESSMODE | |
  26282. */
  26283. wrapV: number;
  26284. /**
  26285. * | Value | Type | Description |
  26286. * | ----- | ------------------ | ----------- |
  26287. * | 0 | CLAMP_ADDRESSMODE | |
  26288. * | 1 | WRAP_ADDRESSMODE | |
  26289. * | 2 | MIRROR_ADDRESSMODE | |
  26290. */
  26291. wrapR: number;
  26292. anisotropicFilteringLevel: number;
  26293. isCube: boolean;
  26294. is3D: boolean;
  26295. gammaSpace: boolean;
  26296. invertZ: boolean;
  26297. lodLevelInAlpha: boolean;
  26298. lodGenerationOffset: number;
  26299. lodGenerationScale: number;
  26300. isRenderTarget: boolean;
  26301. readonly uid: string;
  26302. toString(): string;
  26303. getClassName(): string;
  26304. animations: Animation[];
  26305. /**
  26306. * An event triggered when the texture is disposed.
  26307. */
  26308. onDisposeObservable: Observable<BaseTexture>;
  26309. private _onDisposeObserver;
  26310. onDispose: () => void;
  26311. delayLoadState: number;
  26312. private _scene;
  26313. _texture: Nullable<InternalTexture>;
  26314. private _uid;
  26315. readonly isBlocking: boolean;
  26316. constructor(scene: Nullable<Scene>);
  26317. getScene(): Nullable<Scene>;
  26318. getTextureMatrix(): Matrix;
  26319. getReflectionTextureMatrix(): Matrix;
  26320. getInternalTexture(): Nullable<InternalTexture>;
  26321. isReadyOrNotBlocking(): boolean;
  26322. isReady(): boolean;
  26323. getSize(): ISize;
  26324. getBaseSize(): ISize;
  26325. scale(ratio: number): void;
  26326. readonly canRescale: boolean;
  26327. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number): Nullable<InternalTexture>;
  26328. _rebuild(): void;
  26329. delayLoad(): void;
  26330. clone(): Nullable<BaseTexture>;
  26331. readonly textureType: number;
  26332. readonly textureFormat: number;
  26333. readPixels(faceIndex?: number): Nullable<ArrayBufferView>;
  26334. releaseInternalTexture(): void;
  26335. sphericalPolynomial: Nullable<SphericalPolynomial>;
  26336. readonly _lodTextureHigh: Nullable<BaseTexture>;
  26337. readonly _lodTextureMid: Nullable<BaseTexture>;
  26338. readonly _lodTextureLow: Nullable<BaseTexture>;
  26339. dispose(): void;
  26340. serialize(): any;
  26341. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  26342. }
  26343. }
  26344. declare module BABYLON {
  26345. /**
  26346. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  26347. * It can help converting any input color in a desired output one. This can then be used to create effects
  26348. * from sepia, black and white to sixties or futuristic rendering...
  26349. *
  26350. * The only supported format is currently 3dl.
  26351. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table/
  26352. */
  26353. class ColorGradingTexture extends BaseTexture {
  26354. /**
  26355. * The current texture matrix. (will always be identity in color grading texture)
  26356. */
  26357. private _textureMatrix;
  26358. /**
  26359. * The texture URL.
  26360. */
  26361. url: string;
  26362. /**
  26363. * Empty line regex stored for GC.
  26364. */
  26365. private static _noneEmptyLineRegex;
  26366. private _engine;
  26367. /**
  26368. * Instantiates a ColorGradingTexture from the following parameters.
  26369. *
  26370. * @param url The location of the color gradind data (currently only supporting 3dl)
  26371. * @param scene The scene the texture will be used in
  26372. */
  26373. constructor(url: string, scene: Scene);
  26374. /**
  26375. * Returns the texture matrix used in most of the material.
  26376. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  26377. */
  26378. getTextureMatrix(): Matrix;
  26379. /**
  26380. * Occurs when the file being loaded is a .3dl LUT file.
  26381. */
  26382. private load3dlTexture();
  26383. /**
  26384. * Starts the loading process of the texture.
  26385. */
  26386. private loadTexture();
  26387. /**
  26388. * Clones the color gradind texture.
  26389. */
  26390. clone(): ColorGradingTexture;
  26391. /**
  26392. * Called during delayed load for textures.
  26393. */
  26394. delayLoad(): void;
  26395. /**
  26396. * Parses a color grading texture serialized by Babylon.
  26397. * @param parsedTexture The texture information being parsedTexture
  26398. * @param scene The scene to load the texture in
  26399. * @param rootUrl The root url of the data assets to load
  26400. * @return A color gradind texture
  26401. */
  26402. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<ColorGradingTexture>;
  26403. /**
  26404. * Serializes the LUT texture to json format.
  26405. */
  26406. serialize(): any;
  26407. }
  26408. }
  26409. declare module BABYLON {
  26410. class CubeTexture extends BaseTexture {
  26411. url: string;
  26412. coordinatesMode: number;
  26413. /**
  26414. * Gets or sets the center of the bounding box associated with the cube texture
  26415. * It must define where the camera used to render the texture was set
  26416. */
  26417. boundingBoxPosition: Vector3;
  26418. private _boundingBoxSize;
  26419. /**
  26420. * Gets or sets the size of the bounding box associated with the cube texture
  26421. * When defined, the cubemap will switch to local mode
  26422. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  26423. * @example https://www.babylonjs-playground.com/#RNASML
  26424. */
  26425. boundingBoxSize: Vector3;
  26426. private _noMipmap;
  26427. private _files;
  26428. private _extensions;
  26429. private _textureMatrix;
  26430. private _format;
  26431. private _prefiltered;
  26432. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  26433. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any): CubeTexture;
  26434. 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);
  26435. delayLoad(): void;
  26436. getReflectionTextureMatrix(): Matrix;
  26437. setReflectionTextureMatrix(value: Matrix): void;
  26438. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  26439. clone(): CubeTexture;
  26440. }
  26441. }
  26442. declare module BABYLON {
  26443. /**
  26444. * A class extending {BABYLON.Texture} allowing drawing on a texture
  26445. * @see http://doc.babylonjs.com/how_to/dynamictexture
  26446. */
  26447. class DynamicTexture extends Texture {
  26448. private _generateMipMaps;
  26449. private _canvas;
  26450. private _context;
  26451. private _engine;
  26452. /**
  26453. * Creates a {BABYLON.DynamicTexture}
  26454. * @param name defines the name of the texture
  26455. * @param options provides 3 alternatives for width and height of texture, a canvas, object with width and height properties, number for both width and height
  26456. * @param scene defines the scene where you want the texture
  26457. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  26458. * @param samplingMode defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  26459. * @param format defines the texture format to use (default is BABYLON.Engine.TEXTUREFORMAT_RGBA)
  26460. */
  26461. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  26462. /**
  26463. * Gets the current state of canRescale
  26464. */
  26465. readonly canRescale: boolean;
  26466. private _recreate(textureSize);
  26467. /**
  26468. * Scales the texture
  26469. * @param ratio the scale factor to apply to both width and height
  26470. */
  26471. scale(ratio: number): void;
  26472. /**
  26473. * Resizes the texture
  26474. * @param width the new width
  26475. * @param height the new height
  26476. */
  26477. scaleTo(width: number, height: number): void;
  26478. /**
  26479. * Gets the context of the canvas used by the texture
  26480. * @returns the canvas context of the dynamic texture
  26481. */
  26482. getContext(): CanvasRenderingContext2D;
  26483. /**
  26484. * Clears the texture
  26485. */
  26486. clear(): void;
  26487. /**
  26488. * Updates the texture
  26489. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  26490. */
  26491. update(invertY?: boolean): void;
  26492. /**
  26493. * Draws text onto the texture
  26494. * @param text defines the text to be drawn
  26495. * @param x defines the placement of the text from the left
  26496. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  26497. * @param font defines the font to be used with font-style, font-size, font-name
  26498. * @param color defines the color used for the text
  26499. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  26500. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  26501. * @param update defines whether texture is immediately update (default is true)
  26502. */
  26503. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  26504. /**
  26505. * Clones the texture
  26506. * @returns the clone of the texture.
  26507. */
  26508. clone(): DynamicTexture;
  26509. /** @ignore */
  26510. _rebuild(): void;
  26511. }
  26512. }
  26513. declare module BABYLON {
  26514. /**
  26515. * This represents a texture coming from an HDR input.
  26516. *
  26517. * The only supported format is currently panorama picture stored in RGBE format.
  26518. * Example of such files can be found on HDRLib: http://hdrlib.com/
  26519. */
  26520. class HDRCubeTexture extends BaseTexture {
  26521. private static _facesMapping;
  26522. private _useInGammaSpace;
  26523. private _generateHarmonics;
  26524. private _noMipmap;
  26525. private _textureMatrix;
  26526. private _size;
  26527. private _usePMREMGenerator;
  26528. private _isBABYLONPreprocessed;
  26529. private _onLoad;
  26530. private _onError;
  26531. /**
  26532. * The texture URL.
  26533. */
  26534. url: string;
  26535. /**
  26536. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  26537. */
  26538. coordinatesMode: number;
  26539. /**
  26540. * Specifies wether the texture has been generated through the PMREMGenerator tool.
  26541. * This is usefull at run time to apply the good shader.
  26542. */
  26543. isPMREM: boolean;
  26544. protected _isBlocking: boolean;
  26545. /**
  26546. * Gets wether or not the texture is blocking during loading.
  26547. */
  26548. /**
  26549. * Sets wether or not the texture is blocking during loading.
  26550. */
  26551. isBlocking: boolean;
  26552. /**
  26553. * Gets or sets the center of the bounding box associated with the cube texture
  26554. * It must define where the camera used to render the texture was set
  26555. */
  26556. boundingBoxPosition: Vector3;
  26557. private _boundingBoxSize;
  26558. /**
  26559. * Gets or sets the size of the bounding box associated with the cube texture
  26560. * When defined, the cubemap will switch to local mode
  26561. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  26562. * @example https://www.babylonjs-playground.com/#RNASML
  26563. */
  26564. boundingBoxSize: Vector3;
  26565. /**
  26566. * Instantiates an HDRTexture from the following parameters.
  26567. *
  26568. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  26569. * @param scene The scene the texture will be used in
  26570. * @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.
  26571. * @param noMipmap Forces to not generate the mipmap if true
  26572. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  26573. * @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)
  26574. * @param usePMREMGenerator Specifies whether or not to generate the CubeMap through CubeMapGen to avoid seams issue at run time.
  26575. */
  26576. 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>);
  26577. /**
  26578. * Occurs when the file is a preprocessed .babylon.hdr file.
  26579. */
  26580. private loadBabylonTexture();
  26581. /**
  26582. * Occurs when the file is raw .hdr file.
  26583. */
  26584. private loadHDRTexture();
  26585. /**
  26586. * Starts the loading process of the texture.
  26587. */
  26588. private loadTexture();
  26589. clone(): HDRCubeTexture;
  26590. delayLoad(): void;
  26591. getReflectionTextureMatrix(): Matrix;
  26592. setReflectionTextureMatrix(value: Matrix): void;
  26593. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  26594. serialize(): any;
  26595. /**
  26596. * Saves as a file the data contained in the texture in a binary format.
  26597. * This can be used to prevent the long loading tie associated with creating the seamless texture as well
  26598. * as the spherical used in the lighting.
  26599. * @param url The HDR file url.
  26600. * @param size The size of the texture data to generate (one of the cubemap face desired width).
  26601. * @param onError Method called if any error happens during download.
  26602. * @return The packed binary data.
  26603. */
  26604. static generateBabylonHDROnDisk(url: string, size: number, onError?: Nullable<(() => void)>): void;
  26605. /**
  26606. * Serializes the data contained in the texture in a binary format.
  26607. * This can be used to prevent the long loading tie associated with creating the seamless texture as well
  26608. * as the spherical used in the lighting.
  26609. * @param url The HDR file url.
  26610. * @param size The size of the texture data to generate (one of the cubemap face desired width).
  26611. * @param onError Method called if any error happens during download.
  26612. * @return The packed binary data.
  26613. */
  26614. static generateBabylonHDR(url: string, size: number, callback: ((ArrayBuffer: ArrayBuffer) => void), onError?: Nullable<(() => void)>): void;
  26615. }
  26616. }
  26617. declare module BABYLON {
  26618. /**
  26619. * Class used to store data associated with WebGL texture data for the engine
  26620. * This class should not be used directly
  26621. */
  26622. class InternalTexture implements IInternalTextureTracker {
  26623. /**
  26624. * The source of the texture data is unknown
  26625. */
  26626. static DATASOURCE_UNKNOWN: number;
  26627. /**
  26628. * Texture data comes from an URL
  26629. */
  26630. static DATASOURCE_URL: number;
  26631. /**
  26632. * Texture data is only used for temporary storage
  26633. */
  26634. static DATASOURCE_TEMP: number;
  26635. /**
  26636. * Texture data comes from raw data (ArrayBuffer)
  26637. */
  26638. static DATASOURCE_RAW: number;
  26639. /**
  26640. * Texture content is dynamic (video or dynamic texture)
  26641. */
  26642. static DATASOURCE_DYNAMIC: number;
  26643. /**
  26644. * Texture content is generated by rendering to it
  26645. */
  26646. static DATASOURCE_RENDERTARGET: number;
  26647. /**
  26648. * Texture content is part of a multi render target process
  26649. */
  26650. static DATASOURCE_MULTIRENDERTARGET: number;
  26651. /**
  26652. * Texture data comes from a cube data file
  26653. */
  26654. static DATASOURCE_CUBE: number;
  26655. /**
  26656. * Texture data comes from a raw cube data
  26657. */
  26658. static DATASOURCE_CUBERAW: number;
  26659. /**
  26660. * Texture data come from a prefiltered cube data file
  26661. */
  26662. static DATASOURCE_CUBEPREFILTERED: number;
  26663. /**
  26664. * Texture content is raw 3D data
  26665. */
  26666. static DATASOURCE_RAW3D: number;
  26667. /**
  26668. * Texture content is a depth texture
  26669. */
  26670. static DATASOURCE_DEPTHTEXTURE: number;
  26671. /**
  26672. * Defines if the texture is ready
  26673. */
  26674. isReady: boolean;
  26675. /**
  26676. * Defines if the texture is a cube texture
  26677. */
  26678. isCube: boolean;
  26679. /**
  26680. * Defines if the texture contains 3D data
  26681. */
  26682. is3D: boolean;
  26683. /**
  26684. * Gets the URL used to load this texture
  26685. */
  26686. url: string;
  26687. /**
  26688. * Gets the sampling mode of the texture
  26689. */
  26690. samplingMode: number;
  26691. /**
  26692. * Gets a boolean indicating if the texture needs mipmaps generation
  26693. */
  26694. generateMipMaps: boolean;
  26695. /**
  26696. * Gets the number of samples used by the texture (WebGL2+ only)
  26697. */
  26698. samples: number;
  26699. /**
  26700. * Gets the type of the texture
  26701. */
  26702. type: number;
  26703. /**
  26704. * Gets the format of the texture
  26705. */
  26706. format: number;
  26707. /**
  26708. * Observable called when the texture is loaded
  26709. */
  26710. onLoadedObservable: Observable<InternalTexture>;
  26711. /**
  26712. * Gets the width of the texture
  26713. */
  26714. width: number;
  26715. /**
  26716. * Gets the height of the texture
  26717. */
  26718. height: number;
  26719. /**
  26720. * Gets the depth of the texture
  26721. */
  26722. depth: number;
  26723. /**
  26724. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  26725. */
  26726. baseWidth: number;
  26727. /**
  26728. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  26729. */
  26730. baseHeight: number;
  26731. /**
  26732. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  26733. */
  26734. baseDepth: number;
  26735. /**
  26736. * Gets a boolean indicating if the texture is inverted on Y axis
  26737. */
  26738. invertY: boolean;
  26739. /**
  26740. * Gets or set the previous tracker in the list
  26741. */
  26742. previous: Nullable<IInternalTextureTracker>;
  26743. /**
  26744. * Gets or set the next tracker in the list
  26745. */
  26746. next: Nullable<IInternalTextureTracker>;
  26747. /** @ignore */
  26748. _initialSlot: number;
  26749. /** @ignore */
  26750. _designatedSlot: number;
  26751. /** @ignore */
  26752. _dataSource: number;
  26753. /** @ignore */
  26754. _buffer: Nullable<ArrayBuffer | HTMLImageElement>;
  26755. /** @ignore */
  26756. _bufferView: Nullable<ArrayBufferView>;
  26757. /** @ignore */
  26758. _bufferViewArray: Nullable<ArrayBufferView[]>;
  26759. /** @ignore */
  26760. _size: number;
  26761. /** @ignore */
  26762. _extension: string;
  26763. /** @ignore */
  26764. _files: Nullable<string[]>;
  26765. /** @ignore */
  26766. _workingCanvas: HTMLCanvasElement;
  26767. /** @ignore */
  26768. _workingContext: CanvasRenderingContext2D;
  26769. /** @ignore */
  26770. _framebuffer: Nullable<WebGLFramebuffer>;
  26771. /** @ignore */
  26772. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  26773. /** @ignore */
  26774. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  26775. /** @ignore */
  26776. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  26777. /** @ignore */
  26778. _attachments: Nullable<number[]>;
  26779. /** @ignore */
  26780. _cachedCoordinatesMode: Nullable<number>;
  26781. /** @ignore */
  26782. _cachedWrapU: Nullable<number>;
  26783. /** @ignore */
  26784. _cachedWrapV: Nullable<number>;
  26785. /** @ignore */
  26786. _cachedWrapR: Nullable<number>;
  26787. /** @ignore */
  26788. _cachedAnisotropicFilteringLevel: Nullable<number>;
  26789. /** @ignore */
  26790. _isDisabled: boolean;
  26791. /** @ignore */
  26792. _compression: Nullable<string>;
  26793. /** @ignore */
  26794. _generateStencilBuffer: boolean;
  26795. /** @ignore */
  26796. _generateDepthBuffer: boolean;
  26797. /** @ignore */
  26798. _comparisonFunction: number;
  26799. /** @ignore */
  26800. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  26801. /** @ignore */
  26802. _lodGenerationScale: number;
  26803. /** @ignore */
  26804. _lodGenerationOffset: number;
  26805. /** @ignore */
  26806. _lodTextureHigh: BaseTexture;
  26807. /** @ignore */
  26808. _lodTextureMid: BaseTexture;
  26809. /** @ignore */
  26810. _lodTextureLow: BaseTexture;
  26811. /** @ignore */
  26812. _webGLTexture: Nullable<WebGLTexture>;
  26813. /** @ignore */
  26814. _references: number;
  26815. private _engine;
  26816. /**
  26817. * Gets the data source type of the texture (can be one of the BABYLON.InternalTexture.DATASOURCE_XXXX)
  26818. */
  26819. readonly dataSource: number;
  26820. /**
  26821. * Creates a new InternalTexture
  26822. * @param engine defines the engine to use
  26823. * @param dataSource defines the type of data that will be used
  26824. */
  26825. constructor(engine: Engine, dataSource: number);
  26826. /**
  26827. * Increments the number of references (ie. the number of {BABYLON.Texture} that point to it)
  26828. */
  26829. incrementReferences(): void;
  26830. /**
  26831. * Change the size of the texture (not the size of the content)
  26832. * @param width defines the new width
  26833. * @param height defines the new height
  26834. * @param depth defines the new depth (1 by default)
  26835. */
  26836. updateSize(width: int, height: int, depth?: int): void;
  26837. /** @ignore */
  26838. _rebuild(): void;
  26839. private _swapAndDie(target);
  26840. /**
  26841. * Dispose the current allocated resources
  26842. */
  26843. dispose(): void;
  26844. }
  26845. }
  26846. declare module BABYLON {
  26847. /**
  26848. * Internal interface used to track {BABYLON.InternalTexture} already bound to the GL context
  26849. */
  26850. interface IInternalTextureTracker {
  26851. /**
  26852. * Gets or set the previous tracker in the list
  26853. */
  26854. previous: Nullable<IInternalTextureTracker>;
  26855. /**
  26856. * Gets or set the next tracker in the list
  26857. */
  26858. next: Nullable<IInternalTextureTracker>;
  26859. }
  26860. /**
  26861. * Internal class used by the engine to get list of {BABYLON.InternalTexture} already bound to the GL context
  26862. */
  26863. class DummyInternalTextureTracker {
  26864. /**
  26865. * Gets or set the previous tracker in the list
  26866. */
  26867. previous: Nullable<IInternalTextureTracker>;
  26868. /**
  26869. * Gets or set the next tracker in the list
  26870. */
  26871. next: Nullable<IInternalTextureTracker>;
  26872. }
  26873. }
  26874. declare module BABYLON {
  26875. class MirrorTexture extends RenderTargetTexture {
  26876. mirrorPlane: Plane;
  26877. private _transformMatrix;
  26878. private _mirrorMatrix;
  26879. private _savedViewMatrix;
  26880. private _blurX;
  26881. private _blurY;
  26882. private _adaptiveBlurKernel;
  26883. private _blurKernelX;
  26884. private _blurKernelY;
  26885. private _blurRatio;
  26886. blurRatio: number;
  26887. adaptiveBlurKernel: number;
  26888. blurKernel: number;
  26889. blurKernelX: number;
  26890. blurKernelY: number;
  26891. private _autoComputeBlurKernel();
  26892. protected _onRatioRescale(): void;
  26893. constructor(name: string, size: number | {
  26894. width: number;
  26895. height: number;
  26896. } | {
  26897. ratio: number;
  26898. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  26899. private _preparePostProcesses();
  26900. clone(): MirrorTexture;
  26901. serialize(): any;
  26902. }
  26903. }
  26904. declare module BABYLON {
  26905. interface IMultiRenderTargetOptions {
  26906. generateMipMaps?: boolean;
  26907. types?: number[];
  26908. samplingModes?: number[];
  26909. generateDepthBuffer?: boolean;
  26910. generateStencilBuffer?: boolean;
  26911. generateDepthTexture?: boolean;
  26912. textureCount?: number;
  26913. doNotChangeAspectRatio?: boolean;
  26914. defaultType?: number;
  26915. }
  26916. class MultiRenderTarget extends RenderTargetTexture {
  26917. private _internalTextures;
  26918. private _textures;
  26919. readonly isSupported: boolean;
  26920. private _multiRenderTargetOptions;
  26921. readonly textures: Texture[];
  26922. readonly depthTexture: Texture;
  26923. wrapU: number;
  26924. wrapV: number;
  26925. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  26926. _rebuild(): void;
  26927. private _createInternalTextures();
  26928. private _createTextures();
  26929. samples: number;
  26930. resize(size: any): void;
  26931. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  26932. dispose(): void;
  26933. releaseInternalTextures(): void;
  26934. }
  26935. }
  26936. declare module BABYLON {
  26937. class RawTexture extends Texture {
  26938. format: number;
  26939. private _engine;
  26940. constructor(data: ArrayBufferView, width: number, height: number, format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  26941. update(data: ArrayBufferView): void;
  26942. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  26943. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  26944. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  26945. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  26946. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  26947. }
  26948. }
  26949. declare module BABYLON {
  26950. /**
  26951. * Creates a refraction texture used by refraction channel of the standard material.
  26952. * @param name the texture name
  26953. * @param size size of the underlying texture
  26954. * @param scene root scene
  26955. */
  26956. class RefractionTexture extends RenderTargetTexture {
  26957. refractionPlane: Plane;
  26958. depth: number;
  26959. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  26960. clone(): RefractionTexture;
  26961. serialize(): any;
  26962. }
  26963. }
  26964. declare module BABYLON {
  26965. class RenderTargetTexture extends Texture {
  26966. isCube: boolean;
  26967. static _REFRESHRATE_RENDER_ONCE: number;
  26968. static _REFRESHRATE_RENDER_ONEVERYFRAME: number;
  26969. static _REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  26970. static readonly REFRESHRATE_RENDER_ONCE: number;
  26971. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  26972. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  26973. /**
  26974. * Use this predicate to dynamically define the list of mesh you want to render.
  26975. * If set, the renderList property will be overwritten.
  26976. */
  26977. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  26978. /**
  26979. * Use this list to define the list of mesh you want to render.
  26980. */
  26981. renderList: Nullable<Array<AbstractMesh>>;
  26982. renderParticles: boolean;
  26983. renderSprites: boolean;
  26984. coordinatesMode: number;
  26985. activeCamera: Nullable<Camera>;
  26986. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  26987. useCameraPostProcesses: boolean;
  26988. ignoreCameraViewport: boolean;
  26989. private _postProcessManager;
  26990. private _postProcesses;
  26991. private _resizeObserver;
  26992. /**
  26993. * An event triggered when the texture is unbind.
  26994. */
  26995. onBeforeBindObservable: Observable<RenderTargetTexture>;
  26996. /**
  26997. * An event triggered when the texture is unbind.
  26998. */
  26999. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  27000. private _onAfterUnbindObserver;
  27001. onAfterUnbind: () => void;
  27002. /**
  27003. * An event triggered before rendering the texture
  27004. */
  27005. onBeforeRenderObservable: Observable<number>;
  27006. private _onBeforeRenderObserver;
  27007. onBeforeRender: (faceIndex: number) => void;
  27008. /**
  27009. * An event triggered after rendering the texture
  27010. */
  27011. onAfterRenderObservable: Observable<number>;
  27012. private _onAfterRenderObserver;
  27013. onAfterRender: (faceIndex: number) => void;
  27014. /**
  27015. * An event triggered after the texture clear
  27016. */
  27017. onClearObservable: Observable<Engine>;
  27018. private _onClearObserver;
  27019. onClear: (Engine: Engine) => void;
  27020. clearColor: Color4;
  27021. protected _size: number | {
  27022. width: number;
  27023. height: number;
  27024. };
  27025. protected _initialSizeParameter: number | {
  27026. width: number;
  27027. height: number;
  27028. } | {
  27029. ratio: number;
  27030. };
  27031. protected _sizeRatio: Nullable<number>;
  27032. _generateMipMaps: boolean;
  27033. protected _renderingManager: RenderingManager;
  27034. _waitingRenderList: string[];
  27035. protected _doNotChangeAspectRatio: boolean;
  27036. protected _currentRefreshId: number;
  27037. protected _refreshRate: number;
  27038. protected _textureMatrix: Matrix;
  27039. protected _samples: number;
  27040. protected _renderTargetOptions: RenderTargetCreationOptions;
  27041. readonly renderTargetOptions: RenderTargetCreationOptions;
  27042. protected _engine: Engine;
  27043. protected _onRatioRescale(): void;
  27044. /**
  27045. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  27046. * It must define where the camera used to render the texture is set
  27047. */
  27048. boundingBoxPosition: Vector3;
  27049. private _boundingBoxSize;
  27050. /**
  27051. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  27052. * When defined, the cubemap will switch to local mode
  27053. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  27054. * @example https://www.babylonjs-playground.com/#RNASML
  27055. */
  27056. boundingBoxSize: Vector3;
  27057. /**
  27058. * In case the RTT has been created with a depth texture, get the associated
  27059. * depth texture.
  27060. * Otherwise, return null.
  27061. */
  27062. depthStencilTexture: Nullable<InternalTexture>;
  27063. /**
  27064. * Instantiate a render target texture. This is mainly to render of screen the scene to for instance apply post processse
  27065. * or used a shadow, depth texture...
  27066. * @param name The friendly name of the texture
  27067. * @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)
  27068. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  27069. * @param generateMipMaps True if mip maps need to be generated after render.
  27070. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  27071. * @param type The type of the buffer in the RTT (int, half float, float...)
  27072. * @param isCube True if a cube texture needs to be created
  27073. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  27074. * @param generateDepthBuffer True to generate a depth buffer
  27075. * @param generateStencilBuffer True to generate a stencil buffer
  27076. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  27077. */
  27078. constructor(name: string, size: number | {
  27079. width: number;
  27080. height: number;
  27081. } | {
  27082. ratio: number;
  27083. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean);
  27084. /**
  27085. * Creates a depth stencil texture.
  27086. * This is only available in WebGL 2 or with the depth texture extension available.
  27087. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  27088. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  27089. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  27090. */
  27091. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  27092. private _processSizeParameter(size);
  27093. samples: number;
  27094. resetRefreshCounter(): void;
  27095. refreshRate: number;
  27096. addPostProcess(postProcess: PostProcess): void;
  27097. clearPostProcesses(dispose?: boolean): void;
  27098. removePostProcess(postProcess: PostProcess): void;
  27099. _shouldRender(): boolean;
  27100. getRenderSize(): number;
  27101. getRenderWidth(): number;
  27102. getRenderHeight(): number;
  27103. readonly canRescale: boolean;
  27104. scale(ratio: number): void;
  27105. getReflectionTextureMatrix(): Matrix;
  27106. resize(size: number | {
  27107. width: number;
  27108. height: number;
  27109. } | {
  27110. ratio: number;
  27111. }): void;
  27112. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  27113. private _bestReflectionRenderTargetDimension(renderDimension, scale);
  27114. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  27115. private renderToTarget(faceIndex, currentRenderList, currentRenderListLength, useCameraPostProcess, dumpForDebug);
  27116. /**
  27117. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  27118. * This allowed control for front to back rendering or reversly depending of the special needs.
  27119. *
  27120. * @param renderingGroupId The rendering group id corresponding to its index
  27121. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  27122. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  27123. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  27124. */
  27125. 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;
  27126. /**
  27127. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  27128. *
  27129. * @param renderingGroupId The rendering group id corresponding to its index
  27130. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  27131. */
  27132. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  27133. clone(): RenderTargetTexture;
  27134. serialize(): any;
  27135. disposeFramebufferObjects(): void;
  27136. dispose(): void;
  27137. _rebuild(): void;
  27138. /**
  27139. * Clear the info related to rendering groups preventing retention point in material dispose.
  27140. */
  27141. freeRenderingGroups(): void;
  27142. }
  27143. }
  27144. declare module BABYLON {
  27145. class Texture extends BaseTexture {
  27146. static NEAREST_SAMPLINGMODE: number;
  27147. static NEAREST_NEAREST_MIPLINEAR: number;
  27148. static BILINEAR_SAMPLINGMODE: number;
  27149. static LINEAR_LINEAR_MIPNEAREST: number;
  27150. static TRILINEAR_SAMPLINGMODE: number;
  27151. static LINEAR_LINEAR_MIPLINEAR: number;
  27152. static NEAREST_NEAREST_MIPNEAREST: number;
  27153. static NEAREST_LINEAR_MIPNEAREST: number;
  27154. static NEAREST_LINEAR_MIPLINEAR: number;
  27155. static NEAREST_LINEAR: number;
  27156. static NEAREST_NEAREST: number;
  27157. static LINEAR_NEAREST_MIPNEAREST: number;
  27158. static LINEAR_NEAREST_MIPLINEAR: number;
  27159. static LINEAR_LINEAR: number;
  27160. static LINEAR_NEAREST: number;
  27161. static EXPLICIT_MODE: number;
  27162. static SPHERICAL_MODE: number;
  27163. static PLANAR_MODE: number;
  27164. static CUBIC_MODE: number;
  27165. static PROJECTION_MODE: number;
  27166. static SKYBOX_MODE: number;
  27167. static INVCUBIC_MODE: number;
  27168. static EQUIRECTANGULAR_MODE: number;
  27169. static FIXED_EQUIRECTANGULAR_MODE: number;
  27170. static FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  27171. static CLAMP_ADDRESSMODE: number;
  27172. static WRAP_ADDRESSMODE: number;
  27173. static MIRROR_ADDRESSMODE: number;
  27174. /**
  27175. * 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
  27176. */
  27177. static UseSerializedUrlIfAny: boolean;
  27178. url: Nullable<string>;
  27179. uOffset: number;
  27180. vOffset: number;
  27181. uScale: number;
  27182. vScale: number;
  27183. uAng: number;
  27184. vAng: number;
  27185. wAng: number;
  27186. readonly noMipmap: boolean;
  27187. private _noMipmap;
  27188. _invertY: boolean;
  27189. private _rowGenerationMatrix;
  27190. private _cachedTextureMatrix;
  27191. private _projectionModeMatrix;
  27192. private _t0;
  27193. private _t1;
  27194. private _t2;
  27195. private _cachedUOffset;
  27196. private _cachedVOffset;
  27197. private _cachedUScale;
  27198. private _cachedVScale;
  27199. private _cachedUAng;
  27200. private _cachedVAng;
  27201. private _cachedWAng;
  27202. private _cachedProjectionMatrixId;
  27203. private _cachedCoordinatesMode;
  27204. _samplingMode: number;
  27205. private _buffer;
  27206. private _deleteBuffer;
  27207. protected _format: Nullable<number>;
  27208. private _delayedOnLoad;
  27209. private _delayedOnError;
  27210. protected _onLoadObservable: Nullable<Observable<Texture>>;
  27211. protected _isBlocking: boolean;
  27212. isBlocking: boolean;
  27213. readonly samplingMode: number;
  27214. 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);
  27215. updateURL(url: string): void;
  27216. delayLoad(): void;
  27217. updateSamplingMode(samplingMode: number): void;
  27218. private _prepareRowForTextureGeneration(x, y, z, t);
  27219. getTextureMatrix(): Matrix;
  27220. getReflectionTextureMatrix(): Matrix;
  27221. clone(): Texture;
  27222. readonly onLoadObservable: Observable<Texture>;
  27223. serialize(): any;
  27224. getClassName(): string;
  27225. dispose(): void;
  27226. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  27227. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  27228. 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;
  27229. }
  27230. }
  27231. declare module BABYLON {
  27232. /**
  27233. * Settings for finer control over video usage
  27234. */
  27235. interface VideoTextureSettings {
  27236. /**
  27237. * Applies `autoplay` to video, if specified
  27238. */
  27239. autoPlay?: boolean;
  27240. /**
  27241. * Applies `loop` to video, if specified
  27242. */
  27243. loop?: boolean;
  27244. /**
  27245. * Automatically updates internal texture from video at every frame in the render loop
  27246. */
  27247. autoUpdateTexture: boolean;
  27248. }
  27249. class VideoTexture extends Texture {
  27250. /**
  27251. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  27252. */
  27253. readonly autoUpdateTexture: boolean;
  27254. /**
  27255. * The video instance used by the texture internally
  27256. */
  27257. readonly video: HTMLVideoElement;
  27258. private _generateMipMaps;
  27259. private _engine;
  27260. /**
  27261. * Creates a video texture.
  27262. * Sample : https://doc.babylonjs.com/how_to/video_texture
  27263. * @param {string | null} name optional name, will detect from video source, if not defined
  27264. * @param {(string | string[] | HTMLVideoElement)} src can be used to provide an url, array of urls or an already setup HTML video element.
  27265. * @param {BABYLON.Scene} scene is obviously the current scene.
  27266. * @param {boolean} generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  27267. * @param {boolean} invertY is false by default but can be used to invert video on Y axis
  27268. * @param {number} samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  27269. * @param {VideoTextureSettings} [settings] allows finer control over video usage
  27270. */
  27271. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  27272. private _getName(src);
  27273. private _getVideo(src);
  27274. private _createInternalTexture;
  27275. private reset;
  27276. /**
  27277. * Internal method to initiate `update`.
  27278. */
  27279. _rebuild(): void;
  27280. /**
  27281. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  27282. */
  27283. update(): void;
  27284. /**
  27285. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  27286. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  27287. */
  27288. updateTexture(isVisible: boolean): void;
  27289. protected _updateInternalTexture: (e?: Event | undefined) => void;
  27290. /**
  27291. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  27292. * @param url New url.
  27293. */
  27294. updateURL(url: string): void;
  27295. dispose(): void;
  27296. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  27297. minWidth: number;
  27298. maxWidth: number;
  27299. minHeight: number;
  27300. maxHeight: number;
  27301. deviceId: string;
  27302. }): void;
  27303. }
  27304. }
  27305. declare module BABYLON {
  27306. /**
  27307. * The Physically based material base class of BJS.
  27308. *
  27309. * This offers the main features of a standard PBR material.
  27310. * For more information, please refer to the documentation :
  27311. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  27312. */
  27313. abstract class PBRBaseMaterial extends PushMaterial {
  27314. /**
  27315. * Intensity of the direct lights e.g. the four lights available in your scene.
  27316. * This impacts both the direct diffuse and specular highlights.
  27317. */
  27318. protected _directIntensity: number;
  27319. /**
  27320. * Intensity of the emissive part of the material.
  27321. * This helps controlling the emissive effect without modifying the emissive color.
  27322. */
  27323. protected _emissiveIntensity: number;
  27324. /**
  27325. * Intensity of the environment e.g. how much the environment will light the object
  27326. * either through harmonics for rough material or through the refelction for shiny ones.
  27327. */
  27328. protected _environmentIntensity: number;
  27329. /**
  27330. * This is a special control allowing the reduction of the specular highlights coming from the
  27331. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  27332. */
  27333. protected _specularIntensity: number;
  27334. /**
  27335. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  27336. */
  27337. private _lightingInfos;
  27338. /**
  27339. * Debug Control allowing disabling the bump map on this material.
  27340. */
  27341. protected _disableBumpMap: boolean;
  27342. /**
  27343. * AKA Diffuse Texture in standard nomenclature.
  27344. */
  27345. protected _albedoTexture: BaseTexture;
  27346. /**
  27347. * AKA Occlusion Texture in other nomenclature.
  27348. */
  27349. protected _ambientTexture: BaseTexture;
  27350. /**
  27351. * AKA Occlusion Texture Intensity in other nomenclature.
  27352. */
  27353. protected _ambientTextureStrength: number;
  27354. /**
  27355. * Stores the alpha values in a texture.
  27356. */
  27357. protected _opacityTexture: BaseTexture;
  27358. /**
  27359. * Stores the reflection values in a texture.
  27360. */
  27361. protected _reflectionTexture: BaseTexture;
  27362. /**
  27363. * Stores the refraction values in a texture.
  27364. */
  27365. protected _refractionTexture: BaseTexture;
  27366. /**
  27367. * Stores the emissive values in a texture.
  27368. */
  27369. protected _emissiveTexture: BaseTexture;
  27370. /**
  27371. * AKA Specular texture in other nomenclature.
  27372. */
  27373. protected _reflectivityTexture: BaseTexture;
  27374. /**
  27375. * Used to switch from specular/glossiness to metallic/roughness workflow.
  27376. */
  27377. protected _metallicTexture: BaseTexture;
  27378. /**
  27379. * Specifies the metallic scalar of the metallic/roughness workflow.
  27380. * Can also be used to scale the metalness values of the metallic texture.
  27381. */
  27382. protected _metallic: number;
  27383. /**
  27384. * Specifies the roughness scalar of the metallic/roughness workflow.
  27385. * Can also be used to scale the roughness values of the metallic texture.
  27386. */
  27387. protected _roughness: number;
  27388. /**
  27389. * Used to enable roughness/glossiness fetch from a separate chanel depending on the current mode.
  27390. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  27391. */
  27392. protected _microSurfaceTexture: BaseTexture;
  27393. /**
  27394. * Stores surface normal data used to displace a mesh in a texture.
  27395. */
  27396. protected _bumpTexture: BaseTexture;
  27397. /**
  27398. * Stores the pre-calculated light information of a mesh in a texture.
  27399. */
  27400. protected _lightmapTexture: BaseTexture;
  27401. /**
  27402. * The color of a material in ambient lighting.
  27403. */
  27404. protected _ambientColor: Color3;
  27405. /**
  27406. * AKA Diffuse Color in other nomenclature.
  27407. */
  27408. protected _albedoColor: Color3;
  27409. /**
  27410. * AKA Specular Color in other nomenclature.
  27411. */
  27412. protected _reflectivityColor: Color3;
  27413. /**
  27414. * The color applied when light is reflected from a material.
  27415. */
  27416. protected _reflectionColor: Color3;
  27417. /**
  27418. * The color applied when light is emitted from a material.
  27419. */
  27420. protected _emissiveColor: Color3;
  27421. /**
  27422. * AKA Glossiness in other nomenclature.
  27423. */
  27424. protected _microSurface: number;
  27425. /**
  27426. * source material index of refraction (IOR)' / 'destination material IOR.
  27427. */
  27428. protected _indexOfRefraction: number;
  27429. /**
  27430. * Controls if refraction needs to be inverted on Y. This could be usefull for procedural texture.
  27431. */
  27432. protected _invertRefractionY: boolean;
  27433. /**
  27434. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  27435. * Materials half opaque for instance using refraction could benefit from this control.
  27436. */
  27437. protected _linkRefractionWithTransparency: boolean;
  27438. /**
  27439. * Specifies that the material will use the light map as a show map.
  27440. */
  27441. protected _useLightmapAsShadowmap: boolean;
  27442. /**
  27443. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  27444. * makes the reflect vector face the model (under horizon).
  27445. */
  27446. protected _useHorizonOcclusion: boolean;
  27447. /**
  27448. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  27449. * too much the area relying on ambient texture to define their ambient occlusion.
  27450. */
  27451. protected _useRadianceOcclusion: boolean;
  27452. /**
  27453. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  27454. */
  27455. protected _useAlphaFromAlbedoTexture: boolean;
  27456. /**
  27457. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  27458. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  27459. */
  27460. protected _useSpecularOverAlpha: boolean;
  27461. /**
  27462. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  27463. */
  27464. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  27465. /**
  27466. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  27467. */
  27468. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  27469. /**
  27470. * Specifies if the metallic texture contains the roughness information in its green channel.
  27471. */
  27472. protected _useRoughnessFromMetallicTextureGreen: boolean;
  27473. /**
  27474. * Specifies if the metallic texture contains the metallness information in its blue channel.
  27475. */
  27476. protected _useMetallnessFromMetallicTextureBlue: boolean;
  27477. /**
  27478. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  27479. */
  27480. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  27481. /**
  27482. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  27483. */
  27484. protected _useAmbientInGrayScale: boolean;
  27485. /**
  27486. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  27487. * The material will try to infer what glossiness each pixel should be.
  27488. */
  27489. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  27490. /**
  27491. * BJS is using an harcoded light falloff based on a manually sets up range.
  27492. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  27493. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  27494. */
  27495. protected _usePhysicalLightFalloff: boolean;
  27496. /**
  27497. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  27498. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  27499. */
  27500. protected _useRadianceOverAlpha: boolean;
  27501. /**
  27502. * Allows using an object space normal map (instead of tangent space).
  27503. */
  27504. protected _useObjectSpaceNormalMap: boolean;
  27505. /**
  27506. * Allows using the bump map in parallax mode.
  27507. */
  27508. protected _useParallax: boolean;
  27509. /**
  27510. * Allows using the bump map in parallax occlusion mode.
  27511. */
  27512. protected _useParallaxOcclusion: boolean;
  27513. /**
  27514. * Controls the scale bias of the parallax mode.
  27515. */
  27516. protected _parallaxScaleBias: number;
  27517. /**
  27518. * If sets to true, disables all the lights affecting the material.
  27519. */
  27520. protected _disableLighting: boolean;
  27521. /**
  27522. * Number of Simultaneous lights allowed on the material.
  27523. */
  27524. protected _maxSimultaneousLights: number;
  27525. /**
  27526. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  27527. */
  27528. protected _invertNormalMapX: boolean;
  27529. /**
  27530. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  27531. */
  27532. protected _invertNormalMapY: boolean;
  27533. /**
  27534. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  27535. */
  27536. protected _twoSidedLighting: boolean;
  27537. /**
  27538. * Defines the alpha limits in alpha test mode.
  27539. */
  27540. protected _alphaCutOff: number;
  27541. /**
  27542. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  27543. */
  27544. protected _forceAlphaTest: boolean;
  27545. /**
  27546. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  27547. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  27548. */
  27549. protected _useAlphaFresnel: boolean;
  27550. /**
  27551. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  27552. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  27553. */
  27554. protected _useLinearAlphaFresnel: boolean;
  27555. /**
  27556. * The transparency mode of the material.
  27557. */
  27558. protected _transparencyMode: Nullable<number>;
  27559. /**
  27560. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  27561. * from cos thetav and roughness:
  27562. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  27563. */
  27564. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  27565. /**
  27566. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  27567. */
  27568. protected _forceIrradianceInFragment: boolean;
  27569. /**
  27570. * Force normal to face away from face.
  27571. */
  27572. protected _forceNormalForward: boolean;
  27573. /**
  27574. * Default configuration related to image processing available in the PBR Material.
  27575. */
  27576. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  27577. /**
  27578. * Keep track of the image processing observer to allow dispose and replace.
  27579. */
  27580. private _imageProcessingObserver;
  27581. /**
  27582. * Attaches a new image processing configuration to the PBR Material.
  27583. * @param configuration
  27584. */
  27585. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  27586. /**
  27587. * Stores the available render targets.
  27588. */
  27589. private _renderTargets;
  27590. /**
  27591. * Sets the global ambient color for the material used in lighting calculations.
  27592. */
  27593. private _globalAmbientColor;
  27594. /**
  27595. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  27596. */
  27597. private _useLogarithmicDepth;
  27598. /**
  27599. * If set to true, no lighting calculations will be applied.
  27600. */
  27601. private _unlit;
  27602. /**
  27603. * Instantiates a new PBRMaterial instance.
  27604. *
  27605. * @param name The material name
  27606. * @param scene The scene the material will be use in.
  27607. */
  27608. constructor(name: string, scene: Scene);
  27609. /**
  27610. * Gets the name of the material class.
  27611. */
  27612. getClassName(): string;
  27613. /**
  27614. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  27615. */
  27616. /**
  27617. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  27618. */
  27619. useLogarithmicDepth: boolean;
  27620. /**
  27621. * Gets the current transparency mode.
  27622. */
  27623. /**
  27624. * Sets the transparency mode of the material.
  27625. */
  27626. transparencyMode: Nullable<number>;
  27627. /**
  27628. * Returns true if alpha blending should be disabled.
  27629. */
  27630. private readonly _disableAlphaBlending;
  27631. /**
  27632. * Specifies whether or not this material should be rendered in alpha blend mode.
  27633. */
  27634. needAlphaBlending(): boolean;
  27635. /**
  27636. * Specifies if the mesh will require alpha blending.
  27637. * @param mesh - BJS mesh.
  27638. */
  27639. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  27640. /**
  27641. * Specifies whether or not this material should be rendered in alpha test mode.
  27642. */
  27643. needAlphaTesting(): boolean;
  27644. /**
  27645. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  27646. */
  27647. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  27648. /**
  27649. * Gets the texture used for the alpha test.
  27650. */
  27651. getAlphaTestTexture(): BaseTexture;
  27652. /**
  27653. * Stores the reflectivity values based on metallic roughness workflow.
  27654. */
  27655. private static _scaledReflectivity;
  27656. /**
  27657. * Specifies that the submesh is ready to be used.
  27658. * @param mesh - BJS mesh.
  27659. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  27660. * @param useInstances - Specifies that instances should be used.
  27661. * @returns - boolean indicating that the submesh is ready or not.
  27662. */
  27663. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  27664. /**
  27665. * Specifies if the material uses metallic roughness workflow.
  27666. * @returns boolean specifiying if the material uses metallic roughness workflow.
  27667. */
  27668. isMetallicWorkflow(): boolean;
  27669. private _prepareEffect(mesh, defines, onCompiled?, onError?, useInstances?, useClipPlane?);
  27670. private _prepareDefines(mesh, defines, useInstances?, useClipPlane?);
  27671. /**
  27672. * Force shader compilation
  27673. */
  27674. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  27675. clipPlane: boolean;
  27676. }>): void;
  27677. /**
  27678. * Initializes the uniform buffer layout for the shader.
  27679. */
  27680. buildUniformLayout(): void;
  27681. /**
  27682. * Unbinds the textures.
  27683. */
  27684. unbind(): void;
  27685. /**
  27686. * Binds the submesh data.
  27687. * @param world - The world matrix.
  27688. * @param mesh - The BJS mesh.
  27689. * @param subMesh - A submesh of the BJS mesh.
  27690. */
  27691. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  27692. /**
  27693. * Returns the animatable textures.
  27694. * @returns - Array of animatable textures.
  27695. */
  27696. getAnimatables(): IAnimatable[];
  27697. /**
  27698. * Returns the texture used for reflections.
  27699. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  27700. */
  27701. private _getReflectionTexture();
  27702. /**
  27703. * Returns the texture used for refraction or null if none is used.
  27704. * @returns - Refection texture if present. If no refraction texture and refraction
  27705. * is linked with transparency, returns environment texture. Otherwise, returns null.
  27706. */
  27707. private _getRefractionTexture();
  27708. /**
  27709. * Disposes the resources of the material.
  27710. * @param forceDisposeEffect - Forces the disposal of effects.
  27711. * @param forceDisposeTextures - Forces the disposal of all textures.
  27712. */
  27713. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  27714. }
  27715. }
  27716. declare module BABYLON {
  27717. /**
  27718. * The Physically based simple base material of BJS.
  27719. *
  27720. * This enables better naming and convention enforcements on top of the pbrMaterial.
  27721. * It is used as the base class for both the specGloss and metalRough conventions.
  27722. */
  27723. abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  27724. /**
  27725. * Number of Simultaneous lights allowed on the material.
  27726. */
  27727. maxSimultaneousLights: number;
  27728. /**
  27729. * If sets to true, disables all the lights affecting the material.
  27730. */
  27731. disableLighting: boolean;
  27732. /**
  27733. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  27734. */
  27735. environmentTexture: BaseTexture;
  27736. /**
  27737. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  27738. */
  27739. invertNormalMapX: boolean;
  27740. /**
  27741. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  27742. */
  27743. invertNormalMapY: boolean;
  27744. /**
  27745. * Normal map used in the model.
  27746. */
  27747. normalTexture: BaseTexture;
  27748. /**
  27749. * Emissivie color used to self-illuminate the model.
  27750. */
  27751. emissiveColor: Color3;
  27752. /**
  27753. * Emissivie texture used to self-illuminate the model.
  27754. */
  27755. emissiveTexture: BaseTexture;
  27756. /**
  27757. * Occlusion Channel Strenght.
  27758. */
  27759. occlusionStrength: number;
  27760. /**
  27761. * Occlusion Texture of the material (adding extra occlusion effects).
  27762. */
  27763. occlusionTexture: BaseTexture;
  27764. /**
  27765. * Defines the alpha limits in alpha test mode.
  27766. */
  27767. alphaCutOff: number;
  27768. /**
  27769. * Gets the current double sided mode.
  27770. */
  27771. /**
  27772. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  27773. */
  27774. doubleSided: boolean;
  27775. lightmapTexture: BaseTexture;
  27776. useLightmapAsShadowmap: boolean;
  27777. /**
  27778. * Return the active textures of the material.
  27779. */
  27780. getActiveTextures(): BaseTexture[];
  27781. hasTexture(texture: BaseTexture): boolean;
  27782. /**
  27783. * Instantiates a new PBRMaterial instance.
  27784. *
  27785. * @param name The material name
  27786. * @param scene The scene the material will be use in.
  27787. */
  27788. constructor(name: string, scene: Scene);
  27789. getClassName(): string;
  27790. }
  27791. }
  27792. declare module BABYLON {
  27793. /**
  27794. * The Physically based material of BJS.
  27795. *
  27796. * This offers the main features of a standard PBR material.
  27797. * For more information, please refer to the documentation :
  27798. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  27799. */
  27800. class PBRMaterial extends PBRBaseMaterial {
  27801. private static _PBRMATERIAL_OPAQUE;
  27802. /**
  27803. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  27804. */
  27805. static readonly PBRMATERIAL_OPAQUE: number;
  27806. /**
  27807. * Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  27808. */
  27809. private static _PBRMATERIAL_ALPHATEST;
  27810. /**
  27811. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  27812. */
  27813. static readonly PBRMATERIAL_ALPHATEST: number;
  27814. /**
  27815. * Represents the value for Alpha Blend. Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  27816. */
  27817. private static _PBRMATERIAL_ALPHABLEND;
  27818. /**
  27819. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  27820. */
  27821. static readonly PBRMATERIAL_ALPHABLEND: number;
  27822. /**
  27823. * 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.
  27824. * They are also discarded below the alpha cutoff threshold to improve performances.
  27825. */
  27826. private static _PBRMATERIAL_ALPHATESTANDBLEND;
  27827. /**
  27828. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  27829. * They are also discarded below the alpha cutoff threshold to improve performances.
  27830. */
  27831. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  27832. /**
  27833. * Intensity of the direct lights e.g. the four lights available in your scene.
  27834. * This impacts both the direct diffuse and specular highlights.
  27835. */
  27836. directIntensity: number;
  27837. /**
  27838. * Intensity of the emissive part of the material.
  27839. * This helps controlling the emissive effect without modifying the emissive color.
  27840. */
  27841. emissiveIntensity: number;
  27842. /**
  27843. * Intensity of the environment e.g. how much the environment will light the object
  27844. * either through harmonics for rough material or through the refelction for shiny ones.
  27845. */
  27846. environmentIntensity: number;
  27847. /**
  27848. * This is a special control allowing the reduction of the specular highlights coming from the
  27849. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  27850. */
  27851. specularIntensity: number;
  27852. /**
  27853. * Debug Control allowing disabling the bump map on this material.
  27854. */
  27855. disableBumpMap: boolean;
  27856. /**
  27857. * AKA Diffuse Texture in standard nomenclature.
  27858. */
  27859. albedoTexture: BaseTexture;
  27860. /**
  27861. * AKA Occlusion Texture in other nomenclature.
  27862. */
  27863. ambientTexture: BaseTexture;
  27864. /**
  27865. * AKA Occlusion Texture Intensity in other nomenclature.
  27866. */
  27867. ambientTextureStrength: number;
  27868. /**
  27869. * Stores the alpha values in a texture.
  27870. */
  27871. opacityTexture: BaseTexture;
  27872. /**
  27873. * Stores the reflection values in a texture.
  27874. */
  27875. reflectionTexture: Nullable<BaseTexture>;
  27876. /**
  27877. * Stores the emissive values in a texture.
  27878. */
  27879. emissiveTexture: BaseTexture;
  27880. /**
  27881. * AKA Specular texture in other nomenclature.
  27882. */
  27883. reflectivityTexture: BaseTexture;
  27884. /**
  27885. * Used to switch from specular/glossiness to metallic/roughness workflow.
  27886. */
  27887. metallicTexture: BaseTexture;
  27888. /**
  27889. * Specifies the metallic scalar of the metallic/roughness workflow.
  27890. * Can also be used to scale the metalness values of the metallic texture.
  27891. */
  27892. metallic: number;
  27893. /**
  27894. * Specifies the roughness scalar of the metallic/roughness workflow.
  27895. * Can also be used to scale the roughness values of the metallic texture.
  27896. */
  27897. roughness: number;
  27898. /**
  27899. * Used to enable roughness/glossiness fetch from a separate chanel depending on the current mode.
  27900. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  27901. */
  27902. microSurfaceTexture: BaseTexture;
  27903. /**
  27904. * Stores surface normal data used to displace a mesh in a texture.
  27905. */
  27906. bumpTexture: BaseTexture;
  27907. /**
  27908. * Stores the pre-calculated light information of a mesh in a texture.
  27909. */
  27910. lightmapTexture: BaseTexture;
  27911. /**
  27912. * Stores the refracted light information in a texture.
  27913. */
  27914. refractionTexture: BaseTexture;
  27915. /**
  27916. * The color of a material in ambient lighting.
  27917. */
  27918. ambientColor: Color3;
  27919. /**
  27920. * AKA Diffuse Color in other nomenclature.
  27921. */
  27922. albedoColor: Color3;
  27923. /**
  27924. * AKA Specular Color in other nomenclature.
  27925. */
  27926. reflectivityColor: Color3;
  27927. /**
  27928. * The color reflected from the material.
  27929. */
  27930. reflectionColor: Color3;
  27931. /**
  27932. * The color emitted from the material.
  27933. */
  27934. emissiveColor: Color3;
  27935. /**
  27936. * AKA Glossiness in other nomenclature.
  27937. */
  27938. microSurface: number;
  27939. /**
  27940. * source material index of refraction (IOR)' / 'destination material IOR.
  27941. */
  27942. indexOfRefraction: number;
  27943. /**
  27944. * Controls if refraction needs to be inverted on Y. This could be usefull for procedural texture.
  27945. */
  27946. invertRefractionY: boolean;
  27947. /**
  27948. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  27949. * Materials half opaque for instance using refraction could benefit from this control.
  27950. */
  27951. linkRefractionWithTransparency: boolean;
  27952. useLightmapAsShadowmap: boolean;
  27953. /**
  27954. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  27955. */
  27956. useAlphaFromAlbedoTexture: boolean;
  27957. /**
  27958. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  27959. */
  27960. forceAlphaTest: boolean;
  27961. /**
  27962. * Defines the alpha limits in alpha test mode.
  27963. */
  27964. alphaCutOff: number;
  27965. /**
  27966. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  27967. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  27968. */
  27969. useSpecularOverAlpha: boolean;
  27970. /**
  27971. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  27972. */
  27973. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  27974. /**
  27975. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  27976. */
  27977. useRoughnessFromMetallicTextureAlpha: boolean;
  27978. /**
  27979. * Specifies if the metallic texture contains the roughness information in its green channel.
  27980. */
  27981. useRoughnessFromMetallicTextureGreen: boolean;
  27982. /**
  27983. * Specifies if the metallic texture contains the metallness information in its blue channel.
  27984. */
  27985. useMetallnessFromMetallicTextureBlue: boolean;
  27986. /**
  27987. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  27988. */
  27989. useAmbientOcclusionFromMetallicTextureRed: boolean;
  27990. /**
  27991. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  27992. */
  27993. useAmbientInGrayScale: boolean;
  27994. /**
  27995. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  27996. * The material will try to infer what glossiness each pixel should be.
  27997. */
  27998. useAutoMicroSurfaceFromReflectivityMap: boolean;
  27999. /**
  28000. * BJS is using an harcoded light falloff based on a manually sets up range.
  28001. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  28002. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  28003. */
  28004. usePhysicalLightFalloff: boolean;
  28005. /**
  28006. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  28007. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  28008. */
  28009. useRadianceOverAlpha: boolean;
  28010. /**
  28011. * Allows using an object space normal map (instead of tangent space).
  28012. */
  28013. useObjectSpaceNormalMap: boolean;
  28014. /**
  28015. * Allows using the bump map in parallax mode.
  28016. */
  28017. useParallax: boolean;
  28018. /**
  28019. * Allows using the bump map in parallax occlusion mode.
  28020. */
  28021. useParallaxOcclusion: boolean;
  28022. /**
  28023. * Controls the scale bias of the parallax mode.
  28024. */
  28025. parallaxScaleBias: number;
  28026. /**
  28027. * If sets to true, disables all the lights affecting the material.
  28028. */
  28029. disableLighting: boolean;
  28030. /**
  28031. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  28032. */
  28033. forceIrradianceInFragment: boolean;
  28034. /**
  28035. * Number of Simultaneous lights allowed on the material.
  28036. */
  28037. maxSimultaneousLights: number;
  28038. /**
  28039. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  28040. */
  28041. invertNormalMapX: boolean;
  28042. /**
  28043. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  28044. */
  28045. invertNormalMapY: boolean;
  28046. /**
  28047. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  28048. */
  28049. twoSidedLighting: boolean;
  28050. /**
  28051. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  28052. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  28053. */
  28054. useAlphaFresnel: boolean;
  28055. /**
  28056. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  28057. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  28058. */
  28059. useLinearAlphaFresnel: boolean;
  28060. /**
  28061. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  28062. * And/Or occlude the blended part.
  28063. */
  28064. environmentBRDFTexture: Nullable<BaseTexture>;
  28065. /**
  28066. * Force normal to face away from face.
  28067. */
  28068. forceNormalForward: boolean;
  28069. /**
  28070. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  28071. * makes the reflect vector face the model (under horizon).
  28072. */
  28073. useHorizonOcclusion: boolean;
  28074. /**
  28075. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  28076. * too much the area relying on ambient texture to define their ambient occlusion.
  28077. */
  28078. useRadianceOcclusion: boolean;
  28079. /**
  28080. * If set to true, no lighting calculations will be applied.
  28081. */
  28082. unlit: boolean;
  28083. /**
  28084. * Gets the image processing configuration used either in this material.
  28085. */
  28086. /**
  28087. * Sets the Default image processing configuration used either in the this material.
  28088. *
  28089. * If sets to null, the scene one is in use.
  28090. */
  28091. imageProcessingConfiguration: ImageProcessingConfiguration;
  28092. /**
  28093. * Gets wether the color curves effect is enabled.
  28094. */
  28095. /**
  28096. * Sets wether the color curves effect is enabled.
  28097. */
  28098. cameraColorCurvesEnabled: boolean;
  28099. /**
  28100. * Gets wether the color grading effect is enabled.
  28101. */
  28102. /**
  28103. * Gets wether the color grading effect is enabled.
  28104. */
  28105. cameraColorGradingEnabled: boolean;
  28106. /**
  28107. * Gets wether tonemapping is enabled or not.
  28108. */
  28109. /**
  28110. * Sets wether tonemapping is enabled or not
  28111. */
  28112. cameraToneMappingEnabled: boolean;
  28113. /**
  28114. * The camera exposure used on this material.
  28115. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  28116. * This corresponds to a photographic exposure.
  28117. */
  28118. /**
  28119. * The camera exposure used on this material.
  28120. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  28121. * This corresponds to a photographic exposure.
  28122. */
  28123. cameraExposure: number;
  28124. /**
  28125. * Gets The camera contrast used on this material.
  28126. */
  28127. /**
  28128. * Sets The camera contrast used on this material.
  28129. */
  28130. cameraContrast: number;
  28131. /**
  28132. * Gets the Color Grading 2D Lookup Texture.
  28133. */
  28134. /**
  28135. * Sets the Color Grading 2D Lookup Texture.
  28136. */
  28137. cameraColorGradingTexture: Nullable<BaseTexture>;
  28138. /**
  28139. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  28140. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  28141. * 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;
  28142. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  28143. */
  28144. /**
  28145. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  28146. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  28147. * 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;
  28148. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  28149. */
  28150. cameraColorCurves: Nullable<ColorCurves>;
  28151. /**
  28152. * Instantiates a new PBRMaterial instance.
  28153. *
  28154. * @param name The material name
  28155. * @param scene The scene the material will be use in.
  28156. */
  28157. constructor(name: string, scene: Scene);
  28158. /**
  28159. * Returns the name of this material class.
  28160. */
  28161. getClassName(): string;
  28162. /**
  28163. * Returns an array of the actively used textures.
  28164. * @returns - Array of BaseTextures
  28165. */
  28166. getActiveTextures(): BaseTexture[];
  28167. /**
  28168. * Checks to see if a texture is used in the material.
  28169. * @param texture - Base texture to use.
  28170. * @returns - Boolean specifying if a texture is used in the material.
  28171. */
  28172. hasTexture(texture: BaseTexture): boolean;
  28173. /**
  28174. * Makes a duplicate of the current material.
  28175. * @param name - name to use for the new material.
  28176. */
  28177. clone(name: string): PBRMaterial;
  28178. /**
  28179. * Serializes this PBR Material.
  28180. * @returns - An object with the serialized material.
  28181. */
  28182. serialize(): any;
  28183. /**
  28184. * Parses a PBR Material from a serialized object.
  28185. * @param source - Serialized object.
  28186. * @param scene - BJS scene instance.
  28187. * @param rootUrl - url for the scene object
  28188. * @returns - PBRMaterial
  28189. */
  28190. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  28191. }
  28192. }
  28193. declare module BABYLON {
  28194. /**
  28195. * The PBR material of BJS following the metal roughness convention.
  28196. *
  28197. * This fits to the PBR convention in the GLTF definition:
  28198. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  28199. */
  28200. class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  28201. /**
  28202. * The base color has two different interpretations depending on the value of metalness.
  28203. * When the material is a metal, the base color is the specific measured reflectance value
  28204. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  28205. * of the material.
  28206. */
  28207. baseColor: Color3;
  28208. /**
  28209. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  28210. * well as opacity information in the alpha channel.
  28211. */
  28212. baseTexture: BaseTexture;
  28213. /**
  28214. * Specifies the metallic scalar value of the material.
  28215. * Can also be used to scale the metalness values of the metallic texture.
  28216. */
  28217. metallic: number;
  28218. /**
  28219. * Specifies the roughness scalar value of the material.
  28220. * Can also be used to scale the roughness values of the metallic texture.
  28221. */
  28222. roughness: number;
  28223. /**
  28224. * Texture containing both the metallic value in the B channel and the
  28225. * roughness value in the G channel to keep better precision.
  28226. */
  28227. metallicRoughnessTexture: BaseTexture;
  28228. /**
  28229. * Instantiates a new PBRMetalRoughnessMaterial instance.
  28230. *
  28231. * @param name The material name
  28232. * @param scene The scene the material will be use in.
  28233. */
  28234. constructor(name: string, scene: Scene);
  28235. /**
  28236. * Return the currrent class name of the material.
  28237. */
  28238. getClassName(): string;
  28239. /**
  28240. * Return the active textures of the material.
  28241. */
  28242. getActiveTextures(): BaseTexture[];
  28243. /**
  28244. * Checks to see if a texture is used in the material.
  28245. * @param texture - Base texture to use.
  28246. * @returns - Boolean specifying if a texture is used in the material.
  28247. */
  28248. hasTexture(texture: BaseTexture): boolean;
  28249. /**
  28250. * Makes a duplicate of the current material.
  28251. * @param name - name to use for the new material.
  28252. */
  28253. clone(name: string): PBRMetallicRoughnessMaterial;
  28254. /**
  28255. * Serialize the material to a parsable JSON object.
  28256. */
  28257. serialize(): any;
  28258. /**
  28259. * Parses a JSON object correponding to the serialize function.
  28260. */
  28261. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  28262. }
  28263. }
  28264. declare module BABYLON {
  28265. /**
  28266. * The PBR material of BJS following the specular glossiness convention.
  28267. *
  28268. * This fits to the PBR convention in the GLTF definition:
  28269. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  28270. */
  28271. class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  28272. /**
  28273. * Specifies the diffuse color of the material.
  28274. */
  28275. diffuseColor: Color3;
  28276. /**
  28277. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  28278. * channel.
  28279. */
  28280. diffuseTexture: BaseTexture;
  28281. /**
  28282. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  28283. */
  28284. specularColor: Color3;
  28285. /**
  28286. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  28287. */
  28288. glossiness: number;
  28289. /**
  28290. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  28291. */
  28292. specularGlossinessTexture: BaseTexture;
  28293. /**
  28294. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  28295. *
  28296. * @param name The material name
  28297. * @param scene The scene the material will be use in.
  28298. */
  28299. constructor(name: string, scene: Scene);
  28300. /**
  28301. * Return the currrent class name of the material.
  28302. */
  28303. getClassName(): string;
  28304. /**
  28305. * Return the active textures of the material.
  28306. */
  28307. getActiveTextures(): BaseTexture[];
  28308. /**
  28309. * Checks to see if a texture is used in the material.
  28310. * @param texture - Base texture to use.
  28311. * @returns - Boolean specifying if a texture is used in the material.
  28312. */
  28313. hasTexture(texture: BaseTexture): boolean;
  28314. /**
  28315. * Makes a duplicate of the current material.
  28316. * @param name - name to use for the new material.
  28317. */
  28318. clone(name: string): PBRSpecularGlossinessMaterial;
  28319. /**
  28320. * Serialize the material to a parsable JSON object.
  28321. */
  28322. serialize(): any;
  28323. /**
  28324. * Parses a JSON object correponding to the serialize function.
  28325. */
  28326. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  28327. }
  28328. }
  28329. declare module BABYLON {
  28330. /**
  28331. * Particle emitter emitting particles from the inside of a box.
  28332. * It emits the particles randomly between 2 given directions.
  28333. */
  28334. class BoxParticleEmitter implements IParticleEmitterType {
  28335. /**
  28336. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  28337. */
  28338. direction1: Vector3;
  28339. /**
  28340. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  28341. */
  28342. direction2: Vector3;
  28343. /**
  28344. * 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.
  28345. */
  28346. minEmitBox: Vector3;
  28347. /**
  28348. * 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.
  28349. */
  28350. maxEmitBox: Vector3;
  28351. /**
  28352. * Creates a new instance BoxParticleEmitter
  28353. */
  28354. constructor();
  28355. /**
  28356. * Called by the particle System when the direction is computed for the created particle.
  28357. * @param emitPower is the power of the particle (speed)
  28358. * @param worldMatrix is the world matrix of the particle system
  28359. * @param directionToUpdate is the direction vector to update with the result
  28360. * @param particle is the particle we are computed the direction for
  28361. */
  28362. startDirectionFunction(emitPower: number, worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  28363. /**
  28364. * Called by the particle System when the position is computed for the created particle.
  28365. * @param worldMatrix is the world matrix of the particle system
  28366. * @param positionToUpdate is the position vector to update with the result
  28367. * @param particle is the particle we are computed the position for
  28368. */
  28369. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  28370. /**
  28371. * Clones the current emitter and returns a copy of it
  28372. * @returns the new emitter
  28373. */
  28374. clone(): BoxParticleEmitter;
  28375. /**
  28376. * Called by the {BABYLON.GPUParticleSystem} to setup the update shader
  28377. * @param effect defines the update shader
  28378. */
  28379. applyToShader(effect: Effect): void;
  28380. /**
  28381. * Returns a string to use to update the GPU particles update shader
  28382. * @returns a string containng the defines string
  28383. */
  28384. getEffectDefines(): string;
  28385. /**
  28386. * Returns the string "BoxEmitter"
  28387. * @returns a string containing the class name
  28388. */
  28389. getClassName(): string;
  28390. /**
  28391. * Serializes the particle system to a JSON object.
  28392. * @returns the JSON object
  28393. */
  28394. serialize(): any;
  28395. /**
  28396. * Parse properties from a JSON object
  28397. * @param serializationObject defines the JSON object
  28398. */
  28399. parse(serializationObject: any): void;
  28400. }
  28401. }
  28402. declare module BABYLON {
  28403. /**
  28404. * Particle emitter emitting particles from the inside of a cone.
  28405. * It emits the particles alongside the cone volume from the base to the particle.
  28406. * The emission direction might be randomized.
  28407. */
  28408. class ConeParticleEmitter implements IParticleEmitterType {
  28409. /**
  28410. * The radius of the emission cone.
  28411. */
  28412. angle: number;
  28413. /**
  28414. * The cone base angle.
  28415. */
  28416. directionRandomizer: number;
  28417. private _radius;
  28418. private _height;
  28419. /**
  28420. * Gets the radius of the emission cone.
  28421. */
  28422. /**
  28423. * Sets the radius of the emission cone.
  28424. */
  28425. radius: number;
  28426. /**
  28427. * Creates a new instance ConeParticleEmitter
  28428. * @param radius the radius of the emission cone (1 by default)
  28429. * @param angles the cone base angle (PI by default)
  28430. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  28431. */
  28432. constructor(radius?: number,
  28433. /**
  28434. * The radius of the emission cone.
  28435. */
  28436. angle?: number,
  28437. /**
  28438. * The cone base angle.
  28439. */
  28440. directionRandomizer?: number);
  28441. /**
  28442. * Called by the particle System when the direction is computed for the created particle.
  28443. * @param emitPower is the power of the particle (speed)
  28444. * @param worldMatrix is the world matrix of the particle system
  28445. * @param directionToUpdate is the direction vector to update with the result
  28446. * @param particle is the particle we are computed the direction for
  28447. */
  28448. startDirectionFunction(emitPower: number, worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  28449. /**
  28450. * Called by the particle System when the position is computed for the created particle.
  28451. * @param worldMatrix is the world matrix of the particle system
  28452. * @param positionToUpdate is the position vector to update with the result
  28453. * @param particle is the particle we are computed the position for
  28454. */
  28455. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  28456. /**
  28457. * Clones the current emitter and returns a copy of it
  28458. * @returns the new emitter
  28459. */
  28460. clone(): ConeParticleEmitter;
  28461. /**
  28462. * Called by the {BABYLON.GPUParticleSystem} to setup the update shader
  28463. * @param effect defines the update shader
  28464. */
  28465. applyToShader(effect: Effect): void;
  28466. /**
  28467. * Returns a string to use to update the GPU particles update shader
  28468. * @returns a string containng the defines string
  28469. */
  28470. getEffectDefines(): string;
  28471. /**
  28472. * Returns the string "BoxEmitter"
  28473. * @returns a string containing the class name
  28474. */
  28475. getClassName(): string;
  28476. /**
  28477. * Serializes the particle system to a JSON object.
  28478. * @returns the JSON object
  28479. */
  28480. serialize(): any;
  28481. /**
  28482. * Parse properties from a JSON object
  28483. * @param serializationObject defines the JSON object
  28484. */
  28485. parse(serializationObject: any): void;
  28486. }
  28487. }
  28488. declare module BABYLON {
  28489. /**
  28490. * Particle emitter represents a volume emitting particles.
  28491. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  28492. */
  28493. interface IParticleEmitterType {
  28494. /**
  28495. * Called by the particle System when the direction is computed for the created particle.
  28496. * @param emitPower is the power of the particle (speed)
  28497. * @param worldMatrix is the world matrix of the particle system
  28498. * @param directionToUpdate is the direction vector to update with the result
  28499. * @param particle is the particle we are computed the direction for
  28500. */
  28501. startDirectionFunction(emitPower: number, worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  28502. /**
  28503. * Called by the particle System when the position is computed for the created particle.
  28504. * @param worldMatrix is the world matrix of the particle system
  28505. * @param positionToUpdate is the position vector to update with the result
  28506. * @param particle is the particle we are computed the position for
  28507. */
  28508. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  28509. /**
  28510. * Clones the current emitter and returns a copy of it
  28511. * @returns the new emitter
  28512. */
  28513. clone(): IParticleEmitterType;
  28514. /**
  28515. * Called by the {BABYLON.GPUParticleSystem} to setup the update shader
  28516. * @param effect defines the update shader
  28517. */
  28518. applyToShader(effect: Effect): void;
  28519. /**
  28520. * Returns a string to use to update the GPU particles update shader
  28521. * @returns the effect defines string
  28522. */
  28523. getEffectDefines(): string;
  28524. /**
  28525. * Returns a string representing the class name
  28526. * @returns a string containing the class name
  28527. */
  28528. getClassName(): string;
  28529. /**
  28530. * Serializes the particle system to a JSON object.
  28531. * @returns the JSON object
  28532. */
  28533. serialize(): any;
  28534. /**
  28535. * Parse properties from a JSON object
  28536. * @param serializationObject defines the JSON object
  28537. */
  28538. parse(serializationObject: any): void;
  28539. }
  28540. }
  28541. declare module BABYLON {
  28542. /**
  28543. * Particle emitter emitting particles from the inside of a sphere.
  28544. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  28545. */
  28546. class SphereParticleEmitter implements IParticleEmitterType {
  28547. /**
  28548. * The radius of the emission sphere.
  28549. */
  28550. radius: number;
  28551. /**
  28552. * How much to randomize the particle direction [0-1].
  28553. */
  28554. directionRandomizer: number;
  28555. /**
  28556. * Creates a new instance SphereParticleEmitter
  28557. * @param radius the radius of the emission sphere (1 by default)
  28558. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  28559. */
  28560. constructor(
  28561. /**
  28562. * The radius of the emission sphere.
  28563. */
  28564. radius?: number,
  28565. /**
  28566. * How much to randomize the particle direction [0-1].
  28567. */
  28568. directionRandomizer?: number);
  28569. /**
  28570. * Called by the particle System when the direction is computed for the created particle.
  28571. * @param emitPower is the power of the particle (speed)
  28572. * @param worldMatrix is the world matrix of the particle system
  28573. * @param directionToUpdate is the direction vector to update with the result
  28574. * @param particle is the particle we are computed the direction for
  28575. */
  28576. startDirectionFunction(emitPower: number, worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  28577. /**
  28578. * Called by the particle System when the position is computed for the created particle.
  28579. * @param worldMatrix is the world matrix of the particle system
  28580. * @param positionToUpdate is the position vector to update with the result
  28581. * @param particle is the particle we are computed the position for
  28582. */
  28583. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  28584. /**
  28585. * Clones the current emitter and returns a copy of it
  28586. * @returns the new emitter
  28587. */
  28588. clone(): SphereParticleEmitter;
  28589. /**
  28590. * Called by the {BABYLON.GPUParticleSystem} to setup the update shader
  28591. * @param effect defines the update shader
  28592. */
  28593. applyToShader(effect: Effect): void;
  28594. /**
  28595. * Returns a string to use to update the GPU particles update shader
  28596. * @returns a string containng the defines string
  28597. */
  28598. getEffectDefines(): string;
  28599. /**
  28600. * Returns the string "SphereParticleEmitter"
  28601. * @returns a string containing the class name
  28602. */
  28603. getClassName(): string;
  28604. /**
  28605. * Serializes the particle system to a JSON object.
  28606. * @returns the JSON object
  28607. */
  28608. serialize(): any;
  28609. /**
  28610. * Parse properties from a JSON object
  28611. * @param serializationObject defines the JSON object
  28612. */
  28613. parse(serializationObject: any): void;
  28614. }
  28615. /**
  28616. * Particle emitter emitting particles from the inside of a sphere.
  28617. * It emits the particles randomly between two vectors.
  28618. */
  28619. class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  28620. /**
  28621. * The min limit of the emission direction.
  28622. */
  28623. direction1: Vector3;
  28624. /**
  28625. * The max limit of the emission direction.
  28626. */
  28627. direction2: Vector3;
  28628. /**
  28629. * Creates a new instance SphereDirectedParticleEmitter
  28630. * @param radius the radius of the emission sphere (1 by default)
  28631. * @param direction1 the min limit of the emission direction (up vector by default)
  28632. * @param direction2 the max limit of the emission direction (up vector by default)
  28633. */
  28634. constructor(radius?: number,
  28635. /**
  28636. * The min limit of the emission direction.
  28637. */
  28638. direction1?: Vector3,
  28639. /**
  28640. * The max limit of the emission direction.
  28641. */
  28642. direction2?: Vector3);
  28643. /**
  28644. * Called by the particle System when the direction is computed for the created particle.
  28645. * @param emitPower is the power of the particle (speed)
  28646. * @param worldMatrix is the world matrix of the particle system
  28647. * @param directionToUpdate is the direction vector to update with the result
  28648. * @param particle is the particle we are computed the direction for
  28649. */
  28650. startDirectionFunction(emitPower: number, worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  28651. /**
  28652. * Clones the current emitter and returns a copy of it
  28653. * @returns the new emitter
  28654. */
  28655. clone(): SphereDirectedParticleEmitter;
  28656. /**
  28657. * Called by the {BABYLON.GPUParticleSystem} to setup the update shader
  28658. * @param effect defines the update shader
  28659. */
  28660. applyToShader(effect: Effect): void;
  28661. /**
  28662. * Returns a string to use to update the GPU particles update shader
  28663. * @returns a string containng the defines string
  28664. */
  28665. getEffectDefines(): string;
  28666. /**
  28667. * Returns the string "SphereDirectedParticleEmitter"
  28668. * @returns a string containing the class name
  28669. */
  28670. getClassName(): string;
  28671. /**
  28672. * Serializes the particle system to a JSON object.
  28673. * @returns the JSON object
  28674. */
  28675. serialize(): any;
  28676. /**
  28677. * Parse properties from a JSON object
  28678. * @param serializationObject defines the JSON object
  28679. */
  28680. parse(serializationObject: any): void;
  28681. }
  28682. }
  28683. declare var DracoDecoderModule: any;
  28684. declare module BABYLON {
  28685. /**
  28686. * Draco compression (https://google.github.io/draco/)
  28687. */
  28688. class DracoCompression implements IDisposable {
  28689. private _workerPool;
  28690. /**
  28691. * Gets the url to the draco decoder if available.
  28692. */
  28693. static DecoderUrl: Nullable<string>;
  28694. /**
  28695. * Constructor
  28696. * @param numWorkers The number of workers for async operations
  28697. */
  28698. constructor(numWorkers?: number);
  28699. /**
  28700. * Stop all async operations and release resources.
  28701. */
  28702. dispose(): void;
  28703. /**
  28704. * Decode Draco compressed mesh data to vertex data.
  28705. * @param data The array buffer view for the Draco compression data
  28706. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  28707. * @returns A promise that resolves with the decoded vertex data
  28708. */
  28709. decodeMeshAsync(data: ArrayBufferView, attributes: {
  28710. [kind: string]: number;
  28711. }): Promise<VertexData>;
  28712. /**
  28713. * The worker function that gets converted to a blob url to pass into a worker.
  28714. */
  28715. private static _Worker();
  28716. private static _GetDefaultDecoderUrl();
  28717. }
  28718. }
  28719. declare module BABYLON {
  28720. class CannonJSPlugin implements IPhysicsEnginePlugin {
  28721. private _useDeltaForWorldStep;
  28722. world: any;
  28723. name: string;
  28724. private _physicsMaterials;
  28725. private _fixedTimeStep;
  28726. BJSCANNON: any;
  28727. constructor(_useDeltaForWorldStep?: boolean, iterations?: number);
  28728. setGravity(gravity: Vector3): void;
  28729. setTimeStep(timeStep: number): void;
  28730. getTimeStep(): number;
  28731. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  28732. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  28733. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  28734. generatePhysicsBody(impostor: PhysicsImpostor): void;
  28735. private _processChildMeshes(mainImpostor);
  28736. removePhysicsBody(impostor: PhysicsImpostor): void;
  28737. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  28738. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  28739. private _addMaterial(name, friction, restitution);
  28740. private _checkWithEpsilon(value);
  28741. private _createShape(impostor);
  28742. private _createHeightmap(object, pointDepth?);
  28743. private _minus90X;
  28744. private _plus90X;
  28745. private _tmpPosition;
  28746. private _tmpDeltaPosition;
  28747. private _tmpUnityRotation;
  28748. private _updatePhysicsBodyTransformation(impostor);
  28749. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  28750. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  28751. isSupported(): boolean;
  28752. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  28753. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  28754. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  28755. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  28756. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  28757. getBodyMass(impostor: PhysicsImpostor): number;
  28758. getBodyFriction(impostor: PhysicsImpostor): number;
  28759. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  28760. getBodyRestitution(impostor: PhysicsImpostor): number;
  28761. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  28762. sleepBody(impostor: PhysicsImpostor): void;
  28763. wakeUpBody(impostor: PhysicsImpostor): void;
  28764. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  28765. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  28766. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  28767. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  28768. getRadius(impostor: PhysicsImpostor): number;
  28769. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  28770. dispose(): void;
  28771. private _extendNamespace();
  28772. }
  28773. }
  28774. declare module BABYLON {
  28775. class OimoJSPlugin implements IPhysicsEnginePlugin {
  28776. world: any;
  28777. name: string;
  28778. BJSOIMO: any;
  28779. constructor(iterations?: number);
  28780. setGravity(gravity: Vector3): void;
  28781. setTimeStep(timeStep: number): void;
  28782. getTimeStep(): number;
  28783. private _tmpImpostorsArray;
  28784. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  28785. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  28786. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  28787. generatePhysicsBody(impostor: PhysicsImpostor): void;
  28788. private _tmpPositionVector;
  28789. removePhysicsBody(impostor: PhysicsImpostor): void;
  28790. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  28791. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  28792. isSupported(): boolean;
  28793. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  28794. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  28795. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  28796. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  28797. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  28798. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  28799. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  28800. getBodyMass(impostor: PhysicsImpostor): number;
  28801. getBodyFriction(impostor: PhysicsImpostor): number;
  28802. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  28803. getBodyRestitution(impostor: PhysicsImpostor): number;
  28804. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  28805. sleepBody(impostor: PhysicsImpostor): void;
  28806. wakeUpBody(impostor: PhysicsImpostor): void;
  28807. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  28808. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  28809. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  28810. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  28811. getRadius(impostor: PhysicsImpostor): number;
  28812. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  28813. dispose(): void;
  28814. }
  28815. }
  28816. declare module BABYLON {
  28817. /**
  28818. * This represents a set of one or more post processes in Babylon.
  28819. * A post process can be used to apply a shader to a texture after it is rendered.
  28820. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  28821. */
  28822. class PostProcessRenderEffect {
  28823. private _postProcesses;
  28824. private _getPostProcesses;
  28825. private _singleInstance;
  28826. private _cameras;
  28827. private _indicesForCamera;
  28828. /**
  28829. * Name of the effect
  28830. */
  28831. _name: string;
  28832. /**
  28833. * Instantiates a post process render effect.
  28834. * A post process can be used to apply a shader to a texture after it is rendered.
  28835. * @param engine The engine the effect is tied to
  28836. * @param name The name of the effect
  28837. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  28838. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  28839. */
  28840. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  28841. /**
  28842. * Checks if all the post processes in the effect are supported.
  28843. */
  28844. readonly isSupported: boolean;
  28845. /**
  28846. * Updates the current state of the effect
  28847. */
  28848. _update(): void;
  28849. /**
  28850. * Attaches the effect on cameras
  28851. * @param cameras The camera to attach to.
  28852. */
  28853. _attachCameras(cameras: Camera): void;
  28854. /**
  28855. * Attaches the effect on cameras
  28856. * @param cameras The camera to attach to.
  28857. */
  28858. _attachCameras(cameras: Camera[]): void;
  28859. /**
  28860. * Detatches the effect on cameras
  28861. * @param cameras The camera to detatch from.
  28862. */
  28863. _detachCameras(cameras: Camera): void;
  28864. /**
  28865. * Detatches the effect on cameras
  28866. * @param cameras The camera to detatch from.
  28867. */
  28868. _detachCameras(cameras: Camera[]): void;
  28869. /**
  28870. * Enables the effect on given cameras
  28871. * @param cameras The camera to enable.
  28872. */
  28873. _enable(cameras: Camera): void;
  28874. /**
  28875. * Enables the effect on given cameras
  28876. * @param cameras The camera to enable.
  28877. */
  28878. _enable(cameras: Nullable<Camera[]>): void;
  28879. /**
  28880. * Disables the effect on the given cameras
  28881. * @param cameras The camera to disable.
  28882. */
  28883. _disable(cameras: Camera): void;
  28884. /**
  28885. * Disables the effect on the given cameras
  28886. * @param cameras The camera to disable.
  28887. */
  28888. _disable(cameras: Nullable<Camera[]>): void;
  28889. /**
  28890. * Gets a list of the post processes contained in the effect.
  28891. * @param camera The camera to get the post processes on.
  28892. * @returns The list of the post processes in the effect.
  28893. */
  28894. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  28895. }
  28896. }
  28897. declare module BABYLON {
  28898. class PostProcessRenderPipeline {
  28899. private engine;
  28900. private _renderEffects;
  28901. private _renderEffectsForIsolatedPass;
  28902. protected _cameras: Camera[];
  28903. _name: string;
  28904. constructor(engine: Engine, name: string);
  28905. getClassName(): string;
  28906. readonly isSupported: boolean;
  28907. addEffect(renderEffect: PostProcessRenderEffect): void;
  28908. _rebuild(): void;
  28909. _enableEffect(renderEffectName: string, cameras: Camera): void;
  28910. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  28911. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  28912. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  28913. _attachCameras(cameras: Camera, unique: boolean): void;
  28914. _attachCameras(cameras: Camera[], unique: boolean): void;
  28915. _detachCameras(cameras: Camera): void;
  28916. _detachCameras(cameras: Nullable<Camera[]>): void;
  28917. _update(): void;
  28918. _reset(): void;
  28919. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  28920. dispose(): void;
  28921. }
  28922. }
  28923. declare module BABYLON {
  28924. class PostProcessRenderPipelineManager {
  28925. private _renderPipelines;
  28926. constructor();
  28927. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  28928. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: Camera, unique?: boolean): void;
  28929. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: Camera[], unique?: boolean): void;
  28930. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: Camera): void;
  28931. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: Camera[]): void;
  28932. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: Camera): void;
  28933. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: Camera[]): void;
  28934. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: Camera): void;
  28935. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: Camera[]): void;
  28936. update(): void;
  28937. _rebuild(): void;
  28938. dispose(): void;
  28939. }
  28940. }
  28941. declare module BABYLON {
  28942. /**
  28943. * Helper class dealing with the extraction of spherical polynomial dataArray
  28944. * from a cube map.
  28945. */
  28946. class CubeMapToSphericalPolynomialTools {
  28947. private static FileFaces;
  28948. /**
  28949. * Converts a texture to the according Spherical Polynomial data.
  28950. * This extracts the first 3 orders only as they are the only one used in the lighting.
  28951. *
  28952. * @param texture The texture to extract the information from.
  28953. * @return The Spherical Polynomial data.
  28954. */
  28955. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  28956. /**
  28957. * Converts a cubemap to the according Spherical Polynomial data.
  28958. * This extracts the first 3 orders only as they are the only one used in the lighting.
  28959. *
  28960. * @param cubeInfo The Cube map to extract the information from.
  28961. * @return The Spherical Polynomial data.
  28962. */
  28963. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  28964. }
  28965. }
  28966. declare module BABYLON {
  28967. /**
  28968. * Header information of HDR texture files.
  28969. */
  28970. interface HDRInfo {
  28971. /**
  28972. * The height of the texture in pixels.
  28973. */
  28974. height: number;
  28975. /**
  28976. * The width of the texture in pixels.
  28977. */
  28978. width: number;
  28979. /**
  28980. * The index of the beginning of the data in the binary file.
  28981. */
  28982. dataPosition: number;
  28983. }
  28984. /**
  28985. * This groups tools to convert HDR texture to native colors array.
  28986. */
  28987. class HDRTools {
  28988. private static Ldexp(mantissa, exponent);
  28989. private static Rgbe2float(float32array, red, green, blue, exponent, index);
  28990. private static readStringLine(uint8array, startIndex);
  28991. /**
  28992. * Reads header information from an RGBE texture stored in a native array.
  28993. * More information on this format are available here:
  28994. * https://en.wikipedia.org/wiki/RGBE_image_format
  28995. *
  28996. * @param uint8array The binary file stored in native array.
  28997. * @return The header information.
  28998. */
  28999. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  29000. /**
  29001. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  29002. * This RGBE texture needs to store the information as a panorama.
  29003. *
  29004. * More information on this format are available here:
  29005. * https://en.wikipedia.org/wiki/RGBE_image_format
  29006. *
  29007. * @param buffer The binary file stored in an array buffer.
  29008. * @param size The expected size of the extracted cubemap.
  29009. * @return The Cube Map information.
  29010. */
  29011. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  29012. /**
  29013. * Returns the pixels data extracted from an RGBE texture.
  29014. * This pixels will be stored left to right up to down in the R G B order in one array.
  29015. *
  29016. * More information on this format are available here:
  29017. * https://en.wikipedia.org/wiki/RGBE_image_format
  29018. *
  29019. * @param uint8array The binary file stored in an array buffer.
  29020. * @param hdrInfo The header information of the file.
  29021. * @return The pixels data in RGB right to left up to down order.
  29022. */
  29023. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  29024. private static RGBE_ReadPixels_RLE(uint8array, hdrInfo);
  29025. }
  29026. }
  29027. declare module BABYLON {
  29028. /**
  29029. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  29030. */
  29031. interface CubeMapInfo {
  29032. /**
  29033. * The pixel array for the front face.
  29034. * This is stored in format, left to right, up to down format.
  29035. */
  29036. front: Nullable<ArrayBufferView>;
  29037. /**
  29038. * The pixel array for the back face.
  29039. * This is stored in format, left to right, up to down format.
  29040. */
  29041. back: Nullable<ArrayBufferView>;
  29042. /**
  29043. * The pixel array for the left face.
  29044. * This is stored in format, left to right, up to down format.
  29045. */
  29046. left: Nullable<ArrayBufferView>;
  29047. /**
  29048. * The pixel array for the right face.
  29049. * This is stored in format, left to right, up to down format.
  29050. */
  29051. right: Nullable<ArrayBufferView>;
  29052. /**
  29053. * The pixel array for the up face.
  29054. * This is stored in format, left to right, up to down format.
  29055. */
  29056. up: Nullable<ArrayBufferView>;
  29057. /**
  29058. * The pixel array for the down face.
  29059. * This is stored in format, left to right, up to down format.
  29060. */
  29061. down: Nullable<ArrayBufferView>;
  29062. /**
  29063. * The size of the cubemap stored.
  29064. *
  29065. * Each faces will be size * size pixels.
  29066. */
  29067. size: number;
  29068. /**
  29069. * The format of the texture.
  29070. *
  29071. * RGBA, RGB.
  29072. */
  29073. format: number;
  29074. /**
  29075. * The type of the texture data.
  29076. *
  29077. * UNSIGNED_INT, FLOAT.
  29078. */
  29079. type: number;
  29080. /**
  29081. * Specifies whether the texture is in gamma space.
  29082. */
  29083. gammaSpace: boolean;
  29084. }
  29085. /**
  29086. * Helper class usefull to convert panorama picture to their cubemap representation in 6 faces.
  29087. */
  29088. class PanoramaToCubeMapTools {
  29089. private static FACE_FRONT;
  29090. private static FACE_BACK;
  29091. private static FACE_RIGHT;
  29092. private static FACE_LEFT;
  29093. private static FACE_DOWN;
  29094. private static FACE_UP;
  29095. /**
  29096. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  29097. *
  29098. * @param float32Array The source data.
  29099. * @param inputWidth The width of the input panorama.
  29100. * @param inputhHeight The height of the input panorama.
  29101. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  29102. * @return The cubemap data
  29103. */
  29104. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  29105. private static CreateCubemapTexture(texSize, faceData, float32Array, inputWidth, inputHeight);
  29106. private static CalcProjectionSpherical(vDir, float32Array, inputWidth, inputHeight);
  29107. }
  29108. }
  29109. declare module BABYLON {
  29110. class CustomProceduralTexture extends ProceduralTexture {
  29111. private _animate;
  29112. private _time;
  29113. private _config;
  29114. private _texturePath;
  29115. constructor(name: string, texturePath: any, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  29116. private loadJson(jsonUrl);
  29117. isReady(): boolean;
  29118. render(useCameraPostProcess?: boolean): void;
  29119. updateTextures(): void;
  29120. updateShaderUniforms(): void;
  29121. animate: boolean;
  29122. }
  29123. }
  29124. declare module BABYLON {
  29125. class ProceduralTexture extends Texture {
  29126. isCube: boolean;
  29127. private _size;
  29128. _generateMipMaps: boolean;
  29129. isEnabled: boolean;
  29130. private _currentRefreshId;
  29131. private _refreshRate;
  29132. onGenerated: () => void;
  29133. private _vertexBuffers;
  29134. private _indexBuffer;
  29135. private _effect;
  29136. private _uniforms;
  29137. private _samplers;
  29138. private _fragment;
  29139. _textures: {
  29140. [key: string]: Texture;
  29141. };
  29142. private _floats;
  29143. private _floatsArrays;
  29144. private _colors3;
  29145. private _colors4;
  29146. private _vectors2;
  29147. private _vectors3;
  29148. private _matrices;
  29149. private _fallbackTexture;
  29150. private _fallbackTextureUsed;
  29151. private _engine;
  29152. constructor(name: string, size: any, fragment: any, scene: Scene, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  29153. private _createIndexBuffer();
  29154. _rebuild(): void;
  29155. reset(): void;
  29156. isReady(): boolean;
  29157. resetRefreshCounter(): void;
  29158. setFragment(fragment: any): void;
  29159. refreshRate: number;
  29160. _shouldRender(): boolean;
  29161. getRenderSize(): number;
  29162. resize(size: number, generateMipMaps: boolean): void;
  29163. private _checkUniform(uniformName);
  29164. setTexture(name: string, texture: Texture): ProceduralTexture;
  29165. setFloat(name: string, value: number): ProceduralTexture;
  29166. setFloats(name: string, value: number[]): ProceduralTexture;
  29167. setColor3(name: string, value: Color3): ProceduralTexture;
  29168. setColor4(name: string, value: Color4): ProceduralTexture;
  29169. setVector2(name: string, value: Vector2): ProceduralTexture;
  29170. setVector3(name: string, value: Vector3): ProceduralTexture;
  29171. setMatrix(name: string, value: Matrix): ProceduralTexture;
  29172. render(useCameraPostProcess?: boolean): void;
  29173. clone(): ProceduralTexture;
  29174. dispose(): void;
  29175. }
  29176. }
  29177. declare module BABYLON {
  29178. /**
  29179. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  29180. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  29181. */
  29182. class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  29183. private _scene;
  29184. private _originalCameras;
  29185. /**
  29186. * ID of the sharpen post process,
  29187. */
  29188. private readonly SharpenPostProcessId;
  29189. /**
  29190. * ID of the image processing post process;
  29191. */
  29192. readonly ImageProcessingPostProcessId: string;
  29193. /**
  29194. * ID of the Fast Approximate Anti-Aliasing post process;
  29195. */
  29196. readonly FxaaPostProcessId: string;
  29197. /**
  29198. * ID of the chromatic aberration post process,
  29199. */
  29200. private readonly ChromaticAberrationPostProcessId;
  29201. /**
  29202. * ID of the grain post process
  29203. */
  29204. private readonly GrainPostProcessId;
  29205. /**
  29206. * Sharpen post process which will apply a sharpen convolution to enhance edges
  29207. */
  29208. sharpen: SharpenPostProcess;
  29209. private _sharpenEffect;
  29210. private bloom;
  29211. /**
  29212. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  29213. */
  29214. depthOfField: DepthOfFieldEffect;
  29215. /**
  29216. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  29217. */
  29218. fxaa: FxaaPostProcess;
  29219. /**
  29220. * Image post processing pass used to perform operations such as tone mapping or color grading.
  29221. */
  29222. imageProcessing: ImageProcessingPostProcess;
  29223. /**
  29224. * Chromatic aberration post process which will shift rgb colors in the image
  29225. */
  29226. chromaticAberration: ChromaticAberrationPostProcess;
  29227. private _chromaticAberrationEffect;
  29228. /**
  29229. * Grain post process which add noise to the image
  29230. */
  29231. grain: GrainPostProcess;
  29232. private _grainEffect;
  29233. /**
  29234. * Animations which can be used to tweak settings over a period of time
  29235. */
  29236. animations: Animation[];
  29237. private _imageProcessingConfigurationObserver;
  29238. private _sharpenEnabled;
  29239. private _bloomEnabled;
  29240. private _depthOfFieldEnabled;
  29241. private _depthOfFieldBlurLevel;
  29242. private _fxaaEnabled;
  29243. private _imageProcessingEnabled;
  29244. private _defaultPipelineTextureType;
  29245. private _bloomScale;
  29246. private _chromaticAberrationEnabled;
  29247. private _grainEnabled;
  29248. private _buildAllowed;
  29249. /**
  29250. * Enable or disable the sharpen process from the pipeline
  29251. */
  29252. sharpenEnabled: boolean;
  29253. private _resizeObserver;
  29254. private _hardwareScaleLevel;
  29255. private _bloomKernel;
  29256. /**
  29257. * Specifies the size of the bloom blur kernel, relative to the final output size
  29258. */
  29259. bloomKernel: number;
  29260. /**
  29261. * Specifies the weight of the bloom in the final rendering
  29262. */
  29263. private _bloomWeight;
  29264. /**
  29265. * Specifies the luma threshold for the area that will be blurred by the bloom
  29266. */
  29267. private _bloomThreshold;
  29268. private _hdr;
  29269. /**
  29270. * The strength of the bloom.
  29271. */
  29272. bloomWeight: number;
  29273. /**
  29274. * The strength of the bloom.
  29275. */
  29276. bloomThreshold: number;
  29277. /**
  29278. * The scale of the bloom, lower value will provide better performance.
  29279. */
  29280. bloomScale: number;
  29281. /**
  29282. * Enable or disable the bloom from the pipeline
  29283. */
  29284. bloomEnabled: boolean;
  29285. private _rebuildBloom();
  29286. /**
  29287. * If the depth of field is enabled.
  29288. */
  29289. depthOfFieldEnabled: boolean;
  29290. /**
  29291. * Blur level of the depth of field effect. (Higher blur will effect performance)
  29292. */
  29293. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  29294. /**
  29295. * If the anti aliasing is enabled.
  29296. */
  29297. fxaaEnabled: boolean;
  29298. private _samples;
  29299. /**
  29300. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  29301. */
  29302. samples: number;
  29303. /**
  29304. * If image processing is enabled.
  29305. */
  29306. imageProcessingEnabled: boolean;
  29307. /**
  29308. * Enable or disable the chromaticAberration process from the pipeline
  29309. */
  29310. chromaticAberrationEnabled: boolean;
  29311. /**
  29312. * Enable or disable the grain process from the pipeline
  29313. */
  29314. grainEnabled: boolean;
  29315. /**
  29316. * @constructor
  29317. * @param {string} name - The rendering pipeline name
  29318. * @param {BABYLON.Scene} scene - The scene linked to this pipeline
  29319. * @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)
  29320. * @param {BABYLON.Camera[]} cameras - The array of cameras that the rendering pipeline will be attached to
  29321. * @param {boolean} automaticBuild - if false, you will have to manually call prepare() to update the pipeline
  29322. */
  29323. constructor(name: string, hdr: boolean, scene: Scene, cameras?: Camera[], automaticBuild?: boolean);
  29324. /**
  29325. * Force the compilation of the entire pipeline.
  29326. */
  29327. prepare(): void;
  29328. private _hasCleared;
  29329. private _prevPostProcess;
  29330. private _prevPrevPostProcess;
  29331. private _setAutoClearAndTextureSharing(postProcess, skipTextureSharing?);
  29332. private _buildPipeline();
  29333. private _disposePostProcesses(disposeNonRecreated?);
  29334. /**
  29335. * Dispose of the pipeline and stop all post processes
  29336. */
  29337. dispose(): void;
  29338. /**
  29339. * Serialize the rendering pipeline (Used when exporting)
  29340. * @returns the serialized object
  29341. */
  29342. serialize(): any;
  29343. /**
  29344. * Parse the serialized pipeline
  29345. * @param source Source pipeline.
  29346. * @param scene The scene to load the pipeline to.
  29347. * @param rootUrl The URL of the serialized pipeline.
  29348. * @returns An instantiated pipeline from the serialized object.
  29349. */
  29350. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  29351. }
  29352. }
  29353. declare module BABYLON {
  29354. class LensRenderingPipeline extends PostProcessRenderPipeline {
  29355. /**
  29356. * The chromatic aberration PostProcess id in the pipeline
  29357. */
  29358. LensChromaticAberrationEffect: string;
  29359. /**
  29360. * The highlights enhancing PostProcess id in the pipeline
  29361. */
  29362. HighlightsEnhancingEffect: string;
  29363. /**
  29364. * The depth-of-field PostProcess id in the pipeline
  29365. */
  29366. LensDepthOfFieldEffect: string;
  29367. private _scene;
  29368. private _depthTexture;
  29369. private _grainTexture;
  29370. private _chromaticAberrationPostProcess;
  29371. private _highlightsPostProcess;
  29372. private _depthOfFieldPostProcess;
  29373. private _edgeBlur;
  29374. private _grainAmount;
  29375. private _chromaticAberration;
  29376. private _distortion;
  29377. private _highlightsGain;
  29378. private _highlightsThreshold;
  29379. private _dofDistance;
  29380. private _dofAperture;
  29381. private _dofDarken;
  29382. private _dofPentagon;
  29383. private _blurNoise;
  29384. /**
  29385. * @constructor
  29386. *
  29387. * Effect parameters are as follow:
  29388. * {
  29389. * chromatic_aberration: number; // from 0 to x (1 for realism)
  29390. * edge_blur: number; // from 0 to x (1 for realism)
  29391. * distortion: number; // from 0 to x (1 for realism)
  29392. * grain_amount: number; // from 0 to 1
  29393. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  29394. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  29395. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  29396. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  29397. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  29398. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  29399. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  29400. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  29401. * }
  29402. * Note: if an effect parameter is unset, effect is disabled
  29403. *
  29404. * @param {string} name - The rendering pipeline name
  29405. * @param {object} parameters - An object containing all parameters (see above)
  29406. * @param {BABYLON.Scene} scene - The scene linked to this pipeline
  29407. * @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)
  29408. * @param {BABYLON.Camera[]} cameras - The array of cameras that the rendering pipeline will be attached to
  29409. */
  29410. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  29411. setEdgeBlur(amount: number): void;
  29412. disableEdgeBlur(): void;
  29413. setGrainAmount(amount: number): void;
  29414. disableGrain(): void;
  29415. setChromaticAberration(amount: number): void;
  29416. disableChromaticAberration(): void;
  29417. setEdgeDistortion(amount: number): void;
  29418. disableEdgeDistortion(): void;
  29419. setFocusDistance(amount: number): void;
  29420. disableDepthOfField(): void;
  29421. setAperture(amount: number): void;
  29422. setDarkenOutOfFocus(amount: number): void;
  29423. enablePentagonBokeh(): void;
  29424. disablePentagonBokeh(): void;
  29425. enableNoiseBlur(): void;
  29426. disableNoiseBlur(): void;
  29427. setHighlightsGain(amount: number): void;
  29428. setHighlightsThreshold(amount: number): void;
  29429. disableHighlights(): void;
  29430. /**
  29431. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  29432. */
  29433. dispose(disableDepthRender?: boolean): void;
  29434. private _createChromaticAberrationPostProcess(ratio);
  29435. private _createHighlightsPostProcess(ratio);
  29436. private _createDepthOfFieldPostProcess(ratio);
  29437. private _createGrainTexture();
  29438. }
  29439. }
  29440. declare module BABYLON {
  29441. class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  29442. /**
  29443. * The PassPostProcess id in the pipeline that contains the original scene color
  29444. */
  29445. SSAOOriginalSceneColorEffect: string;
  29446. /**
  29447. * The SSAO PostProcess id in the pipeline
  29448. */
  29449. SSAORenderEffect: string;
  29450. /**
  29451. * The horizontal blur PostProcess id in the pipeline
  29452. */
  29453. SSAOBlurHRenderEffect: string;
  29454. /**
  29455. * The vertical blur PostProcess id in the pipeline
  29456. */
  29457. SSAOBlurVRenderEffect: string;
  29458. /**
  29459. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  29460. */
  29461. SSAOCombineRenderEffect: string;
  29462. /**
  29463. * The output strength of the SSAO post-process. Default value is 1.0.
  29464. */
  29465. totalStrength: number;
  29466. /**
  29467. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  29468. */
  29469. maxZ: number;
  29470. /**
  29471. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  29472. */
  29473. minZAspect: number;
  29474. /**
  29475. * Number of samples used for the SSAO calculations. Default value is 8
  29476. */
  29477. private _samples;
  29478. /**
  29479. * Dynamically generated sphere sampler.
  29480. */
  29481. private _sampleSphere;
  29482. /**
  29483. * Blur filter offsets
  29484. */
  29485. private _samplerOffsets;
  29486. samples: number;
  29487. /**
  29488. * Are we using bilateral blur ?
  29489. */
  29490. private _expensiveBlur;
  29491. expensiveBlur: boolean;
  29492. /**
  29493. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  29494. */
  29495. radius: number;
  29496. /**
  29497. * The base color of the SSAO post-process
  29498. * The final result is "base + ssao" between [0, 1]
  29499. */
  29500. base: number;
  29501. /**
  29502. * Support test.
  29503. */
  29504. static readonly IsSupported: boolean;
  29505. private _scene;
  29506. private _depthTexture;
  29507. private _normalTexture;
  29508. private _randomTexture;
  29509. private _originalColorPostProcess;
  29510. private _ssaoPostProcess;
  29511. private _blurHPostProcess;
  29512. private _blurVPostProcess;
  29513. private _ssaoCombinePostProcess;
  29514. private _firstUpdate;
  29515. /**
  29516. * @constructor
  29517. * @param {string} name - The rendering pipeline name
  29518. * @param {BABYLON.Scene} scene - The scene linked to this pipeline
  29519. * @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 }
  29520. * @param {BABYLON.Camera[]} cameras - The array of cameras that the rendering pipeline will be attached to
  29521. */
  29522. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  29523. /**
  29524. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  29525. */
  29526. dispose(disableGeometryBufferRenderer?: boolean): void;
  29527. private _createBlurPostProcess(ssaoRatio, blurRatio);
  29528. _rebuild(): void;
  29529. private _generateHemisphere();
  29530. private _createSSAOPostProcess(ratio);
  29531. private _createSSAOCombinePostProcess(ratio);
  29532. private _createRandomTexture();
  29533. }
  29534. }
  29535. declare module BABYLON {
  29536. class SSAORenderingPipeline extends PostProcessRenderPipeline {
  29537. /**
  29538. * The PassPostProcess id in the pipeline that contains the original scene color
  29539. */
  29540. SSAOOriginalSceneColorEffect: string;
  29541. /**
  29542. * The SSAO PostProcess id in the pipeline
  29543. */
  29544. SSAORenderEffect: string;
  29545. /**
  29546. * The horizontal blur PostProcess id in the pipeline
  29547. */
  29548. SSAOBlurHRenderEffect: string;
  29549. /**
  29550. * The vertical blur PostProcess id in the pipeline
  29551. */
  29552. SSAOBlurVRenderEffect: string;
  29553. /**
  29554. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  29555. */
  29556. SSAOCombineRenderEffect: string;
  29557. /**
  29558. * The output strength of the SSAO post-process. Default value is 1.0.
  29559. */
  29560. totalStrength: number;
  29561. /**
  29562. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  29563. */
  29564. radius: number;
  29565. /**
  29566. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  29567. * Must not be equal to fallOff and superior to fallOff.
  29568. * Default value is 0.975
  29569. */
  29570. area: number;
  29571. /**
  29572. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  29573. * Must not be equal to area and inferior to area.
  29574. * Default value is 0.0
  29575. */
  29576. fallOff: number;
  29577. /**
  29578. * The base color of the SSAO post-process
  29579. * The final result is "base + ssao" between [0, 1]
  29580. */
  29581. base: number;
  29582. private _scene;
  29583. private _depthTexture;
  29584. private _randomTexture;
  29585. private _originalColorPostProcess;
  29586. private _ssaoPostProcess;
  29587. private _blurHPostProcess;
  29588. private _blurVPostProcess;
  29589. private _ssaoCombinePostProcess;
  29590. private _firstUpdate;
  29591. /**
  29592. * @constructor
  29593. * @param {string} name - The rendering pipeline name
  29594. * @param {BABYLON.Scene} scene - The scene linked to this pipeline
  29595. * @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 }
  29596. * @param {BABYLON.Camera[]} cameras - The array of cameras that the rendering pipeline will be attached to
  29597. */
  29598. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  29599. /**
  29600. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  29601. */
  29602. dispose(disableDepthRender?: boolean): void;
  29603. private _createBlurPostProcess(ratio);
  29604. _rebuild(): void;
  29605. private _createSSAOPostProcess(ratio);
  29606. private _createSSAOCombinePostProcess(ratio);
  29607. private _createRandomTexture();
  29608. }
  29609. }
  29610. declare module BABYLON {
  29611. class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  29612. /**
  29613. * Public members
  29614. */
  29615. originalPostProcess: Nullable<PostProcess>;
  29616. downSampleX4PostProcess: Nullable<PostProcess>;
  29617. brightPassPostProcess: Nullable<PostProcess>;
  29618. blurHPostProcesses: PostProcess[];
  29619. blurVPostProcesses: PostProcess[];
  29620. textureAdderPostProcess: Nullable<PostProcess>;
  29621. volumetricLightPostProcess: Nullable<PostProcess>;
  29622. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  29623. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  29624. volumetricLightMergePostProces: Nullable<PostProcess>;
  29625. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  29626. luminancePostProcess: Nullable<PostProcess>;
  29627. luminanceDownSamplePostProcesses: PostProcess[];
  29628. hdrPostProcess: Nullable<PostProcess>;
  29629. textureAdderFinalPostProcess: Nullable<PostProcess>;
  29630. lensFlareFinalPostProcess: Nullable<PostProcess>;
  29631. hdrFinalPostProcess: Nullable<PostProcess>;
  29632. lensFlarePostProcess: Nullable<PostProcess>;
  29633. lensFlareComposePostProcess: Nullable<PostProcess>;
  29634. motionBlurPostProcess: Nullable<PostProcess>;
  29635. depthOfFieldPostProcess: Nullable<PostProcess>;
  29636. brightThreshold: number;
  29637. blurWidth: number;
  29638. horizontalBlur: boolean;
  29639. exposure: number;
  29640. lensTexture: Nullable<Texture>;
  29641. volumetricLightCoefficient: number;
  29642. volumetricLightPower: number;
  29643. volumetricLightBlurScale: number;
  29644. sourceLight: Nullable<SpotLight | DirectionalLight>;
  29645. hdrMinimumLuminance: number;
  29646. hdrDecreaseRate: number;
  29647. hdrIncreaseRate: number;
  29648. lensColorTexture: Nullable<Texture>;
  29649. lensFlareStrength: number;
  29650. lensFlareGhostDispersal: number;
  29651. lensFlareHaloWidth: number;
  29652. lensFlareDistortionStrength: number;
  29653. lensStarTexture: Nullable<Texture>;
  29654. lensFlareDirtTexture: Nullable<Texture>;
  29655. depthOfFieldDistance: number;
  29656. depthOfFieldBlurWidth: number;
  29657. motionStrength: number;
  29658. animations: Animation[];
  29659. /**
  29660. * Private members
  29661. */
  29662. private _scene;
  29663. private _currentDepthOfFieldSource;
  29664. private _basePostProcess;
  29665. private _hdrCurrentLuminance;
  29666. private _floatTextureType;
  29667. private _ratio;
  29668. private _bloomEnabled;
  29669. private _depthOfFieldEnabled;
  29670. private _vlsEnabled;
  29671. private _lensFlareEnabled;
  29672. private _hdrEnabled;
  29673. private _motionBlurEnabled;
  29674. private _motionBlurSamples;
  29675. private _volumetricLightStepsCount;
  29676. BloomEnabled: boolean;
  29677. DepthOfFieldEnabled: boolean;
  29678. LensFlareEnabled: boolean;
  29679. HDREnabled: boolean;
  29680. VLSEnabled: boolean;
  29681. MotionBlurEnabled: boolean;
  29682. volumetricLightStepsCount: number;
  29683. motionBlurSamples: number;
  29684. /**
  29685. * @constructor
  29686. * @param {string} name - The rendering pipeline name
  29687. * @param {BABYLON.Scene} scene - The scene linked to this pipeline
  29688. * @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)
  29689. * @param {BABYLON.PostProcess} originalPostProcess - the custom original color post-process. Must be "reusable". Can be null.
  29690. * @param {BABYLON.Camera[]} cameras - The array of cameras that the rendering pipeline will be attached to
  29691. */
  29692. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  29693. private _buildPipeline();
  29694. private _createDownSampleX4PostProcess(scene, ratio);
  29695. private _createBrightPassPostProcess(scene, ratio);
  29696. private _createBlurPostProcesses(scene, ratio, indice, blurWidthKey?);
  29697. private _createTextureAdderPostProcess(scene, ratio);
  29698. private _createVolumetricLightPostProcess(scene, ratio);
  29699. private _createLuminancePostProcesses(scene, textureType);
  29700. private _createHdrPostProcess(scene, ratio);
  29701. private _createLensFlarePostProcess(scene, ratio);
  29702. private _createDepthOfFieldPostProcess(scene, ratio);
  29703. private _createMotionBlurPostProcess(scene, ratio);
  29704. private _getDepthTexture();
  29705. private _disposePostProcesses();
  29706. dispose(): void;
  29707. serialize(): any;
  29708. /**
  29709. * Static members
  29710. */
  29711. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  29712. static LuminanceSteps: number;
  29713. }
  29714. }